Download presentation
Presentation is loading. Please wait.
Published byMerilyn McCoy Modified over 9 years ago
1
JVM And CLR Dan Agar April 16, 2004
2
Outline Java and.NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of Environments Conclusions
3
Java Design Developed by Sun Microsystems in the Early 1990s Designed Primarily With the World Wide Web in Mind Portability Safety Simplicity Platform-neutral Virtual Machine
4
.NET Design First Announced by Microsoft in mid-2000 New Platform for Development of Windows Applications Intended to Make Greater Use of the WWW Language-Neutral Virtual Machine
5
Virtual Machines Definition: self-contained environment that behaves like a separate computer Used by Languages Before Java and.NET Abstract Stack-Based Machines
6
Why Use Virtual Machines? Advantages: Fewer Numbers of Compilers to Write Compact Code Safety Disadvantage: Slower Execution Times
7
JVM Approximately 250 Instructions Approximately 250 Instructions 32 bit Word Size 32 bit Word Size Two Forms of Data Representation Two Forms of Data Representation Scalars Scalars Object References Object References
8
JVM Program Execution Java Programs Compiled to Class Files Java Programs Compiled to Class Files JVM Loads Classes as Needed- Performs Safety Checks JVM Loads Classes as Needed- Performs Safety Checks During Execution JVM Performs Runtime Checks During Execution JVM Performs Runtime Checks
9
JVM Many JVM Instructions are Type-Specific iload_1 ; push local int variable 1 iload_2 ; push local int variable 2 iadd ; add the two top elements istore_3 ; pop result into variable 3
10
JVM Four Different Method Call Instructions Virtual Methods Virtual Methods Static Methods Static Methods Interface Methods Interface Methods Virtual Methods Invoked Statically Virtual Methods Invoked Statically
11
JVM Summary Target for Java Target for Java Supports Primarily Safe, Object-Oriented Techniques Supports Primarily Safe, Object-Oriented Techniques Not Necessarily Desirable as a Target for Other Languages Not Necessarily Desirable as a Target for Other Languages
12
CLR Approximately 220 Instructions Approximately 220 Instructions No Fixed Word Size No Fixed Word Size Three Types of Data at Runtime Three Types of Data at Runtime Scalars Scalars References References Instances of Value Classes Instances of Value Classes
13
CLR Program Execution Assembly Files are the Main Units Assembly Files are the Main Units Loaded Dynamically Loaded Dynamically Checks Performed Both During Load Time and During Runtime Checks Performed Both During Load Time and During Runtime
14
CLR CLR Instructions Not Type-Specific ldloc.1 ; push local variable 1 ldloc.2 ; push local variable 2 add ; add the two top elements stloc.3 ; pop result into variable 3
15
CLR Three Different Method Call Instructions call for standard method calls callvirt for virtual and static method calls calli for calls to function pointers
16
CLR Reference and Value Types Value Types: Collections of Fields Value Types: Collections of Fields Analogous to C structs or Pascal records Analogous to C structs or Pascal records Reference Types: Classes and Arrays Reference Types: Classes and Arrays Only One Instruction Needed to Instantiate a Class Only One Instruction Needed to Instantiate a Class
17
Comparisons Safety: The CLR allows for unsafe programming practices- JVM does not. The CLR allows for unsafe programming practices- JVM does not. Parameter Passing: The CLR allows for the passing of reference parameters The CLR allows for the passing of reference parameters Language Support: The CLR is designed to support non object- oriented languages. The CLR is designed to support non object- oriented languages.
18
Case Study: “C Support” The JVM: ecgs-jvm ecgs-jvm University of Queensland University of Queensland gcc Backend Targeting the JVM gcc Backend Targeting the JVM Workarounds Workarounds C’s view of memory C’s view of memory Global Static Data Global Static Data Signed and Unsigned Numbers Signed and Unsigned Numbers Results Results JVM and C Do Not Mix JVM and C Do Not Mix
19
Case Study: “C Support” The CLR gcc.NET gcc.NET Implemented at Cambridge Implemented at Cambridge gcc Backend Targeting the CLR gcc Backend Targeting the CLR No workarounds required No workarounds required Results Results Flawless compilation and execution on CLR Flawless compilation and execution on CLR
20
Performance Java Grande Benchmarks Java and C# Tested Java and C# Tested 1.4Ghz x86, Windows 2000 Professional 1.4Ghz x86, Windows 2000 Professional
21
Conclusions Neither Machine is Definitively “Better”: JVM is a Platform-Neutral Runtime JVM is a Platform-Neutral Runtime CLR is a Language-Neutral Runtime CLR is a Language-Neutral Runtime CLR is More Extensible Languages of Varying Types Supported Languages of Varying Types Supported Could be Ported to Other Platforms Could be Ported to Other Platforms
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.