java virtual machine and managed runtime environment architecture introduction sergey salshev

15
Java Virtual Machine and Java Virtual Machine and Managed Runtime Environment Managed Runtime Environment Architecture Architecture Introduction Introduction Sergey Salshev Sergey Salshev

Upload: michael-clark

Post on 27-Dec-2015

233 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java Virtual Machine and Managed Java Virtual Machine and Managed Runtime Environment ArchitectureRuntime Environment Architecture

IntroductionIntroduction

Sergey Salshev Sergey Salshev

Page 2: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Virtual MachineVirtual Machine A VM was originally defined by A VM was originally defined by Popek and Goldberg as as

"an efficient, isolated duplicate of a real machine""an efficient, isolated duplicate of a real machine" A virtual machine (VM) is a generic software A virtual machine (VM) is a generic software

implementation of a dedicated machine (i.e. a specific implementation of a dedicated machine (i.e. a specific computer or dedicated software runtime) that executes computer or dedicated software runtime) that executes programs like a dedicated machineprograms like a dedicated machine

Program might be as big as an OS (System level VM) or Program might be as big as an OS (System level VM) or as small as a single process (Process level VM)as small as a single process (Process level VM)

The program code can be interpreted, compiled (JIT or The program code can be interpreted, compiled (JIT or AOT) or just run under control of VMAOT) or just run under control of VM

Examples: Xen, VMWare,JVM, LLVM, Parrot, Examples: Xen, VMWare,JVM, LLVM, Parrot, ScrummVM, DosBox, Sega Emulator ScrummVM, DosBox, Sega Emulator

Java designers initially thought about JM without VJava designers initially thought about JM without V

Page 3: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Runtime EnvironmentRuntime Environment

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

Program entry/exitProgram entry/exit Low level OS-like services (io, file, …)Low level OS-like services (io, file, …) Runtime-Type-CheckingRuntime-Type-Checking Exception handlingException handling Code generation and executionCode generation and execution

Runtime doesn’t always mean OSRuntime doesn’t always mean OS OS-less system is called baremetalOS-less system is called baremetal

Programs in low level languages such as C and ASM Programs in low level languages such as C and ASM can run without Runtimecan run without Runtime

In most situations it is impracticalIn most situations it is impractical

Page 4: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Managed Runtime EnvironmentManaged Runtime Environment

Term was coned in by .NET architects to define Java Term was coned in by .NET architects to define Java without saying Javawithout saying Java

It defines the runtime environment that guaranties It defines the runtime environment that guaranties potential recovery of all errors in the “managed code”potential recovery of all errors in the “managed code”

Erroneous code shouldn’t run freeErroneous code shouldn’t run free Exceptions should be thrown immediately on error and in the Exceptions should be thrown immediately on error and in the

context of the high level language statementcontext of the high level language statement Other features are just consequencesOther features are just consequences Type safety, Pointer safety, Thread safety, Garbage collection, Type safety, Pointer safety, Thread safety, Garbage collection,

Interface unification, Security, Basic managed libraries, Interface unification, Security, Basic managed libraries, Hardware Isolation, Code Verification, Cross-Platform Code, Hardware Isolation, Code Verification, Cross-Platform Code, ReflectionReflection

Page 5: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Alternative: Binary compilationAlternative: Binary compilation

Full access to hardwareFull access to hardware Platform specific optimizationsPlatform specific optimizations

Platform specific binariesPlatform specific binaries Platform specific optimizationsPlatform specific optimizations No cross-platform binariesNo cross-platform binaries

Static compilationStatic compilation Bigger codeBigger code Faster startupFaster startup

Inherent security vulnerabilitiesInherent security vulnerabilities Code is not semantically verified for correctnessCode is not semantically verified for correctness Inherent vulnerability to data executionInherent vulnerability to data execution

Page 6: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

MRE: ProsMRE: Pros

Smaller codeSmaller code Cross-platform binaries Cross-platform binaries

Binaries might be equal to source codeBinaries might be equal to source code

Code is semantically verified on loadingCode is semantically verified on loading Better SecurityBetter Security Better debuggingBetter debugging Profile driven dynamic optimization is possibleProfile driven dynamic optimization is possible Potential OS replacementPotential OS replacement

Page 7: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

MRE: ConsMRE: Cons

Bigger RuntimeBigger Runtime Bigger performance overhead on runtimeBigger performance overhead on runtime Slower startup with JITSlower startup with JIT Limited platform specific optimizationsLimited platform specific optimizations Limited usage for system programmingLimited usage for system programming

Page 8: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

MRE/VM ExamplesMRE/VM Examples

SpecializedSpecialized RIP for PostScript, SQL ServerRIP for PostScript, SQL Server

GenericGeneric PHP, Python, Ruby, CLISP, TCL, Lua, Java PHP, Python, Ruby, CLISP, TCL, Lua, Java

RE, CLIRE, CLI((.NET), Google V8 (Java Script), .NET), Google V8 (Java Script), Mozilla Spider Monkey (Java Script), Android Mozilla Spider Monkey (Java Script), Android Dalvik (Java)Dalvik (Java)

Page 9: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Ultimate system programming testUltimate system programming test

CompilerCompiler Java in Java (Odersky GJ Compiler, Eclipse)Java in Java (Odersky GJ Compiler, Eclipse) C# in C# (Mono) C# in C# (Mono)

MREMRE Java (Jikes RVM)Java (Jikes RVM) Python (PyPy)Python (PyPy) Smalltalk (Squeak)Smalltalk (Squeak)

OS DriversOS Drivers Java (Experimental Solaris Drivers)Java (Experimental Solaris Drivers)

OS KernelOS Kernel LISP (Genera OS)LISP (Genera OS) Java (JNode OS)Java (JNode OS) C# (Singularity OS)C# (Singularity OS)

Page 10: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java language design (1991)Java language design (1991)

RequirementsRequirements It should be "simple, object-oriented and familiar"It should be "simple, object-oriented and familiar" It should be "robust and secure"It should be "robust and secure" It should be "architecture-neutral and portable"It should be "architecture-neutral and portable" It should execute with "high performance"It should execute with "high performance" It should be "interpreted, threaded, and dynamic“It should be "interpreted, threaded, and dynamic“

PrinciplesPrinciples Remove all unsafe language featuresRemove all unsafe language features Transparent translation to ISA bytecodeTransparent translation to ISA bytecode Bytecode verificationBytecode verification

Page 11: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java: Early HistoryJava: Early History

DesignDesign 1991 Oak1991 Oak – – programming language for consumer electronicsprogramming language for consumer electronics 1993 Green – programming language for the internet1993 Green – programming language for the internet 1995 Java early release1995 Java early release

Early HistoryEarly History 1996 1996 Java 1.0, HotJava web browserJava 1.0, HotJava web browser 1996 Java Card1996 Java Card 1998 1998 Java 1.1.6 with JIT from MicrosoftJava 1.1.6 with JIT from Microsoft 1998 Generic Java compiler (Odersky)1998 Generic Java compiler (Odersky) 1998 J2SE, J2EE, J2ME (JDK 1.2)1998 J2SE, J2EE, J2ME (JDK 1.2) 1999 Java HotSpot dynamic compiler (JDK 1.2.x)1999 Java HotSpot dynamic compiler (JDK 1.2.x) 1999 HotJava web browser discontinued1999 HotJava web browser discontinued

Page 12: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java: Current HistoryJava: Current History

2000 JDK 1.32000 JDK 1.3 2002 JDK 1.4 XML, Regex, NIO, SSL2002 JDK 1.4 XML, Regex, NIO, SSL 2004 JDK 1.5 Generics, Boxing, Annotations, 2004 JDK 1.5 Generics, Boxing, Annotations,

java.util.concurrentjava.util.concurrent 2006 JDK 1.62006 JDK 1.6 2007 Sun Spot ultra-low power baremetal Java2007 Sun Spot ultra-low power baremetal Java 2010 Sun bought by Oracle2010 Sun bought by Oracle 2011 JDK 1.7 Dynamic Language support2011 JDK 1.7 Dynamic Language support

Page 13: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java at GoogleJava at Google

2003 Android, Inc2003 Android, Inc 2005 Google acquired Android Inc.2005 Google acquired Android Inc. 2008 Android 1.0 Dalvik VM, Iterpreter, 2008 Android 1.0 Dalvik VM, Iterpreter,

Java Lib code taken from Apache Java Lib code taken from Apache HarmonyHarmony

2010 Android 2.2 Dalvik VM JIT2010 Android 2.2 Dalvik VM JIT 2013 Android 4.4 ART (AOT)2013 Android 4.4 ART (AOT)

Page 14: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

Java Application ExamplesJava Application Examples

• MobileMobile Whole Android Market, Java ME for Symbian OS (Opera Mini, Games)Whole Android Market, Java ME for Symbian OS (Opera Mini, Games)

• ClientClient Eclipse, NetBeans, JetBrain IDEA, jEditEclipse, NetBeans, JetBrain IDEA, jEdit

• ServerServer Big DataBig Data

HadoopHadoop App ServerApp Server

Tomcat, Geronimo, Axis, jBossTomcat, Geronimo, Axis, jBoss DatabaseDatabase

Java DB, HSQLDB, H2, JOBDJava DB, HSQLDB, H2, JOBD App FrameworksApp Frameworks

• Server Faces, Springs, Hibernate, GWTServer Faces, Springs, Hibernate, GWT

Page 15: Java Virtual Machine and Managed Runtime Environment Architecture Introduction Sergey Salshev

CLI HistoryCLI History DesignDesign

1998 MS JRE 1.1.6 with JIT1998 MS JRE 1.1.6 with JIT 1998 1998 J++J++ 6.0 6.0 2000 CLI ECMA standard draft2000 CLI ECMA standard draft 2000 .NET 1.0 Beta2000 .NET 1.0 Beta

Early historyEarly history 2002 .NET 1.0 2002 .NET 1.0 2004 Mono 1.02004 Mono 1.0 2005 CLI 3ed ECMA standard2005 CLI 3ed ECMA standard 2005 .NET 2.0 Generics2005 .NET 2.0 Generics

Current historyCurrent history 2006 .NET 3.02006 .NET 3.0 2008 Mono 2.02008 Mono 2.0 2009 .NET micro framework baremetal Apache License2009 .NET micro framework baremetal Apache License 2010 .NET 4.0 Major Lib update2010 .NET 4.0 Major Lib update 2012 Mono 3.02012 Mono 3.0