General Introduction



Similar documents
Cloud Computing. Up until now

Introduction to Virtual Machines

Jonathan Worthington Scarborough Linux User Group

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

System Structures. Services Interface Structure

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Garbage Collection in the Java HotSpot Virtual Machine

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

picojava TM : A Hardware Implementation of the Java Virtual Machine

CSCI E 98: Managed Environments for the Execution of Programs

1/20/2016 INTRODUCTION

02 B The Java Virtual Machine

Virtual Machines. Virtual Machines

Restraining Execution Environments

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Multi-core Programming System Overview

The Design of the Inferno Virtual Machine. Introduction

Kernel Types System Calls. Operating Systems. Autumn 2013 CS4023

1 The Java Virtual Machine

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

1. Overview of the Java Language

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

Chapter 2 System Structures

Angelika Langer The Art of Garbage Collection Tuning

Virtual Machines.

Virtual Hosting & Virtual Machines

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

A Unified View of Virtual Machines

Example of Standard API

Chapter 3 Operating-System Structures

The V8 JavaScript Engine

12. Introduction to Virtual Machines

ELEC 377. Operating Systems. Week 1 Class 3

Evolution of the Major Programming Languages

Monitoring Java enviroment / applications

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Lecture 1 Introduction to Android

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Overview. The Android operating system is like a cake consisting of various layers.

- Applet java appaiono di frequente nelle pagine web - Come funziona l'interprete contenuto in ogni browser di un certo livello? - Per approfondire

Zing Vision. Answering your toughest production Java performance questions

Understanding Java Garbage Collection

Language Based Virtual Machines... or why speed matters. by Lars Bak, Google Inc

Chapter 3: Operating-System Structures. Common System Components

Overview of CS 282 & Android

Week Overview. Installing Linux Linux on your Desktop Virtualization Basic Linux system administration

Introduction to Embedded Systems. Software Update Problem

Java Garbage Collection Basics

Chapter 14 Virtual Machines

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

Virtualization. Jia Rao Assistant Professor in CS

Data Centers and Cloud Computing

Operating System Structures

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Chapter 7D The Java Virtual Machine

Section 1.4. Java s Magic: Bytecode, Java Virtual Machine, JIT,

Lesson 06: Basics of Software Development (W02D2

Java and Real Time Storage Applications

Instruction Set Design

The Hotspot Java Virtual Machine: Memory and Architecture

What s Cool in the SAP JVM (CON3243)

COM 444 Cloud Computing

Virtual Machines. Adapted from J.S. Smith and R. Nair, VIRTUAL MACHINES, Morgan-Kaufmann Teodor Rus.

Virtual Machine Learning: Thinking Like a Computer Architect

What is a programming language?

Effective Java Programming. efficient software development

Virtualization. Clothing the Wolf in Wool. Wednesday, April 17, 13

Using jvmstat and visualgc to Solve Memory Management Problems

Applications to Computational Financial and GPU Computing. May 16th. Dr. Daniel Egloff

JBoss Seam Performance and Scalability on Dell PowerEdge 1855 Blade Servers

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

CS3600 SYSTEMS AND NETWORKS

How To Use Java On An Ipa (Jspa) With A Microsoft Powerbook (Jempa) With An Ipad And A Microos 2.5 (Microos)

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Replication on Virtual Machines

Hardware/Software Co-Design of a Java Virtual Machine

Extending Tizen Native Framework with Node.js

CS420: Operating Systems OS Services & System Calls

Monitoring and Managing a JVM

JVM Performance Study Comparing Oracle HotSpot and Azul Zing Using Apache Cassandra

Java Environment for Parallel Realtime Development Platform Independent Software Development for Multicore Systems

USE OF PYTHON AS A SATELLITE OPERATIONS AND TESTING AUTOMATION LANGUAGE

Developing Embedded Software in Java Part 1: Technology and Architecture

Lecture 32: The Java Virtual Machine. The Java Virtual Machine

2 Introduction to Java. Introduction to Programming 1 1

CSE 403. Performance Profiling Marty Stepp

PC Based Escape Analysis in the Java Virtual Machine

KVM: A Hypervisor for All Seasons. Avi Kivity avi@qumranet.com

.NET and J2EE Intro to Software Engineering

Full and Para Virtualization

Java Performance. Adrian Dozsa TM-JUG

Distributed and Cloud Computing

Suh yun Ki m (KIS T) (KIS suhyunk@.com

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Transcription:

Managed Runtime Technology: General Introduction Xiao-Feng Li (xiaofeng.li@gmail.com) 2012-10-10

Agenda Virtual machines Managed runtime systems EE and MM (JIT and GC) Summary 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 2

What is Virtual Machine? A virtual machine is implemented by adding a layer of software to a real machine to support the desired virtual machine s architecture. Virtualization constructs an isomorphism that maps a virtual guest system to a real host. Virtualization vs. abstraction Virtualization does not necessarily hide details Abstraction uses interfaces to express the abstract model 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 3

System (ISA) Virtual Machine Such as Vmware, Xen, VirtualBox, etc. Picture from Virtual Machines: Versatile Platforms for Systems and Processes 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 4

Process (ABI) Virtual Machine Different ISAs: Digital FX!32, IA32 EL, etc. Same ISAs: such as Dynamo, etc. 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 5

Virtual-ISA Virtual Machine Such as JVM, CLI, etc. Virtual machine Runtime engine 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 6

Language Runtime Engine Such as Javascript, Python, HTML, etc. Levels: ISA ABI Virtual-ISA -> Language Abstractions: From all architecture details to language interface Usually depend on other supportive functions Our focus: Managed Runtime System Virtual-ISA virtual machine, and language runtime engine 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 7

Link Runtime to Services Language Programming language interface description language service description language Such as AIDL (Android), WSDL (web service) Service entity Process local service Inter-process service cross-machine service Internet cloud computing 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 8

Agenda Virtual machines Managed runtime systems EE and MM (JIT and GC) Summary 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 9

Managed Runtime Systems Why? Portability Security Productivity 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 10

Modern Programming Programming in safe languages No illegal pointer dereference a = 0; b = *a; No illegal control flow jmp format_disk; Then what s safe language? type-safe language and plus If it does not allow operations or conversions which lead to erroneous conditions Memory safety and Control safety Can download-and-run safely 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 11

Safe Languages Almost all the modern languages are safe Commercial: Java, C#, SQL, etc. Academic: LISP, Haskell, ML, etc. Scripting: Ruby, Javascript, PHP, etc. Widely used today and probably tomorrow Unsafe languages C, C++, asm, etc. Will only be used by system programmers Specifically, unsafe languages are commonly used to implement safe languages 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 12

Modern Programming Is Good Programming is becoming higher-level Programmers care only logics What I want to achieve? Leave the details to system How it is achieved? E.g., details like memory allocation/release, thread scheduling, etc. The question: How the system provides the supports? This is our work 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 13

Supports to Modern Prog. Original system supports Compiler: Syntax checking Compilation into binary OS Page allocation and management Process scheduling What are missing? Runtime safety checking Runtime interpretation or compilation Memory management at object granularity 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 14

C code Javascript Compiler SpiderMonkey binary OS OS 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 15

Ruby code Java code Compiler Compiler wordcode bytecode YARV Core JVM binary OS OS 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 16

Example: Ruby Engine Ruby scripts Built-in Classes Object/Class Manager Ruby Parser InstructionSeq Compiler Runtime Envirement OS/Hardware Ruby VM Heap Manager (GC) Ruby VM Parser: convert scripts into AST Compiler: compile AST to wordcode sequence Runtime environment: Yarv core Object/class manager Heap manager 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 17

Example: Java Virtual Machine Java code (*.java) Java Compiler Class loader Execution manager JVM Interpreter compiler class libraries Memory manager Java bytecode (*.class) Thread manager Linux Windows Solaris Hardware 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 18

JVM: a Computing Environment For any computing environment, you have: Programming language: C/C++ Compiler + OS + machine: gcc/g++ + Linux + X86 Runtime library: glibc/glibc++ Java provides the same things: Programming language: defined by Gosling/Joy/Steele in 1995 Virtual machine: JVM has execution engine + threading/mm + ISA Library: class libraries with standard API All are specified into standards 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 19

JVM Specification Mainly defines four things: 1. Instruction set for the VM (bytecodes) 2. JVM executable file format (Java class file) 3. Class loading and verification (ensure the program does not compromise the JVM integrity) 4. Java threading and memory model (the system) Specification says nothing on implementation method Can be implemented as a process in OS, or Part of OS kernel, or OS is part of JVM, or In hardware, or anything 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 20

Agenda Virtual machines Managed runtime systems EE and MM (JIT and GC) Summary 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 21

JVM Execution Engine Executes Java bytecodes either using interpreter or Just-In-Time compiler Registers: PC: Program Counter FP: Frame Pointer SP: Operand Stack Top Pointer Interpreter: directly interpret the bytecodes JIT compiler: compile the bytecode into machine code then execute 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 22

Bytecode Interpreter while( program not end ) { fetch next bytecode => b switch(b) { case ILOAD: load an integer from the local variable array and push on top of current operand stack; case ISTORE: pop an integer from the top of current operand stack and store it into the local variable array; case ALOAD:...... } // end of switch } // end of while 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 23

Object and Vtable x.foo() x object t = [x] vtable bar Data fields 64 Methods addresses [t+64] foo 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 24

JIT Compiler Object reference Object info Vtable Pointer Field 0 Field n JIT compiler compile(metha) JIT ed binary code Object meta data (synchronization, etc.) VTable Class Pointer Interface Table Method A Method X 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 25

Interpreter vs. Compiler Key difference Whether the engine needs to generate native code during execution Interpreter: Portable code execution Easy to implement, no extra memory for compiled code JIT Compiler: Faster code execution Tradeoffs between execution time and compilation time Also tradeoffs between optimization levels 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 26

Adaptive Compilation Bytecode Execution Manager Interpreter or fast Code Generator Counters Optimizing Compiler Unoptimized Native Optimized Native 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 27

Method-based vs. Trace-based JIT Method-based JIT The method to compile is dynamically identified Pros: large optimization scope Cons: not all the method code is executed If execution is very dynamic, optimization is difficult Trace-based JIT The code in the trace is dynamically identified Pros: only compile hot traces and no control flow Cons: hot trace has to be stable If execution is very dynamic, potential trace explosion 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 28

Garbage Collection Reference counting vs. Reachability analysis Reference counting: Object dead when reference count is zero Pros: Real-time death identification Cons: runtime overhead to maintain counters Reachability analysis Object alive when it is reachable from app Pros: no need to maintain counters Cons: need suspend app to find reachable objects Xiao-Feng Li, et al, Cycler: Improve Heap Management for Allocation-intensive Applications with On-the-fly Object Reuse, PDCS 2011 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 29

Reachability Analysis Roots object references in threads execution context Live object The object that is reachable from root reference or other live object Dead object (garbage) Objects that are not accessible to the application A B E F roots C D G 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 30

Mark-Sweep-Compaction Algorithm Trace heap from roots to mark all live objects Sweep garbage from the heap, reclaiming their space Compact the heap to reduce the fragmentation Pros Fast, non-moving Cons Space fragmentation Object access locality 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 31

roots roots roots roots A A B B B B E C C G D D E E E F F G G G Before GC After Mark After Sweep After Compact Live Garbage Free Unknown 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 32

Generational Collection Hypothesis: most objects die young, small percentage long live Algorithm Partition the heap into generations, collect only the younger generation mostly When older generations are full, collect entire heap Pros Short pause time Cons Floating garbage 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 33

roots roots roots A A B B C C Young generation D D E E E B Old generation C Before GC After Mark After Collect Live Garbage Free Unknown 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 34

Concurrent GC App execution (mutator) GC execution (collector) Sleeping pauses Stop-the-world App Thread 1 App Thread 2 GC Thread pauses time Concurrent App Thread 1 App Thread 2 GC Thread time Xiao-Feng Li, et al, Tick: Concurrent GC in Apache Harmony, 2009 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 35

Agenda Virtual machines Managed runtime systems EE and MM (JIT and GC) Summary 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 36

Summary Evolution of Virtual Machines and Runtime Systems Modern Programming and Managed Runtime Systems Differences between a managed runtime system and a traditional runtime system Execution Engine and Garbage Collection 10/10/2012 Managed Runtime Technology Introduction - Xiao-Feng Li 37