1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 32: The Java Virtual Machine COMP 144 Programming Language Concepts Spring 2002.

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

1 Lecture 10 Intermediate Representations. 2 front end »produces an intermediate representation (IR) for the program. optimizer »transforms the code in.
BA1 JVM arkitektur BA2 Specifikation I The Java Virtual Machine Specification specificeres bl.a.: –De grundlæggende datatyper.
Date: Subject:Distributed Data Processing Name:Maria Br ü ckner.
Memory Management Case study (JVM & CLR) KIRAN KUMAR V KIRAN KUMAR V LENIN THUMMALAPALLI LENIN THUMMALAPALLI.
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.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 33: Code Generation and Linking COMP 144 Programming Language Concepts Spring 2002.
CS 536 Spring Run-time organization Lecture 19.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 31: Building a Runnable Program COMP 144 Programming Language Concepts Spring 2002.
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
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.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 34: Code Optimization COMP 144 Programming Language Concepts Spring 2002 Felix.
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 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
CSc 453 Interpreters & Interpretation Saumya Debray The University of Arizona Tucson.
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.
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.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Compiler Construction Lecture 17 Mapping Variables to Memory.
Lecture 17 Modern Programming Trends JVM, C#, .NET
1 The Java Virtual Machine Yearly Programming Project.
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
1 Binding Time and Storage Allocation (Section ) CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos.
1 October 1, October 1, 2015October 1, 2015October 1, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
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.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
1 Introduction to JVM Based on material produced by Bill Venners.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
12/10/2002© 2002 Hal Perkins & UW CSET-1 CSE 582 – Compilers Java Implementation – JVMs, JITs &c Hal Perkins Autumn 2002.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Garbage Collection and Classloading Java Garbage Collectors  Eden Space  Surviver Space  Tenured Gen  Perm Gen  Garbage Collection Notes Classloading.
CSE 598c – Virtual Machines Survey Proposal: Improving Performance for the JVM Sandra Rueda.
Object Oriented Software Development 4. C# data types, objects and references.
Programming Languages and Paradigms Activation Records in Java.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
The Execution System1. 2 Introduction Managed code and managed data qualify code or data that executes in cooperation with the execution engine The execution.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
RealTimeSystems Lab Jong-Koo, Lim
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
The Java Virtual Machine (JVM)
Compositional Pointer and Escape Analysis for Java Programs
Internet and Java Foundations, Programming and Practice
Java Virtual Machine Complete subject details are available at:
2.1. Compilers and Interpreters
CSc 453 Interpreters & Interpretation
Java Implementation – JVMs, JITs &c Hal Perkins Summer 2004
CSc 453 Interpreters & Interpretation
Presentation transcript:

1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 32: The Java Virtual Machine COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos April 12 The University of North Carolina at Chapel Hill

2 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Java Virtual Machine Java ArchitectureJava Architecture –Java Programming Language –Java Virtual Machine (JVM) –Java API We will use the JVM as a case study of an intermediate program representationWe will use the JVM as a case study of an intermediate program representation

3 COMP 144 Programming Language Concepts Felix Hernandez-Campos Reference The content of this lecture is based on Inside the Java 2 Virtual Machine by Bill VennersThe content of this lecture is based on Inside the Java 2 Virtual Machine by Bill Venners –Chapter 1Introduction to Java's Architecture » urePrint.html urePrint.htmlhttp:// urePrint.html –Chapter 5 The Java Virtual Machine » html htmlhttp:// html –Interactive Illustrations »

4 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Java Programming Environment

5 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Java Platform The byte code generated by the Java front-end is an intermediate formThe byte code generated by the Java front-end is an intermediate form –Compact –Platform-independent

6 COMP 144 Programming Language Concepts Felix Hernandez-Campos Phases of Compilation

7 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Role of the Virtual Machime Local or Remote

8 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Execution Engine Back-end transformation and executionBack-end transformation and execution –Simple JVM: byte code interpretation –Just-in-time compiler »Method byte codes are compiled into machine code the first time they are invoked »The machine code is cached for subsequent invocation »It requires more memory –Adaptive optimization »The interpreter monitors the activity of the program, compiling the heavily used part of the program into machine code »It is much faster than simple interpretation »The memory requirement is only slightly larger due to the 20 % /80 % rule of program execution (In general, 20% of the code is responsible for 80% of the execution)

9 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Java Virtual Machine

10 COMP 144 Programming Language Concepts Felix Hernandez-Campos Shared Data Areas

11 COMP 144 Programming Language Concepts Felix Hernandez-Campos Thread Data Areas Frame in Execution

12 COMP 144 Programming Language Concepts Felix Hernandez-Campos Stack Frames Stack frames have three parts:Stack frames have three parts: –Local variables –Operand stack –Frame data

13 COMP 144 Programming Language Concepts Felix Hernandez-Campos Stack Frame Local Variables class Example3a { public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) { public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) { return 0; return 0; } public int runInstanceMethod(char c, double d, short s, boolean b) { public int runInstanceMethod(char c, double d, short s, boolean b) { return 0; return 0; }}

14 COMP 144 Programming Language Concepts Felix Hernandez-Campos Stack Frame Operand Stack Adding 2 numbers iload_0iload_1Iaddistore_2

15 COMP 144 Programming Language Concepts Felix Hernandez-Campos Execution Model Eternal Math ExampleEternal Math Example – l lhttp:// l

16 COMP 144 Programming Language Concepts Felix Hernandez-Campos Stack Frame Frame Data The stack frame also supportsThe stack frame also supports –Constant pool resolution –Normal method return –Exception dispatch

17 COMP 144 Programming Language Concepts Felix Hernandez-Campos Stack Frame Frame Allocation in a Heap class Example3c { public static void addAndPrint() { public static void addAndPrint() { double result = addTwoTypes(1, 88.88); double result = addTwoTypes(1, 88.88); System.out.println(result) ; System.out.println(result) ; } public static double addTwoTypes(int i, double d) { public static double addTwoTypes(int i, double d) { return i + d; return i + d; }}

18 COMP 144 Programming Language Concepts Felix Hernandez-Campos Stack Frame Native Method A simulated stack of the target language (e.g. C) is created for JNIA simulated stack of the target language (e.g. C) is created for JNI

19 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Heap Class instances and array are stores in a single, shared heapClass instances and array are stores in a single, shared heap Each Java application has its own heapEach Java application has its own heap –Isolation –But a JVM crash will break this isolation JVM heaps always implement garbage collection mechanismsJVM heaps always implement garbage collection mechanisms

20 COMP 144 Programming Language Concepts Felix Hernandez-Campos Heap Monolithic Object Representation

21 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Heap Splitted Object Representation

22 COMP 144 Programming Language Concepts Felix Hernandez-Campos Example HeapOfFishHeapOfFish – l lhttp:// l

23 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Heap Memory/Speed Tradeoff

24 COMP 144 Programming Language Concepts Felix Hernandez-Campos The Heap Arrays as Objects

25 COMP 144 Programming Language Concepts Felix Hernandez-Campos Reading Assignment Inside the Java 2 Virtual Machine by Bill VennersInside the Java 2 Virtual Machine by Bill Venners –Ch 1 –Ch 5 –Illustrations