Aarhus University, 2005Esmertec AG1 Implementing Object-Oriented Virtual Machines Lars Bak & Kasper Lund Esmertec AG

Slides:



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

Introduction to .NET Framework
Tahir Nawaz Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Introduction to JAVA Vijayan Sugumaran School of Business Administration Oakland University Rochester, MI
Model for Supporting High Integrity and Fault Tolerance Brian Dobbing, Aonix Europe Ltd Chief Technical Consultant.
The road to reliable, autonomous distributed systems
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Honors Compilers Addressing of Local Variables Mar 19 th, 2002.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
CS884 (Prasad)Java Goals1 “Perfect Quote” You know you've achieved perfection in design, Not when you have nothing more to add, But when you have nothing.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
Embedded Java Research Geoffrey Beers Peter Jantz December 18, 2001.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
7. Just In Time Compilation Prof. O. Nierstrasz Jan Kurs.
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart :
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
Programming Models & Runtime Systems Breakout Report MICS PI Meeting, June 27, 2002.
The Procedure Abstraction, Part VI: Inheritance in OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled.
 OOPLs  Help companies reduce complexity  Increase competition in open markets  Speeds up development  Improves maintenance, resusability, modifiability.
Java Virtual Machine Case Study on the Design of JikesRVM.
Buffered dynamic run-time profiling of arbitrary data for Virtual Machines which employ interpreter and Just-In-Time (JIT) compiler Compiler workshop ’08.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.1 Basics of Java Produced by Harvey Peters, 2008 Copyright.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
Chapter 4 Memory Management Virtual Memory.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Instrumentation in Software Dynamic Translators for Self-Managed Systems Bruce R. Childers Naveen Kumar, Jonathan Misurda and Mary.
Processes Introduction to Operating Systems: Module 3.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Dynamic Compilation I John Cavazos University.
CS 598 Scripting Languages Design and Implementation 14. Self Compilers.
Processes and Virtual Memory
Full and Para Virtualization
Java Example Presentation of a Language. Background Conception: Java began as a language for embedded processors in consumer electronics, such as VCR,
Operating Systems: Summary INF1060: Introduction to Operating Systems and Data Communication.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Introduction to Programming 1 1 2Introduction to Java.
RealTimeSystems Lab Jong-Koo, Lim
Introduction to JAVA Programming
Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java Author: Fridtjof Siebert, CASES 2000 Michael Sallas Object-Oriented Languages.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Smalltalk Implementation Harry Porter, October 2009 Smalltalk Implementation: Optimization Techniques Prof. Harry Porter Portland State University 1.
Introduction to Operating Systems Concepts
Applications Active Web Documents Active Web Documents.
Interface Java 7 COMP T1.
Multi-Dispatch in the Java™ Virtual Machine
Chapter 3: Windows7 Part 2.
Adaptive Code Unloading for Resource-Constrained JVMs
Chapter 3: Windows7 Part 2.
Inlining and Devirtualization Hal Perkins Autumn 2011
Inlining and Devirtualization Hal Perkins Autumn 2009
Java History, Editions, Version Features
M S COLLEGE ART’S, COMM., SCI. & BMS
CSc 453 Interpreters & Interpretation
JIT Compiler Design Maxine Virtual Machine Dhwani Pandya
Dynamic Binary Translators and Instrumenters
IS 135 Business Programming
Presentation transcript:

Aarhus University, 2005Esmertec AG1 Implementing Object-Oriented Virtual Machines Lars Bak & Kasper Lund Esmertec AG

Aarhus University, 2005 Esmertec AG 2 What Is A Virtual Machine? A virtual machine is a software abstraction layer implemented on top of a "real" hardware platform and operating system

Aarhus University, 2005 Esmertec AG 3 Why Are VMs Interesting? Platform independence Code migration Works for small embedded systems and large server systems Most modern programming languages are expecting a virtual machine Enables aggressive optimization

Aarhus University, 2005 Esmertec AG 4 What Is Performance? Fast execution Fast startup time Fast warm-up time Small pauses Scalable Heap size CPUs

Aarhus University, 2005 Esmertec AG 5 Obstacles To Performance? Platform independent byte codes Object-oriented Virtual calls are the default High call frequency High allocation rate Garbage collection Synchronization in language Dynamic class loading

Aarhus University, 2005 Esmertec AG 6 … But That Is Not Enough Preserve the illusion of bytecode interpretation Important for platform independent debugging Provides serviceability for systems in production systems

Aarhus University, 2005 Esmertec AG 7 The Agenda Fast virtual dispatch Runtime compilation Adaptive compilation Applying aggressive optimizations OSVM + demonstration

Aarhus University, 2005 Esmertec AG 8 Our Background Beta runtime system Self virtual machine and IDE Strongtalk virtual machine Java HotSpot virtual machine CLDC HI virtual machine OSVM embedded platform 20+ years of experience in designing and implementing object oriented virtual machines

Aarhus University, 2005 Esmertec AG 9 Dynamic Dispatch Core part of execution in most OO systems Target method at a call site depends on receiver type Runtime lookup is needed to find the method

Aarhus University, 2005 Esmertec AG 10 Lookup Function f(receiver type, name) -> method Implementation techniques for making the lookup function efficient Virtual dispatch tables Inline caches Hash table

Aarhus University, 2005 Esmertec AG 11 Virtual Dispatch Tables Indirect method table Often used in statically typed languages like Java and C++ Technique Object points to dispatch table Method gets index in table of defining class Call vtbl = obj->vtable() target = vtbl[index] call target

Aarhus University, 2005 Esmertec AG 12 Problems With Vtable Indirect calls are very expensive on modern CPUs Can only handle single inheritance in strongly typed systems Does not work with interface calls Makes incremental execution very hard

Aarhus University, 2005 Esmertec AG 13 Inline Caching Save the result from last lookup Deusch-Schiffman Smalltalk, 1984 >85% of all calls are monomorphic in most object oriented systems Use self modifying code for implementation Where should the cache result reside?

Aarhus University, 2005 Esmertec AG 14 Inline Caching Call site has several modes Empty (no targets) Monomorphic (one target) Megamorphic Inline caching used in monomorphic case

Aarhus University, 2005 Esmertec AG 15 Code For Inline Cache Caller // receiver is in ecx move eax, call target Callee cmp eax, ecx[class offset] bne _inline_cache_miss … code for callee method …

Aarhus University, 2005 Esmertec AG 16 Inline Caching Fast on modern CPUs Used in most OO systems where self modifying code is permissible Side benefit: type information is collected

Aarhus University, 2005 Esmertec AG 17 Hash Tables Often needed with dynamic typing Used in Smalltalk and Self Cache for f(receiver type, name) -> method Used as secondary lookup for inline cache

Aarhus University, 2005 Esmertec AG 18 Hash Table Problems Many collisions result in slow down But, what about a 2-way associative cache Hard to update in multi threaded execution Use thread local cache

Aarhus University, 2005 Esmertec AG 19 Combined Solutions Inline caching + hash table Self + Smalltalk Inline caching + virtual table Java

Aarhus University, 2005 Esmertec AG 20 Dynamic Compilation The process of compiling at runtime Goals Fast startup Great performance Good interactive performance Minimize memory footprint

Aarhus University, 2005 Esmertec AG 21 Execution Model Interpreter and compiled code combination Allows the systems to decide: When to compile? What to compile?

Aarhus University, 2005 Esmertec AG 22 Adaptive Compilation Interpreter bytecoded methods compiled methods Profiler / Recompiler Compiler

Aarhus University, 2005 Esmertec AG 23 Should We Compile That Method? Compile the method if the total execution time is reduced How do we predict if it is beneficial? Use the past to predict the future

Aarhus University, 2005 Esmertec AG 24 Learning From The Past Maintain a sliding window of the past to answer: What to compile? When to compile? Two approaches: Invocation counters Sample based profiling

Aarhus University, 2005 Esmertec AG 25 Why We Need Inlining Too many dynamic dispatch Inlining will: Create bigger basic blocks Give compiler more to work on Might avoid allocation

Aarhus University, 2005 Esmertec AG 26 Aggressive Inlining Use class hierarchy analysis if language has static types Inline based on the current state of the class hierarchy Back out if class loading violates assumptions Use deoptimization as described later

Aarhus University, 2005 Esmertec AG 27 Deoptimization The act of converting a compiled activation into a set of interpreter activations Allow the system to Back out of inlining decisions Preserve the bytecode illusion

Aarhus University, 2005 Esmertec AG 28 Needed Information Debugging information stored with compiled code Enough information to reconstruct the interpreter state at each interrupt points Access to compiled frames

Aarhus University, 2005 Esmertec AG 29 What Can Deoptimization Be Used For? Backing out of aggressive inlining Source level inspection Support for source code level debugging Support for incremental execution

Aarhus University, 2005 Esmertec AG 30 The Process Of Deoptimization 1)Identify activations to deoptimize 2)Transform the compiled activations into an off- stack interpreter based representation 3)Insert trap and remove compiled method 4)When returning to activation unpack the off- stack representation to the stack 5)Continue execution in interpreter

Aarhus University, 2005 Esmertec AG 31 Virtual Machine Performance Summary Object oriented optimizations Agressive inlining Subtype check (instanceof & cast) Efficient memory management system Fast allocation Efficient garbage collection Ultra fast synchronization... and a good compiler

Aarhus University, 2005 Esmertec AG 32 The OSVM Product OSVM IDE OSVM Embedded Platform A middleware platform for creating secure, object-oriented, real-time software for embedded devices Always-on platform Requires minimal memory Increases development productivity Enables analysis and correction of software problems in the field Enables minimal updates of deployed software

Aarhus University, 2005 Esmertec AG 33 OSVM Components OSVM IDE Plugin to Eclipse 3.0 Integrated with CVS Configuration of services Complete tool chain OSVM Libraries Core classes Debugging and reflection OSVM Virtual Machine Executes platform-independent code Runs on various platforms OSVM RTOS Small hard real time operating system Allows tight hardware integration

Aarhus University, 2005 Esmertec AG 34 OSVM Demonstration Intelligent tank demonstration OSVM IDE

Aarhus University, 2005 Esmertec AG 35 Summary Discussed various virtual machine optimizations However, the real reason for being here: Hire part time student programmers for our cool project