1 / 21

JVM And CLR

JVM And CLR. Dan Agar April 16, 2004. Outline. Java and .NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of Environments Conclusions. Java Design. Developed by Sun Microsystems in the Early 1990s

dai
Télécharger la présentation

JVM And CLR

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 • 32 bit Word Size • Two Forms of Data Representation • Scalars • Object References

  8. JVM Program Execution • Java Programs Compiled to Class Files • JVM Loads Classes as Needed- Performs Safety 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 • Static Methods • Interface Methods • Virtual Methods Invoked Statically

  11. JVM Summary • Target for Java • Supports Primarily Safe, Object-Oriented Techniques • Not Necessarily Desirable as a Target for Other Languages

  12. CLR • Approximately 220 Instructions • No Fixed Word Size • Three Types of Data at Runtime • Scalars • References • Instances of Value Classes

  13. CLR Program Execution • Assembly Files are the Main Units • Loaded Dynamically • 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 • Analogous to C structs or Pascal records • Reference Types: Classes and Arrays • Only One Instruction Needed to Instantiate a Class

  17. Comparisons Safety: • The CLR allows for unsafe programming practices- JVM does not. Parameter Passing: • The CLR allows for the passing of reference parameters Language Support: • The CLR is designed to support non object-oriented languages.

  18. Case Study: “C Support” The JVM: • ecgs-jvm • University of Queensland • gcc Backend Targeting the JVM • Workarounds • C’s view of memory • Global Static Data • Signed and Unsigned Numbers • Results • JVM and C Do Not Mix

  19. Case Study: “C Support” The CLR • gcc .NET • Implemented at Cambridge • gcc Backend Targeting the CLR • No workarounds required • Results • Flawless compilation and execution on CLR

  20. Performance Java Grande Benchmarks • Java and C# Tested • 1.4Ghz x86, Windows 2000 Professional

  21. Conclusions Neither Machine is Definitively “Better”: • JVM is a Platform-Neutral Runtime • CLR is a Language-Neutral Runtime CLR is More Extensible • Languages of Varying Types Supported • Could be Ported to Other Platforms

More Related