Java Virtual Machine and Managed Runtime Environment Architecture

  • Slides: 16
Download presentation
Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Virtual Machine § A VM was originally defined by Popek and Goldberg as "an

Virtual Machine § A VM was originally defined by Popek and Goldberg as "an efficient, isolated duplicate of a real machine" § A virtual machine (VM) is a generic software implementation of a dedicated machine (i. e. a specific computer or dedicated software runtime) that executes programs like a dedicated machine § Program might be as big as an OS (System level VM) or as small as a single process (Process level VM) § The program code can be interpreted, compiled (JIT or AOT) or just run under control of VM § Examples: Xen, VMWare, JVM, LLVM, Parrot, Scrumm. VM, Dos. Box, Sega Emulator § Java designers initially thought about JM without V

Runtime Environment § Runtime Environment implements the core behavior of a computer language §

Runtime Environment § Runtime Environment implements the core behavior of a computer language § § § Program entry/exit Low level OS-like services (io, file, …) Runtime-Type-Checking Exception handling Code generation and execution § Runtime doesn’t always mean OS § OS-less system is called baremetal § Programs in low level languages such as C and ASM can run without Runtime § In most situations it is impractical

Managed Runtime Environment § Term was coned in by. NET architects to define Java

Managed Runtime Environment § Term was coned in by. NET architects to define Java without saying Java § It defines the runtime environment that guaranties potential recovery of all errors in the “managed code” § § Erroneous code shouldn’t run free Exceptions should be thrown immediately on error and in the context of the high level language statement Other features are just consequences Type safety, Pointer safety, Thread safety, Garbage collection, Interface unification, Security, Basic managed libraries, Hardware Isolation, Code Verification, Cross-Platform Code, Reflection

Alternative: Binary compilation § Full access to hardware § Platform specific optimizations § Platform

Alternative: Binary compilation § Full access to hardware § Platform specific optimizations § Platform specific binaries § § Platform specific optimizations No cross-platform binaries § Static compilation § § Bigger code Faster startup § Inherent security vulnerabilities § § Code is not semantically verified for correctness Inherent vulnerability to data execution

MRE: Pros § Smaller code § Cross-platform binaries § § § Binaries might be

MRE: Pros § Smaller code § Cross-platform binaries § § § Binaries might be equal to source code Code is semantically verified on loading Better Security Better debugging Profile driven dynamic optimization is possible Potential OS replacement

MRE: Cons § § § Bigger Runtime Bigger performance overhead on runtime Slower startup

MRE: Cons § § § Bigger Runtime Bigger performance overhead on runtime Slower startup with JIT Limited platform specific optimizations Limited usage for system programming

MRE/VM Examples § Specialized § RIP for Post. Script, SQL Server § Generic §

MRE/VM Examples § Specialized § RIP for Post. Script, SQL Server § Generic § PHP, Python, Ruby, CLISP, TCL, Lua, Java RE, CLI(. NET), Google V 8 (Java Script), Mozilla Spider Monkey (Java Script), Android Dalvik (Java)

Ultimate system programming test § Compiler § § Java in Java (Odersky GJ Compiler,

Ultimate system programming test § Compiler § § Java in Java (Odersky GJ Compiler, Eclipse) C# in C# (Mono) § MRE § § § Java (Jikes RVM) Python (Py. Py) Smalltalk (Squeak) § OS Drivers § Java (Experimental Solaris Drivers) § OS Kernel § § § LISP (Genera OS) Java (JNode OS) C# (Singularity OS)

Java language design (1991) § Requirements § § § It should be "simple, object-oriented

Java language design (1991) § Requirements § § § It should be "simple, object-oriented and familiar" It should be "robust and secure" It should be "architecture-neutral and portable" It should execute with "high performance" It should be "interpreted, threaded, and dynamic“ § Principles § § § Remove all unsafe language features Transparent translation to ISA bytecode Bytecode verification

Java: Early History § Design § § § 1991 Oak – programming language for

Java: Early History § Design § § § 1991 Oak – programming language for consumer electronics 1993 Green – programming language for the internet 1995 Java early release § Early History § § § § 1996 Java 1. 0, Hot. Java web browser 1996 Java Card 1998 Java 1. 1. 6 with JIT from Microsoft 1998 Generic Java compiler (Odersky) 1998 J 2 SE, J 2 EE, J 2 ME (JDK 1. 2) 1999 Java Hot. Spot dynamic compiler (JDK 1. 2. x) 1999 Hot. Java web browser discontinued

Java: Current History § 2000 JDK 1. 3 § 2002 JDK 1. 4 XML,

Java: Current History § 2000 JDK 1. 3 § 2002 JDK 1. 4 XML, Regex, NIO, SSL § 2004 JDK 1. 5 Generics, Boxing, Annotations, java. util. concurrent § 2006 JDK 1. 6 § 2007 Sun Spot ultra-low power baremetal Java § 2010 Sun bought by Oracle § 2011 Java 7 Dynamic Language support § 2014 Java 8 Lambda, Stream API

Java at Google § § § § § 2003 Android, Inc 2005 Google acquired

Java at Google § § § § § 2003 Android, Inc 2005 Google acquired Android Inc. 2008 1. 0 Dalvik VM, Iterpreter, Java Lib code taken from Apache Harmony, ARM support 2010 2. 2 Dalvik VM JIT 2012 4. 0 x 86 support 2013 4. 4 ART (AOT) exp. 2014 5. 0 ART, 64 bit 2015 6. 0 Multi-window exp. 2016 7. 0 Multi-window, new profile driven JIT

Java Application Examples • Mobile n Whole Android Market, Java ME for Symbian OS

Java Application Examples • Mobile n Whole Android Market, Java ME for Symbian OS (Opera Mini, Games) • Client n Eclipse, Net. Beans, Jet. Brains IDEA, j. Edit Server n Big Data Hadoop n App Server Tomcat, Geronimo, Axis, j. Boss n Database Java DB, HSQLDB, H 2, JOBD n App Frameworks • Server Faces, Spring, Hibernate, GWT

CLI: Early History § Design § § 1998 MS JRE 1. 1. 6 with

CLI: Early History § Design § § 1998 MS JRE 1. 1. 6 with JIT 1998 J++ 6. 0 2000 CLI ECMA standard draft 2000. NET 1. 0 Beta § Early history § § 2002. NET 1. 0 2004 Mono 1. 0 2005 CLI 3 ed ECMA standard 2005. NET 2. 0 Generics (C# 2. 0)

CLI: Current history § § § § 2006. NET 3. 0 (C# 3. 0)

CLI: Current history § § § § 2006. NET 3. 0 (C# 3. 0) 2008 Mono 2. 0 2009. NET micro framework baremetal Apache License 2010. NET 4. 0 Major Lib update (C# 4. 0) 2012. NET 4. 5 Major Lib update (C# 5. 0) 2012 Mono 3. 0 C# 5. 0 2014. NET 4. 6 Ryu. JIT, Opensource (MIT) (C# 6. 0) 2014 Mono 4. 0. NET integration, C# 5. 0