RealTimeSystems Lab 2001.10.24 Jong-Koo, Lim

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.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
BA1 JVM arkitektur BA2 Specifikation I The Java Virtual Machine Specification specificeres bl.a.: –De grundlæggende datatyper.
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.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
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;
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
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.
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
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.
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.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
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.
Processes CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
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.
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.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
1 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Compiler Construction Lecture 17 Mapping Variables to Memory.
1 The Java Virtual Machine Yearly Programming Project.
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
1 October 1, October 1, 2015October 1, 2015October 1, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa.
Java Bytecode What is a.class file anyway? Dan Fleck George Mason University Fall 2007.
Lecture 10 : Introduction to Java Virtual Machine
Runtime Environments Compiler Construction Chapter 7.
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.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
More on MIPS programs n SPIM does not support everything supported by a general MIPS assembler. For example, –.end doesn’t work Use j $ra –.macro doesn’t.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Programming Languages and Paradigms Activation Records in Java.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Hello world !!! ASCII representation of hello.c.
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.
Operating Systems A Biswas, Dept. of Information Technology.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
(Not too) Real-Time JVM (Progress Report)
Introduction to Operating Systems Concepts
CS 432: Compiler Construction Lecture 15
JAVA MULTIPLE CHOICE QUESTION.
The Java Virtual Machine (JVM)
CS216: Program and Data Representation
Internet and Java Foundations, Programming and Practice
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Java Virtual Machine Complete subject details are available at:
2.1. Compilers and Interpreters
Java Virtual Machine (JVM)
Java Byte Codes (0xCAFEBABE) cs205: engineering software
CSc 453 Interpreters & Interpretation
Course Overview PART I: overview material PART II: inside a compiler
Java Implementation – JVMs, JITs &c Hal Perkins Summer 2004
M S COLLEGE ART’S, COMM., SCI. & BMS
CSc 453 Interpreters & Interpretation
Presentation transcript:

RealTimeSystems Lab Jong-Koo, Lim

RealTimeSystems Lab 2 Contents  Java Architecture  Java Programming Environment  What is ‘Java virtual machine’ ?  Architecture of Java virtual machine  ClassLoader Subsystem  Method Area  Heap  PC Register  Java Stacks  Native Method Stacks  Execution Engine  Next Works

RealTimeSystems Lab 3 Java Architecture  have Four Components(technologies)  Java programming language  Java class file  Java API  Java virtual machine

RealTimeSystems Lab 4 Java Programming Environment A.javaB.javaC.java Java compiler A.classB.classC.class Your program’s source files Your program’s class files Compile-time environment A.classB.classC.class Object.classString.class Your program’s class files Java API’s class files run-time environment Java Virtual Machine Your class files move locally or through a network Java Interpreter

RealTimeSystems Lab 5 What is ‘Java Virtual Machine’ …? H/W Platform & OS Java Virtual Machine Compiled Java Program ByteCode (class files) JVMJVMJVM Linux Win NT Mac  The abstract specification  A concrete implementation  A run-time instance

RealTimeSystems Lab 6 Basic Block diagram of JVM Your program’s class files Java API’s class files Host Operating System Class Loader Execution Engine ByteCodes Native method invocation Java Virtual Machine

RealTimeSystems Lab 7 Architecture of Java Virtual Machine Class Loader Subsystem Execution Engine Method Area Method Area heap Java Stacks PC Registers PC Registers Native Method Stacks Run-time Data Areas Native method Interface Native method Interface Native method library Class files

RealTimeSystems Lab 8 Class Loader Architecture User-defined class loader Objects on the heap part of the Java Virtual Machine implementation Bootstrap class loader Class Loader Subsystem part of the Java Application implementation

RealTimeSystems Lab 9 Loading, Linking, Initialization ( ⅰ ) Loading Linking Verification Preparation Resolution Initialization Class Loader Subsystem

RealTimeSystems Lab 10 Loading, Linking, Initialization ( ⅱ )  Loading  Finding the binary form of class or interface type  By reading from disk or over network  Linking : “ binary form → runtime state form”  Verification : ensuring the correctness of the imported type  Preparation : allocating memory for class variables  Resolution : symbolic reference → direct reference  Initialization  Invoking Java code that initializes class variables Class Loader Subsystem

RealTimeSystems Lab 11 Run-time Data Areas Object Heap Object Method Area Class data Stack frame thread 1 Stack frame thread 2 Stack frame thread 3 Java Stacks thread 1 thread 2 thread 3 Native Method Stacks This areas are shared among all threadsThis areas are exclusive among all threads PC Registers

RealTimeSystems Lab 12 Method Area ( ⅰ )  is analogous to the storage area for compiled code such as ‘data section’ in UNIX process  ‘type information’ + ‘additional information’  Type information  fully qualified name of the type (ex : java.lang.object)  fully qualified name of the type’s direct superclass  which or not the type is a class or an interface  type’s modifiers (public, abstract, or final)  ordered list of the fully qualified names of any direct superinterfaces

RealTimeSystems Lab 13  Additional information  Constant Pool : an ordered set of constants used by the type  Field information : field’s name, field’s type, field’s modifiers  Method information : method’s name, method’s return type, method’s modifier, the number and type of the method’s parameters  Class variables  Reference to class ClassLoader  Reference to class Class Method Area ( ⅱ )

RealTimeSystems Lab 14 An Example of Method Area Use class Tico { private int speed = 5; void drive() { } class Car { public static void main(String[] args) { Tico tico = new Tico(); tico.drive(); } } ※ Sequence  to run ‘Car’ application,  give ‘Car’ to JVM  JVM finds and reads ‘Car.class’  extract the definition of class ‘Car’ from the binary data  places the information into the method area  JVM invokes the main() method by interpreting the bytecodes stored in the method area Method Area

RealTimeSystems Lab 15 Heap  A Java application runs inside its own exclusive JVM instance.  There is only one heap inside a JVM instance  Whenever new object [class instance] is create in a running Java application, the memory for the new object is allocated from a single heap.  All threads in a Java application share the heap  JVM itself is responsible for deciding whether and when to free memory occupied by objects that are no longer referenced by the running application.  It is known as “garbage collection”

RealTimeSystems Lab 16 PC (Program Counter) Register  Each thread of a running program has its own PC register  PC register is created when the thread is started  One word in size  Hold both a ‘ native pointer’ and a ‘ returnAddress’  native pointer : the instruction currently being executed  returnAddress : the address of JVM instruction currently being executed  As a thread executes a Java method, PC register contains the instruction currently being executed by the thread  If a thread is executing a native method, the value of PC register is undefined.

RealTimeSystems Lab 17 Java Stack  When a new thread is launched, the JVM creates a new Java stack for the thread  When a thread invokes a Java method, the JVM creates and pushes a new stack frame onto the thread’s Java stack  It holds parameter, local variables, intermediate computations, and other data  Exceptional conditions  StackOverflowError  OutOfMemoryError

RealTimeSystems Lab 18 Stack frame  has three parts  Local variables section : method’s parameter and local variables  Type int, float, reference, and returnAddress occupy one entry  Type long and double occupy two consecutive entries  Type byte, short, and char are converted to int before being stroed in the local variables  Operand stack : An array of words  JVM use the operand stack as a work space  Frame data  Includes data to support constant pool resolution, normal method return, and exception dispatch Java Stack

Method parameters on the local variables section public static int runClassMethod (int i, long l, float f, double d, Object o, byte b) { return 0; } public int runInstanceMethod (char c, double d, short s, boolean b) { return 0; } int long float double reference int Int i long l float f double d Object o byte b runClassMethod() indextypeparameter int double reference int char c short s double d hidden this boolean b runInstanceMethod() indextypeparameter int Java Stack

RealTimeSystems Lab 20 Adding two local variables iload_0 // push the int in local variable 0 iload_1// push the int in local variable 1 iadd// pop two ints, add them, push result istore_2// pop int, store into local variable before local variables starting Operand stack after iload_0 after iload_1 after iadd after istore_2 Java Stack

RealTimeSystems Lab 21 Implementation of the Java Stack ( ⅰ ) Java Stack Class Example { public static void addAndPrint() { double result = addTwoTypes(1, 22.22); System.out.println(result); } public static double addTwoTypes (int i, double d) { return i + d; } Example Source

Implementation of the Java Stack ( ⅱ ) Java Stack Separate-frames approach Before invocation of addTwoTypes() local variables frame data operand stack 22 After invocation of addTwoTypes() After addTwoTypes() returns Frame for addAndPrint() Frame for addTwoTypes()

Implementation of the Java Stack ( ⅲ ) Java Stack Overlapping-frames approach Before invocation of addTwoTypes() local variables frame data operand stack 23 After invocation of addTwoTypes() After addTwoTypes() returns Frame for addAndPrint() Frame for addTwoTypes()

RealTimeSystems Lab 24 Native Method Stacks Stack frame this Java method invokes a native method the current frame Java stacks native method stack this C function invokes another C function this C function invokes another a Java method

RealTimeSystems Lab 25 Execution Engine ( ⅰ )  Three sense  Abstract specification  Behavior of execution engine  Concrete implementation  Software or hardware  Run-time instance  Thread  In JVM Spec,  Execution engine is defined in terms of an instruction set  describes in detail what an implementation should do  however, say little about how

RealTimeSystems Lab 26 Execution Engine ( ⅱ ) class Act { public static void doMathForever() { int i = 0; for ( ; ; ) { i += 1; i *= 2; } } // Bytecode Stream : 03 3b a b a7 ff f9 // Disassembly : // Method void doMathForever() iconst_0// 03 istore_0// 3b iinc 0, 1// iload_0// 1a iconst_2// 05 imul// 68 istore_0// 3b goto 2// a7 ff f9 Offset of instruction from beginning of method Instruction mnemonics and any operands comment

RealTimeSystems Lab 27 Next Works  Study on ‘inside JVM’ : continue…  Java Class File, Linking Model  Garbage Collection, Exception Handling  Thread Synchronization  RT-Java Spec  Which of JVM Source ‘CDC(CVM)’ or ‘CLDC(KVM)’  Analysis of JVM Source Code  Implementation of RT-JVM