Design and Implementation of the Joeq Virtual Machine Sun Microsystems Labs Mountain View, CA John Whaley Stanford University August 26, 2003.

Slides:



Advertisements
Similar presentations
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Advertisements

Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Extensibility, Safety and Performance in the SPIN Operating System Presented by Allen Kerr.
Run-Time Dynamic Linking for Reprogramming Wireless Sensor Networks
Lab#1 (14/3/1431h) Introduction To java programming cs425
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
Online Performance Auditing Using Hot Optimizations Without Getting Burned Jeremy Lau (UCSD, IBM) Matthew Arnold (IBM) Michael Hind (IBM) Brad Calder (UCSD)
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Combining Static and Dynamic Data in Code Visualization David Eng Sable Research Group, McGill University PASTE 2002 Charleston, South Carolina November.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
Introducing the Common Language Runtime. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution engine.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Introduction to Java.
Efficient Instruction Set Randomization Using Software Dynamic Translation Michael Crane Wei Hu.
COP4020 Programming Languages
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
LLVM Developed by University of Illinois at Urbana-Champaign CIS dept Cisc 471 Matthew Warner.
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
1 Chapter-01 Introduction to Computers and C++ Programming.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
P ARALLEL P ROCESSING I NSTITUTE · F UDAN U NIVERSITY 1.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Threads, Thread management & Resource Management.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
Lecture 10 : Introduction to Java Virtual Machine
The Jikes RVM | Ian Rogers, The University of Manchester | Dr. Ian Rogers Jikes RVM Core Team Member Research Fellow, Advanced.
BLU-ICE and the Distributed Control System Constraints for Software Development Strategies Timothy M. McPhillips Stanford Synchrotron Radiation Laboratory.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Contents 1.Introduction, architecture 2.Live demonstration 3.Extensibility.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
The HipHop Compiler from Facebook By Megha Gupta & Nikhil Kapoor.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
Conrad Benham Java Opcode and Runtime Data Analysis By: Conrad Benham Supervisor: Professor Arthur Sale.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
CINT C++ Interpreter update ROOT2001 at Fermi-Lab Masaharu Goto.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
Introduction Why are virtual machines interesting?
Chapter 1 Basic Concepts of Operating Systems Introduction Software A program is a sequence of instructions that enables the computer to carry.
Getting ready. Why C? Design Features – Efficiency (C programs tend to be compact and to run quickly.) – Portability (C programs written on one system.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
We need a new, common Virtual Execution Environment Herman Venter Research in Software Engineering Group Microsoft Research, Redmond.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Computer System Structures
Applications Active Web Documents Active Web Documents.
Object Oriented Programming in
Current Generation Hypervisor Type 1 Type 2.
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
YAHMD - Yet Another Heap Memory Debugger
Microprocessor and Assembly Language
Workshop in Nihzny Novgorod State University Activity Report
Introduction Enosis Learning.
Introduction Enosis Learning.
Computer Science I CSC 135.
Lecture Topics: 11/1 General Operating System Concepts Processes
Outline Chapter 2 (cont) OS Design OS structure
(Computer fundamental Lab)
System calls….. C-program->POSIX call
JIT Compiler Design Maxine Virtual Machine Dhwani Pandya
Presentation transcript:

Design and Implementation of the Joeq Virtual Machine Sun Microsystems Labs Mountain View, CA John Whaley Stanford University August 26, 2003

Design and Implementation of the Joeq Virtual Machine 1 About me Worked on Java VMs since JDK 1.0 –1996: Extended AWT to support pen input –1997: Clean-room Java VM written in C++ –1998: Jalapeno: designed opt compiler, … –1999: MIT Flex: dataflow framework, etc. –2000: IBM Tokyo JIT: x86 performance –2001: joeq virtual machine

August 26, 2003Design and Implementation of the Joeq Virtual Machine 2 Key Features Implemented in 100% Java –Includes native methods to manipulate addresses, memory, registers directly. Native vs. hosted execution –Native: run directly on hardware –Hosted: run on top of another VM Bootstrap to native via reflection Supports both GC and explicit deallocation

August 26, 2003Design and Implementation of the Joeq Virtual Machine 3 Key Features Compiler and program analysis framework Multiple languages: Java, C, C++, … –Single intermediate representation Static, quasi-static, and dynamic compilation –Single unified compiler infrastructure Online and offline profiling system M:N thread scheduler

August 26, 2003Design and Implementation of the Joeq Virtual Machine 4 Motivation/Purpose Started Ph.D. studies, needed a research infrastructure Purpose: –Try out new ideas –Do research –Publish papers Not out to: –Compete with other VMs –Make a shippable product –Change the world

August 26, 2003Design and Implementation of the Joeq Virtual Machine 5 Other Options SUIF –Written in C++ –Limited support for Java –No dynamic compilation or runtime system –EDG frontend: not 100% gcc compatible Jalapeno –Written in Java –Very familiar with the system –Supports Java only –Not available outside of IBM

August 26, 2003Design and Implementation of the Joeq Virtual Machine 6 Other Options MIT Flex compiler –Written in Java –Familiar with system –Open-source GPL –Statically-compiled Java only Kaffe, etc. –Written in C –Poor design, poor performance

August 26, 2003Design and Implementation of the Joeq Virtual Machine 7 Why Another VM? General problem with established projects: –Established users and code base made it difficult to make major changes. –Wanted to fix the design "mistakes" of Jalapeno and MIT Flex compiler –More productive in Java than in C++

August 26, 2003Design and Implementation of the Joeq Virtual Machine 8 Design Goals Ease of trying out new research ideas –Implemented in Java –Modularity. –Lots of reusable code, use of software patterns. Support Java and C/C++ –A single intermediate representation –Support GC and explicit deallocation

August 26, 2003Design and Implementation of the Joeq Virtual Machine 9 Design Goals Support static, quasi-static, dynamic compilation. –Unified compiler framework. –Compiler implemented in Java. –Allow "maybe" responses due to incomplete information. –General code patching mechanism. –Profile framework allows online/offline profiling.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 10 Design Goals Get something up and running quickly. –Make compiler, runtime easy to debug –Hijack class libraries from running VM –LGPL: can borrow code from other open- source projects –Goal: Self-bootstrapping after one month Make it available for others to use. –Documentation, etc.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 11 Not Design Goals Performance leader –An endless pit, takes a lot of effort –Performance just needs to be “reasonable” –Should be designed for good performance if someone wanted to put in the effort 100% conformance to specification –If programs work, that’s good enough. –No access to good test suites, anyway.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 12 System Overview

August 26, 2003Design and Implementation of the Joeq Virtual Machine 13 Consequences of 100% Java Implementation purity –Self-applicable –VM code is great for program analysis, makes a great test suite Portability –>95% of the code is system-independent –Hosted execution Easier software engineering –Exceptions, GC, software patterns, existing tools

August 26, 2003Design and Implementation of the Joeq Virtual Machine 14 Consequences of 100% Java Java is not a panacea of portability –Hosted execution works OK on most VMs –Native bootstrapping is horribly VM- dependent Internal class library changes cause Joeq to break –Supporting multiple JDK versions is difficult

August 26, 2003Design and Implementation of the Joeq Virtual Machine 15 Bootstrapping technique Use reflection and code analysis to determine root set of methods and objects Dump the objects and code into an object file (COFF or ELF format) Use a standard linker to generate an executable Easy support for static and quasi-static compilation, cross-language calls, dynamic linking, etc.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 16 Bootstrapping trickiness Custom class loaders –Have to hijack class loader and wrap it Files, etc. must be reinitialized –Some state stored in native code Objects created during image write –Finalizer threads, reflection caches, character encodings, … Reflection doesn’t work on all objects –Throwable backtrace, ThreadLocal, etc.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 17 Consequences of bootstrapping technique Standard file formats very useful –Use existing tools and debuggers Big startup time improvement on applications (30x) –Skips all of the initialization code, JIT startup costs Large object files, number of relocations cause problems with some tools.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 18 Consequences of bootstrapping technique Automatic discovery of necessary code: time-consuming, too conservative. Hardwired class list: smaller and faster, but breaks often. Problem: Instantiating an object means class is initialized, which brings in class initializer and many more objects

August 26, 2003Design and Implementation of the Joeq Virtual Machine 19 Consequences of bootstrapping technique Bootstrapping process is a major pain –Time-consuming: reflection is inefficient –Difficult to debug –Process breaks with different JDK versions, environment variables, command line options, locales, etc.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 20 Class library implementation GNU Classpath: too incompatible, too buggy Hijack Sun class library by class merging –Make a “mirror” class with the same name. –Special class loader merges the classes. Easy implementation of native methods. –Native code is just normal Java code. Perfect compatibility, easy updates

August 26, 2003Design and Implementation of the Joeq Virtual Machine 21 Consequences of mirror classes Types don’t match, so javac complains –Cast to java.lang.Object, then back down. Doesn’t work on different class libraries. Many changes between subversions. –Use a hierarchy of mirror classes Incompatible changes lead to many hacks.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 22 Multiple language support Joeq has support for: –Java class files –SUIF files C, C++, Fortran, … –x86 object code All are translated into a single intermediate representation, the Quad.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 23 Quad intermediate representation Analyses and optimizations are instantly applicable to all languages Cross-language inlining and optimization –Elimination of JNI overhead Support for raw address manipulation in Java falls out naturally Type-accurate garbage collection for well- behaved C/C++ programs

August 26, 2003Design and Implementation of the Joeq Virtual Machine 24 Quad intermediate representation Generic interfaces for operators –Lots of shared code Types are optional –Type analysis will construct type information Doesn’t support all esoteric C/C++ features –Computed labels, C++ nastiness, etc.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 25 Hierarchy of Operators

August 26, 2003Design and Implementation of the Joeq Virtual Machine 26 Memory management Memory management is abstracted into different heaps –Each heap has its own allocation/deallocation policy Interface for querying garbage collection policies –Type-accurate, semi-accurate, conservative –GC-safe points or at any instruction –Thread-local allocation pools Working out an interface with JMTk

August 26, 2003Design and Implementation of the Joeq Virtual Machine 27 Consequences of memory management framework Debugging –Run under hosted execution mode –Image snapshots –100% type-accurate is hard Coordinating threads for GC –Making a general interface is tricky

August 26, 2003Design and Implementation of the Joeq Virtual Machine 28 Thread scheduler M:N thread scheduler –Lightweight Java threads –Thread switch at any instruction –Uses local thread queues and work-stealing Timer ticks by using setitimer interrupts (Linux) or a separate thread (Windows) Thread-local information stored off of fs register

August 26, 2003Design and Implementation of the Joeq Virtual Machine 29 Consequences of Java thread scheduler Accessing threads in a machine- independent way is not easy Linux pthread implementation is broken –Lots of bugs, race conditions, inefficiencies –Changing stack pointer is not always supported –Use of fs register is not always supported Windows support is much nicer (?)

August 26, 2003Design and Implementation of the Joeq Virtual Machine 30 Running an Open-Source Project Lots of interest, but very few people actually follow thru Not many people have the skills –Of those, not many have the time Of those, even fewer have the perseverance –The result is that there have only been minor contributions by others Documentation, testing, file releases, updating the web site all take time.

August 26, 2003Design and Implementation of the Joeq Virtual Machine 31 Running an Open-Source Project What’s needed: –Nightly build scripts and regression testing –Implementation hackers –People interested in GC

August 26, 2003Design and Implementation of the Joeq Virtual Machine 32 Conclusion: What I’ve learned Software patterns are useful –Joeq: 100K lines of code Modular design is key –Trying out new type checker: ~2 hours For maximum efficiency, design the system to be easily debuggable. Preemptively eliminate obvious problems. Its more fun to write code when you also write the compiler.