1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.

Slides:



Advertisements
Similar presentations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advertisements

Virtual Machines Matthew Dwyer 324E Nichols Hall
Instruction Set Design
1 Lecture 10 Intermediate Representations. 2 front end »produces an intermediate representation (IR) for the program. optimizer »transforms the code in.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
JAVA Processors and JIT Scheduling. Overview & Literature n Formulation of the problem n JAVA introduction n Description of Caffeine * Literature: “Java.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Oop JVM in Context. oop What’s a JVM uPlatform-independent execution environment lA different JVM is required for each operating system lAny JVM can run.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 32: The Java Virtual Machine COMP 144 Programming Language Concepts Spring 2002.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
1 Further OO Concepts II – Java Program at run-time Overview l Steps in Executing a Java Program. l Loading l Linking l Initialization l Creation of Objects.
CSc 453 Interpreters & Interpretation Saumya Debray The University of Arizona Tucson.
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.
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.
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
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 Introduction 劉登榮 Deng-Rung Liu 87/7/15. Outline 4 History 4 Why Java? 4 Java Concept 4 Java in Real World 4 Language Overview 4 Java Performance!?
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Compiler Construction Lecture 17 Mapping Variables to Memory.
CSC 8505 Compiler Construction IR Example: Java Bytecode (looking inside class files)
Language Systems Chapter FourModern Programming Languages 1.
JVM And CLR Dan Agar April 16, Outline Java and.NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of.
Arpit Jain Mtech1. Outline Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation.
1 The Java Virtual Machine Yearly Programming Project.
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Java Bytecode What is a.class file anyway? Dan Fleck George Mason University Fall 2007.
Lecture 10 : Introduction to Java Virtual Machine
Java Programming Introduction & Concepts. Introduction to Java Developed at Sun Microsystems by James Gosling in 1991 Object Oriented Free Compiled and.
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
10/12/2015© Hal Perkins & UW CSEV-1 CSE P 501 – Compilers Java Implementation – JVMs, JITs &c Hal Perkins Winter 2008.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
1 Introduction to JVM Based on material produced by Bill Venners.
Roopa.T PESIT, Bangalore. Source and Credits Dalvik VM, Dan Bornstein Google IO 2008 The Dalvik virtual machine Architecture by David Ehringer.
Java Virtual Machine Case Study on the Design of JikesRVM.
12/10/2002© 2002 Hal Perkins & UW CSET-1 CSE 582 – Compilers Java Implementation – JVMs, JITs &c Hal Perkins Autumn 2002.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
LANGUAGE SYSTEMS Chapter Four Modern Programming Languages 1.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.
Runtime System CS 153: Compilers. Runtime System Runtime system: all the stuff that the language implicitly assumes and that is not described in the program.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
CSE 598c – Virtual Machines Survey Proposal: Improving Performance for the JVM Sandra Rueda.
Programming Languages and Paradigms Activation Records in Java.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Hello world !!! ASCII representation of hello.c.
RealTimeSystems Lab Jong-Koo, Lim
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
(Not too) Real-Time JVM (Progress Report)
Java™ 2 Platform Getting Started.
Before You Begin Nahla Abuel-ola /WIT.
A Closer Look at Instruction Set Architectures
Java Virtual Machine Complete subject details are available at:
2.1. Compilers and Interpreters
Mobile Handset Virtual Machine
CSc 453 Interpreters & Interpretation
Java Implementation – JVMs, JITs &c Hal Perkins Summer 2004
Programming language translators
M S COLLEGE ART’S, COMM., SCI. & BMS
CSc 453 Interpreters & Interpretation
Presentation transcript:

1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques

2 Lecture Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage Collection Interpreter and Just-In-Time Compiler Reference: Absolute Java (Second Edition)

3 Hello.c gcc for Win gcc for Mac gcc for Linux Windows X86 Mac PowerPC Hello Linux X86 Hello Typical C Program

4 Hello.java javac Windows X86 Mac PowerPC Hello Hello.class Hello Linux X86 Hello Typical Java Program

5 The Big Picture A.java B.java C.java Java Compiler Java Compiler A.class B.class C.class Java Virtual Machine Java Language Specification Java Virtual Machine Specification

6 Java Platforms (1) A Java Platform consists Java Virtual Machine  CPU A set of standard classes  API JVM in all platforms must satisfy JVM spec. Standard classes can be tailored according the the resource constraints Three levels of Java platforms: J2EE, J2SE and J2ME

7 Java Platforms (2) From KVM White Paper (Sun Microsystem )

8 What Is in the JVM Spec? Bytecodes – the instruction set for Java Virtual Machine Class File Format – The platform independent representation of Java binary code Verification Rules – the algorithm for identifying programs that cannot compromise the integrity of the JVM

9 Implementations of JVM JVM OS Hardware Java OS Hardware Java Chip Java Application Java Application Java Application JVM Specification does not specify how a JVM is implemented

10 Class Area Organization of JVM Class Information Constant Pool Method Area Heap Stack Native Stack Native Stack Execution Engine Execution Engine Native Interface Native Interface Class Loader Class Loader File System *.class File System *.class Internet *.class Internet *.class PC, FP, SP Registers Native Methods Native Methods

11 Class Loader 1. Loading: finding and importing the binary data for a class 2. Linking: Verification: ensuring the correctness of the imported type Preparation: allocating memory for class variables and initializing the memory to default values Resolution: transforming symbolic references from the type into direct references. 3. Initialization: invoking Java code that initializes class variables to their proper starting values

12 Verification Is it a structurally valid class file? Are all constant references correct? Will each instruction always find a correct formed stack and local variable array? Check out external references Other safety requirements

13 Class Area Class Information Internal representation of Java classes Information about the superclass and implemented interfaces Information about the fields and methods Constant Pool Method Area Contains the bytecodes of the methods of the loaded classes

14 Stack The Java stack is composed of frames A frame contains the state of one Java method invocation Logically, a frame has two parts: local variable array and operand stack

15 Stack JVM has no registers; it uses the operand stack for storage of intermediate data values to keep the JVM's instruction set compact to facilitate implementation on architectures with limited number of general purpose registers Each Java thread has its own stack and cannot access the stack of other threads

16 Stack Frame public class A { void f(int x) { int i; for(i=0; i<x; i++) { } } Return PC Caller’s FP Caller’s SP x i Inter- Mediate Data Values SP  Local Variable Array FP  Operand Stack

17 Stack – Each Thread Has its own Stack Heap Stack Thread 1Thread 2Thread 3 Frame

18 Heap All Java objects are allocated in the heap Java applications cannot explicitly free an object The Garbage Collector is invoked from time to time automatically to reclaim the objects that are no longer needed by the application The heap is shared by all Java threads

19 Java Objects in the Heap Class Area class A class Object Heap clazz Fields 1 Fields 2 … Fields n clazz … clazz … class B

20 Garbage Collector Roots: internally defined by the JVM implementation root A B C D E F G A B C D E F G Live Objects: reachable from the roots Garbage (Dead Objects): not reachable from the roots, not accessible to the application

21 root A B C D E F G A B C D E F G B E G B E G Before GC LiveGarbageUnknownFree After MarkAfter SweepAfter Compact Mark / Sweep / Compaction

22 Generational Garbage Collection Most objects live for very shot time A small percentage of them live much longer Old Generation Free Young Generation Old Generation Young Generation Free Old Generation Old Generation Young Generation Free

23 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

24 Interpreter vs Just-In-Time Compiler CPU Interpreter Bytecode JIT Compiler CPU Native Code Bytecode InterpretationJIT Compilation

25 Bytecode Interpreter (1) 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

26 Bytecode interpreter (2) Advantage Ease to implement Does not need extra memory to store compiled code Disadvantage Very Slow: 10 ~ 100 times slower than execution of native code

27 Just-In-Time Compiler Dynamically compiles bytecode into native code at runtime, usually in method granularity Execution of native code is much faster than interpretation of bytecode Compilation is time consuming and may slow down the application Tradeoffs between execution time and compilation time

28 Adaptive Compiler Observation: less than 20% of the methods account for more than 80% of execution time Methods contains loop with large number of iteration; Methods that are frequently invoked Idea 1: only compile the methods where the application spends a lot of time Idea 2: perform advanced compiler optimization for the hottest methods, simple or no compiler optimization for less hot methods

29 How Adaptive Compiler Works Set three thresholds T1, T2 (T1<T2) Each method has a counter that is initialized to 0. Whenever the method is invoked, increase its counter by 1 The methods with counter lower than T1 are executed using interpreter When a method’s counter reaches T1, compile this method with simple optimizations When a method’s counter reaches T2, recompile this method with advanced optimizations

30 Processor Virtualization Hardware Processor VMWare Virtual Processor LinuxWindows Win32 AppLinux App

31 Key Points Java Platform Java Virtual Machine A set of standard classes

32 Announcement SWE Revised Program Discussion Monday December 29, 2008 at 12:10-1:00 in 24/141