SlideShare a Scribd company logo
1 of 13
Download to read offline
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 1
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
11
Lecture 32:Lecture 32:
The Java Virtual MachineThe Java Virtual Machine
COMP 144 Programming Language ConceptsCOMP 144 Programming Language Concepts
Spring 2002Spring 2002
Felix HernandezFelix Hernandez--CamposCampos
April 12April 12
The University of North Carolina at Chapel HillThe University of North Carolina at Chapel Hill
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
22
The Java Virtual MachineThe Java Virtual Machine
•• Java ArchitectureJava Architecture
–– Java Programming LanguageJava Programming Language
–– Java Virtual Machine (JVM)Java Virtual Machine (JVM)
–– Java APIJava API
•• We will use the JVM as a case study of anWe will use the JVM as a case study of an
intermediate program representationintermediate program representation
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 2
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
33
ReferenceReference
•• The content of this lecture is based onThe content of this lecture is based on Inside theInside the
Java 2 Virtual MachineJava 2 Virtual Machine by Billby Bill VennersVenners
–– Chapter 1Introduction to Java's ArchitectureChapter 1Introduction to Java's Architecture
»» http://www.artima.com/insidejvm/ed2/ch01IntroToJavasArchitecthttp://www.artima.com/insidejvm/ed2/ch01IntroToJavasArchitect
urePrint.htmlurePrint.html
–– Chapter 5 The Java Virtual MachineChapter 5 The Java Virtual Machine
»» http://www.artima.com/insidejvm/ed2/ch05JavaVirtualMachine1.http://www.artima.com/insidejvm/ed2/ch05JavaVirtualMachine1.
htmlhtml
–– Interactive IllustrationsInteractive Illustrations
»» http://www.artima.com/insidejvm/applets/index.htmlhttp://www.artima.com/insidejvm/applets/index.html
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
44
The Java Programming EnvironmentThe Java Programming Environment
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 3
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
55
The Java PlatformThe Java Platform
•• The byte code generated by the Java frontThe byte code generated by the Java front--end is anend is an
intermediate formintermediate form
–– CompactCompact
–– PlatformPlatform--independentindependent
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
66
Phases of CompilationPhases of Compilation
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 4
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
77
The Role of the VirtualThe Role of the Virtual MachimeMachime
Local orLocal or
RemoteRemote
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
88
The Execution EngineThe Execution Engine
•• BackBack--end transformation and executionend transformation and execution
–– Simple JVM: byte code interpretationSimple JVM: byte code interpretation
–– JustJust--inin--timetime compilercompiler
»» Method byte codes are compiled into machine code the first timeMethod byte codes are compiled into machine code the first time
they are invokedthey are invoked
»» The machine code is cached for subsequent invocationThe machine code is cached for subsequent invocation
»» It requires more memoryIt requires more memory
–– Adaptive optimizationAdaptive optimization
»» The interpreter monitors the activity of the program, compilingThe interpreter monitors the activity of the program, compiling thethe
heavily used part of the program into machine codeheavily used part of the program into machine code
»» It is much faster than simple interpretationIt is much faster than simple interpretation
»» The memory requirement is only slightly larger due to theThe memory requirement is only slightly larger due to the
2020%%//8080%% rule of program execution (In general, 20% of the coderule of program execution (In general, 20% of the code
is responsible for 80% of the execution)is responsible for 80% of the execution)
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 5
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
99
The Java Virtual MachineThe Java Virtual Machine
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1010
Shared Data AreasShared Data Areas
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 6
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1111
Thread Data AreasThread Data Areas
Frame inFrame in
ExecutionExecution
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1212
Stack FramesStack Frames
•• Stack frames have three parts:Stack frames have three parts:
–– Local variablesLocal variables
–– Operand stackOperand stack
–– Frame dataFrame data
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 7
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1313
Stack FrameStack Frame
Local VariablesLocal Variables
class Example3a {class Example3a {
public staticpublic static intint
runClassMethodrunClassMethod((intint i, longi, long
l, float f, double d, Objectl, float f, double d, Object
o, byte b) {o, byte b) {
return 0;return 0;
}}
publicpublic intint
runInstanceMethodrunInstanceMethod(char c,(char c,
double d, short s, booleandouble d, short s, boolean
b) {b) {
return 0;return 0;
}}
}}
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1414
Stack FrameStack Frame
Operand StackOperand Stack
Adding 2 numbersAdding 2 numbers
iloadiload_0_0
iloadiload_1_1
IaddIadd
istoreistore_2_2
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 8
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1515
Execution ModelExecution Model
•• Eternal Math ExampleEternal Math Example
–– http://www.artima.com/insidejvm/applets/EternalMath.htmhttp://www.artima.com/insidejvm/applets/EternalMath.htm
ll
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1616
Stack FrameStack Frame
Frame DataFrame Data
•• The stack frame also supportsThe stack frame also supports
–– Constant pool resolutionConstant pool resolution
–– Normal method returnNormal method return
–– Exception dispatchException dispatch
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 9
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1717
Stack FrameStack Frame
Frame Allocation in a HeapFrame Allocation in a Heap
class Example3c {class Example3c {
public static voidpublic static void
addAndPrintaddAndPrint()() {{
double result =double result =
addTwoTypesaddTwoTypes(1, 88.88);(1, 88.88);
System.out.System.out.printlnprintln(result)(result)
;;
}}
public static doublepublic static double
addTwoTypesaddTwoTypes((intint i, doublei, double
d) {d) {
return i + d;return i + d;
}}
}}
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1818
Stack FrameStack Frame
Native MethodNative Method
•• A simulated stack of the target language (e.g. C) isA simulated stack of the target language (e.g. C) is
created for JNIcreated for JNI
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 10
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
1919
The HeapThe Heap
•• Class instances and array are stores in a single,Class instances and array are stores in a single,
shared heapshared heap
•• Each Java application has its own heapEach Java application has its own heap
–– IsolationIsolation
–– But a JVM crash will break this isolationBut a JVM crash will break this isolation
•• JVM heaps always implement garbage collectionJVM heaps always implement garbage collection
mechanismsmechanisms
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
2020
HeapHeap
Monolithic Object RepresentationMonolithic Object Representation
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 11
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
2121
The HeapThe Heap
SplittedSplitted Object RepresentationObject Representation
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
2222
ExampleExample
•• HeapOfFishHeapOfFish
–– http://www.artima.com/insidejvm/applets/HeapOfFish.htmhttp://www.artima.com/insidejvm/applets/HeapOfFish.htm
ll
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 12
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
2323
The HeapThe Heap
Memory/Speed TradeoffMemory/Speed Tradeoff
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
2424
The HeapThe Heap
Arrays as ObjectsArrays as Objects
COMP 144
Programming Language Concepts
Lecture 32: The Java Virtual Machine
April 12, 2002
Felix Hernandez-Campos 13
COMP 144 Programming Language Concepts
Felix Hernandez-Campos
2525
Reading AssignmentReading Assignment
•• Inside the Java 2 Virtual MachineInside the Java 2 Virtual Machine by Billby Bill VennersVenners
–– Ch 1Ch 1
–– Ch 5Ch 5
–– IllustrationsIllustrations

More Related Content

What's hot

Two-level Just-in-Time Compilation with One Interpreter and One Engine
Two-level Just-in-Time Compilation with One Interpreter and One EngineTwo-level Just-in-Time Compilation with One Interpreter and One Engine
Two-level Just-in-Time Compilation with One Interpreter and One EngineYusuke Izawa
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?Charlie Gracie
 
Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?Eelco Visser
 
Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...
Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...
Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...Yusuke Izawa
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019corehard_by
 
Overview of .Net Framework 4.5
Overview of .Net Framework 4.5Overview of .Net Framework 4.5
Overview of .Net Framework 4.5Bhushan Mulmule
 
Technology Roundup - Programming Languages & Paradigms
Technology Roundup - Programming Languages & ParadigmsTechnology Roundup - Programming Languages & Paradigms
Technology Roundup - Programming Languages & ParadigmsAshish Belagali
 
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Embarcadero Technologies
 
Porting To Symbian
Porting To SymbianPorting To Symbian
Porting To SymbianMark Wilcox
 

What's hot (16)

Two-level Just-in-Time Compilation with One Interpreter and One Engine
Two-level Just-in-Time Compilation with One Interpreter and One EngineTwo-level Just-in-Time Compilation with One Interpreter and One Engine
Two-level Just-in-Time Compilation with One Interpreter and One Engine
 
Prova
ProvaProva
Prova
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?
 
Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?
 
LLVM Compiler
LLVM CompilerLLVM Compiler
LLVM Compiler
 
Hemanth_Krishnan_resume
Hemanth_Krishnan_resumeHemanth_Krishnan_resume
Hemanth_Krishnan_resume
 
Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...
Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...
Stack Hybridization: A Mechanism for Bridging Two Compilation Strategies in a...
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
Overview of .Net Framework 4.5
Overview of .Net Framework 4.5Overview of .Net Framework 4.5
Overview of .Net Framework 4.5
 
report
reportreport
report
 
RISC-V Online Tutor
RISC-V Online TutorRISC-V Online Tutor
RISC-V Online Tutor
 
Compiler Design Unit 1
Compiler Design Unit 1Compiler Design Unit 1
Compiler Design Unit 1
 
Technology Roundup - Programming Languages & Paradigms
Technology Roundup - Programming Languages & ParadigmsTechnology Roundup - Programming Languages & Paradigms
Technology Roundup - Programming Languages & Paradigms
 
Ctutor
CtutorCtutor
Ctutor
 
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
 
Porting To Symbian
Porting To SymbianPorting To Symbian
Porting To Symbian
 

Viewers also liked

Costa rica vrs inglaterra
Costa rica  vrs inglaterraCosta rica  vrs inglaterra
Costa rica vrs inglaterraHellen BG
 
Modales y comportamiento social para tener una buena personalidad.
Modales  y comportamiento social para tener una buena personalidad.Modales  y comportamiento social para tener una buena personalidad.
Modales y comportamiento social para tener una buena personalidad.Catherin Morillo
 
Macri suspende el CCP
Macri suspende el CCPMacri suspende el CCP
Macri suspende el CCPGabriel Conte
 
Eos legend elite_zntpp
Eos legend elite_zntppEos legend elite_zntpp
Eos legend elite_zntppavgusev
 
Países más religiosos, menos científicos
Países más religiosos, menos científicosPaíses más religiosos, menos científicos
Países más religiosos, menos científicosGabriel Conte
 
Macri sobre la Justicia
Macri sobre la JusticiaMacri sobre la Justicia
Macri sobre la JusticiaGabriel Conte
 
Competitive advantage
Competitive advantageCompetitive advantage
Competitive advantageavgusev
 
Proteus. Nanosecond Transient Absorption of Fullerene (C60).
Proteus. Nanosecond Transient Absorption of Fullerene (C60).Proteus. Nanosecond Transient Absorption of Fullerene (C60).
Proteus. Nanosecond Transient Absorption of Fullerene (C60).avgusev
 
Mesa 1215 Peralta hasta Poggi
Mesa 1215   Peralta hasta PoggiMesa 1215   Peralta hasta Poggi
Mesa 1215 Peralta hasta PoggiGabriel Conte
 
Sistem Komunikasi Seluler
Sistem Komunikasi SelulerSistem Komunikasi Seluler
Sistem Komunikasi SelulerRio Hafandi
 
Session 23-8-07
Session 23-8-07Session 23-8-07
Session 23-8-07gogulraj25
 
Informe ovnis argentina
Informe ovnis argentinaInforme ovnis argentina
Informe ovnis argentinaGabriel Conte
 
Computer fundamentals-series1-e book
Computer fundamentals-series1-e bookComputer fundamentals-series1-e book
Computer fundamentals-series1-e bookRamil Demabogte
 
Presupuesto de Mendoza 2016
Presupuesto de Mendoza 2016Presupuesto de Mendoza 2016
Presupuesto de Mendoza 2016Gabriel Conte
 
Computer fundamental
Computer fundamentalComputer fundamental
Computer fundamentalrachit jaish
 

Viewers also liked (20)

Comp 107chp 1
Comp 107chp 1Comp 107chp 1
Comp 107chp 1
 
Costa rica vrs inglaterra
Costa rica  vrs inglaterraCosta rica  vrs inglaterra
Costa rica vrs inglaterra
 
Modales y comportamiento social para tener una buena personalidad.
Modales  y comportamiento social para tener una buena personalidad.Modales  y comportamiento social para tener una buena personalidad.
Modales y comportamiento social para tener una buena personalidad.
 
Macri suspende el CCP
Macri suspende el CCPMacri suspende el CCP
Macri suspende el CCP
 
Questions Addressed, Questions Remaining: Notes from the Calgary ES&G Account...
Questions Addressed, Questions Remaining: Notes from the Calgary ES&G Account...Questions Addressed, Questions Remaining: Notes from the Calgary ES&G Account...
Questions Addressed, Questions Remaining: Notes from the Calgary ES&G Account...
 
Eos legend elite_zntpp
Eos legend elite_zntppEos legend elite_zntpp
Eos legend elite_zntpp
 
Países más religiosos, menos científicos
Países más religiosos, menos científicosPaíses más religiosos, menos científicos
Países más religiosos, menos científicos
 
Macri sobre la Justicia
Macri sobre la JusticiaMacri sobre la Justicia
Macri sobre la Justicia
 
Competitive advantage
Competitive advantageCompetitive advantage
Competitive advantage
 
Non-financial performance... A missed opportunity? ES&G Forum 2014 Pre-Forum ...
Non-financial performance... A missed opportunity? ES&G Forum 2014 Pre-Forum ...Non-financial performance... A missed opportunity? ES&G Forum 2014 Pre-Forum ...
Non-financial performance... A missed opportunity? ES&G Forum 2014 Pre-Forum ...
 
Proteus. Nanosecond Transient Absorption of Fullerene (C60).
Proteus. Nanosecond Transient Absorption of Fullerene (C60).Proteus. Nanosecond Transient Absorption of Fullerene (C60).
Proteus. Nanosecond Transient Absorption of Fullerene (C60).
 
Mesa 1215 Peralta hasta Poggi
Mesa 1215   Peralta hasta PoggiMesa 1215   Peralta hasta Poggi
Mesa 1215 Peralta hasta Poggi
 
Sistem Komunikasi Seluler
Sistem Komunikasi SelulerSistem Komunikasi Seluler
Sistem Komunikasi Seluler
 
Session 23-8-07
Session 23-8-07Session 23-8-07
Session 23-8-07
 
Introduction to FIT-UCSC @ Aurora
Introduction to FIT-UCSC @ AuroraIntroduction to FIT-UCSC @ Aurora
Introduction to FIT-UCSC @ Aurora
 
Informe ovnis argentina
Informe ovnis argentinaInforme ovnis argentina
Informe ovnis argentina
 
Computer fundamentals-series1-e book
Computer fundamentals-series1-e bookComputer fundamentals-series1-e book
Computer fundamentals-series1-e book
 
Rene gruau
Rene gruauRene gruau
Rene gruau
 
Presupuesto de Mendoza 2016
Presupuesto de Mendoza 2016Presupuesto de Mendoza 2016
Presupuesto de Mendoza 2016
 
Computer fundamental
Computer fundamentalComputer fundamental
Computer fundamental
 

Similar to Understanding jvm

Challenges in Debugging Bootstraps of Reflective Kernels
Challenges in Debugging Bootstraps of Reflective KernelsChallenges in Debugging Bootstraps of Reflective Kernels
Challenges in Debugging Bootstraps of Reflective KernelsESUG
 
invokedynamic: Evolution of a Language Feature
invokedynamic: Evolution of a Language Featureinvokedynamic: Evolution of a Language Feature
invokedynamic: Evolution of a Language FeatureDanHeidinga
 
Java bytecode hacking
Java bytecode hackingJava bytecode hacking
Java bytecode hackingChris Laffra
 
Open arkcompiler
Open arkcompilerOpen arkcompiler
Open arkcompileryiwei yang
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Imperative programming
Imperative programmingImperative programming
Imperative programmingEdward Blurock
 
XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64The Linux Foundation
 
KARMA: Adaptive Android Kernel Live Patching
KARMA: Adaptive Android Kernel Live PatchingKARMA: Adaptive Android Kernel Live Patching
KARMA: Adaptive Android Kernel Live PatchingYue Chen
 
Net Framework Overview
Net Framework OverviewNet Framework Overview
Net Framework OverviewLuis Goldster
 
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...InfluxData
 
Software Define your Current Storage with Opensource
Software Define your Current Storage with OpensourceSoftware Define your Current Storage with Opensource
Software Define your Current Storage with OpensourceAntonio Romeo
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel ArchitecturesJoel Falcou
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?Charlie Gracie
 
XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...
XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...
XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...The Linux Foundation
 

Similar to Understanding jvm (20)

JVM ppt
JVM pptJVM ppt
JVM ppt
 
Challenges in Debugging Bootstraps of Reflective Kernels
Challenges in Debugging Bootstraps of Reflective KernelsChallenges in Debugging Bootstraps of Reflective Kernels
Challenges in Debugging Bootstraps of Reflective Kernels
 
invokedynamic: Evolution of a Language Feature
invokedynamic: Evolution of a Language Featureinvokedynamic: Evolution of a Language Feature
invokedynamic: Evolution of a Language Feature
 
Jax keynote
Jax keynoteJax keynote
Jax keynote
 
Java bytecode hacking
Java bytecode hackingJava bytecode hacking
Java bytecode hacking
 
Open arkcompiler
Open arkcompilerOpen arkcompiler
Open arkcompiler
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Imperative programming
Imperative programmingImperative programming
Imperative programming
 
XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64
 
Inferno
InfernoInferno
Inferno
 
Lecture # 1
Lecture # 1Lecture # 1
Lecture # 1
 
KARMA: Adaptive Android Kernel Live Patching
KARMA: Adaptive Android Kernel Live PatchingKARMA: Adaptive Android Kernel Live Patching
KARMA: Adaptive Android Kernel Live Patching
 
Net Framework Overview
Net Framework OverviewNet Framework Overview
Net Framework Overview
 
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
 
Software Define your Current Storage with Opensource
Software Define your Current Storage with OpensourceSoftware Define your Current Storage with Opensource
Software Define your Current Storage with Opensource
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
 
Assembler
AssemblerAssembler
Assembler
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?
 
MOSP Walkthrough 2009
MOSP Walkthrough 2009MOSP Walkthrough 2009
MOSP Walkthrough 2009
 
XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...
XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...
XPDDS17: uniprof: Transparent Unikernel Performance Profiling and Debugging -...
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Understanding jvm

  • 1. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 1 COMP 144 Programming Language Concepts Felix Hernandez-Campos 11 Lecture 32:Lecture 32: The Java Virtual MachineThe Java Virtual Machine COMP 144 Programming Language ConceptsCOMP 144 Programming Language Concepts Spring 2002Spring 2002 Felix HernandezFelix Hernandez--CamposCampos April 12April 12 The University of North Carolina at Chapel HillThe University of North Carolina at Chapel Hill COMP 144 Programming Language Concepts Felix Hernandez-Campos 22 The Java Virtual MachineThe Java Virtual Machine •• Java ArchitectureJava Architecture –– Java Programming LanguageJava Programming Language –– Java Virtual Machine (JVM)Java Virtual Machine (JVM) –– Java APIJava API •• We will use the JVM as a case study of anWe will use the JVM as a case study of an intermediate program representationintermediate program representation
  • 2. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 2 COMP 144 Programming Language Concepts Felix Hernandez-Campos 33 ReferenceReference •• The content of this lecture is based onThe content of this lecture is based on Inside theInside the Java 2 Virtual MachineJava 2 Virtual Machine by Billby Bill VennersVenners –– Chapter 1Introduction to Java's ArchitectureChapter 1Introduction to Java's Architecture »» http://www.artima.com/insidejvm/ed2/ch01IntroToJavasArchitecthttp://www.artima.com/insidejvm/ed2/ch01IntroToJavasArchitect urePrint.htmlurePrint.html –– Chapter 5 The Java Virtual MachineChapter 5 The Java Virtual Machine »» http://www.artima.com/insidejvm/ed2/ch05JavaVirtualMachine1.http://www.artima.com/insidejvm/ed2/ch05JavaVirtualMachine1. htmlhtml –– Interactive IllustrationsInteractive Illustrations »» http://www.artima.com/insidejvm/applets/index.htmlhttp://www.artima.com/insidejvm/applets/index.html COMP 144 Programming Language Concepts Felix Hernandez-Campos 44 The Java Programming EnvironmentThe Java Programming Environment
  • 3. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 3 COMP 144 Programming Language Concepts Felix Hernandez-Campos 55 The Java PlatformThe Java Platform •• The byte code generated by the Java frontThe byte code generated by the Java front--end is anend is an intermediate formintermediate form –– CompactCompact –– PlatformPlatform--independentindependent COMP 144 Programming Language Concepts Felix Hernandez-Campos 66 Phases of CompilationPhases of Compilation
  • 4. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 4 COMP 144 Programming Language Concepts Felix Hernandez-Campos 77 The Role of the VirtualThe Role of the Virtual MachimeMachime Local orLocal or RemoteRemote COMP 144 Programming Language Concepts Felix Hernandez-Campos 88 The Execution EngineThe Execution Engine •• BackBack--end transformation and executionend transformation and execution –– Simple JVM: byte code interpretationSimple JVM: byte code interpretation –– JustJust--inin--timetime compilercompiler »» Method byte codes are compiled into machine code the first timeMethod byte codes are compiled into machine code the first time they are invokedthey are invoked »» The machine code is cached for subsequent invocationThe machine code is cached for subsequent invocation »» It requires more memoryIt requires more memory –– Adaptive optimizationAdaptive optimization »» The interpreter monitors the activity of the program, compilingThe interpreter monitors the activity of the program, compiling thethe heavily used part of the program into machine codeheavily used part of the program into machine code »» It is much faster than simple interpretationIt is much faster than simple interpretation »» The memory requirement is only slightly larger due to theThe memory requirement is only slightly larger due to the 2020%%//8080%% rule of program execution (In general, 20% of the coderule of program execution (In general, 20% of the code is responsible for 80% of the execution)is responsible for 80% of the execution)
  • 5. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 5 COMP 144 Programming Language Concepts Felix Hernandez-Campos 99 The Java Virtual MachineThe Java Virtual Machine COMP 144 Programming Language Concepts Felix Hernandez-Campos 1010 Shared Data AreasShared Data Areas
  • 6. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 6 COMP 144 Programming Language Concepts Felix Hernandez-Campos 1111 Thread Data AreasThread Data Areas Frame inFrame in ExecutionExecution COMP 144 Programming Language Concepts Felix Hernandez-Campos 1212 Stack FramesStack Frames •• Stack frames have three parts:Stack frames have three parts: –– Local variablesLocal variables –– Operand stackOperand stack –– Frame dataFrame data
  • 7. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 7 COMP 144 Programming Language Concepts Felix Hernandez-Campos 1313 Stack FrameStack Frame Local VariablesLocal Variables class Example3a {class Example3a { public staticpublic static intint runClassMethodrunClassMethod((intint i, longi, long l, float f, double d, Objectl, float f, double d, Object o, byte b) {o, byte b) { return 0;return 0; }} publicpublic intint runInstanceMethodrunInstanceMethod(char c,(char c, double d, short s, booleandouble d, short s, boolean b) {b) { return 0;return 0; }} }} COMP 144 Programming Language Concepts Felix Hernandez-Campos 1414 Stack FrameStack Frame Operand StackOperand Stack Adding 2 numbersAdding 2 numbers iloadiload_0_0 iloadiload_1_1 IaddIadd istoreistore_2_2
  • 8. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 8 COMP 144 Programming Language Concepts Felix Hernandez-Campos 1515 Execution ModelExecution Model •• Eternal Math ExampleEternal Math Example –– http://www.artima.com/insidejvm/applets/EternalMath.htmhttp://www.artima.com/insidejvm/applets/EternalMath.htm ll COMP 144 Programming Language Concepts Felix Hernandez-Campos 1616 Stack FrameStack Frame Frame DataFrame Data •• The stack frame also supportsThe stack frame also supports –– Constant pool resolutionConstant pool resolution –– Normal method returnNormal method return –– Exception dispatchException dispatch
  • 9. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 9 COMP 144 Programming Language Concepts Felix Hernandez-Campos 1717 Stack FrameStack Frame Frame Allocation in a HeapFrame Allocation in a Heap class Example3c {class Example3c { public static voidpublic static void addAndPrintaddAndPrint()() {{ double result =double result = addTwoTypesaddTwoTypes(1, 88.88);(1, 88.88); System.out.System.out.printlnprintln(result)(result) ;; }} public static doublepublic static double addTwoTypesaddTwoTypes((intint i, doublei, double d) {d) { return i + d;return i + d; }} }} COMP 144 Programming Language Concepts Felix Hernandez-Campos 1818 Stack FrameStack Frame Native MethodNative Method •• A simulated stack of the target language (e.g. C) isA simulated stack of the target language (e.g. C) is created for JNIcreated for JNI
  • 10. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 10 COMP 144 Programming Language Concepts Felix Hernandez-Campos 1919 The HeapThe Heap •• Class instances and array are stores in a single,Class instances and array are stores in a single, shared heapshared heap •• Each Java application has its own heapEach Java application has its own heap –– IsolationIsolation –– But a JVM crash will break this isolationBut a JVM crash will break this isolation •• JVM heaps always implement garbage collectionJVM heaps always implement garbage collection mechanismsmechanisms COMP 144 Programming Language Concepts Felix Hernandez-Campos 2020 HeapHeap Monolithic Object RepresentationMonolithic Object Representation
  • 11. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 11 COMP 144 Programming Language Concepts Felix Hernandez-Campos 2121 The HeapThe Heap SplittedSplitted Object RepresentationObject Representation COMP 144 Programming Language Concepts Felix Hernandez-Campos 2222 ExampleExample •• HeapOfFishHeapOfFish –– http://www.artima.com/insidejvm/applets/HeapOfFish.htmhttp://www.artima.com/insidejvm/applets/HeapOfFish.htm ll
  • 12. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 12 COMP 144 Programming Language Concepts Felix Hernandez-Campos 2323 The HeapThe Heap Memory/Speed TradeoffMemory/Speed Tradeoff COMP 144 Programming Language Concepts Felix Hernandez-Campos 2424 The HeapThe Heap Arrays as ObjectsArrays as Objects
  • 13. COMP 144 Programming Language Concepts Lecture 32: The Java Virtual Machine April 12, 2002 Felix Hernandez-Campos 13 COMP 144 Programming Language Concepts Felix Hernandez-Campos 2525 Reading AssignmentReading Assignment •• Inside the Java 2 Virtual MachineInside the Java 2 Virtual Machine by Billby Bill VennersVenners –– Ch 1Ch 1 –– Ch 5Ch 5 –– IllustrationsIllustrations