SlideShare a Scribd company logo
1 of 21
Download to read offline
Java Virtual Machine 101
Sarath Soman
https://sarathsoman.wordpress.com/
@sarathsom4
About Me
● Software Engineer @ Hifx
● Ported SlangForDotNet to JVM
● Added Lambda expression support and local variable type inference to SLANG
● Writing a Matrix and Stat library and trying to implement machine learning
algorithms on top of that
● Started writing LKMs and interfacing C/C++ with Java, C# and Python
● At work I write Scala & Java code
Why you should learn VM internals ?
3 types of programmers
Application programmer – Is one who has knowledge in commonly used frameworks,
libraries and common design patterns
Library designer – Is one who has knowledge in DSA, design patterns / principles and
API design
System programmer – Is one who has knowledge in architecture of the VM / cpu,
native code programming and cross platform programming
Where do you belong now ?
If you want to remain as a average application developer you don’t need to know
anything other than the commonly used frameworks and libraries in the industry.
Specialization is for insects.
A human being should be able to change a diaper, plan an invasion, butcher a hog,
conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a
bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations,
analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
-Robert A. Heinlein
0xcafebabe
● Minor & Major version
● Access Flags
● Constant Pool
● Field Instructions
● Method Instructions
JVM Architecture
ClassLoading Procedure
Execution Engine
Postfix arithmetic expression evaluation
Ex: 4 5 6 * +
JVM Instruction Set
Load & Store
● load
● store
● ldc
Method invoke & ret
● invokevirtual
● invokestatic
● invokeinterface
● invokespecial
● invokedynamic
● return
Others
● putstatic
● getstatic
● putfield
● getfield
● div
● add
● mul
● …....
JVM, CLR, Dalvik comparison
● Register based vs Stack based
What happens when Method A->x() calls Method B->y()
Language Constructs, translation and execution
Bytecode engineering
Modifying existing bytecode - Proxy Obj, AOP
Creating bytecode from scratch - Scala, Spring Data JPA, Slang4JVM
Examples - Generating bytecode
Method Handles & Invokedynamic
● JSR 292
● Dynamic languages on JVM
● Lambda expressions
Thank You
Links
● https://archive.codeplex.com/?p=slangfordotnet
● https://github.com/nsarathsoman/SlangCompiler
● https://github.com/nsarathsoman/slango
● https://github.com/nsarathsoman/FAYA-JVM-101

More Related Content

What's hot

What's hot (9)

Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 
easyM2R
easyM2ReasyM2R
easyM2R
 
[Js hcm] Java script- Testing the awesome
[Js hcm] Java script- Testing the awesome[Js hcm] Java script- Testing the awesome
[Js hcm] Java script- Testing the awesome
 
Inside the JVM
Inside the JVMInside the JVM
Inside the JVM
 
Storage class
Storage classStorage class
Storage class
 
MacRuby
MacRubyMacRuby
MacRuby
 
NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]
 
Ruby FFI
Ruby FFIRuby FFI
Ruby FFI
 

Similar to Java virtual machine 101

walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
walkmod
 
Graal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian WimmerGraal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian Wimmer
Thomas Wuerthinger
 
JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013
Vladimir Ivanov
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the rest
george.james
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir Ivanov
ZeroTurnaround
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
Vladimir Ivanov
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
Spike Brehm
 

Similar to Java virtual machine 101 (20)

Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)
 
Nodejs
NodejsNodejs
Nodejs
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
 
Next-generation JavaScript - OpenSlava 2014
Next-generation JavaScript - OpenSlava 2014Next-generation JavaScript - OpenSlava 2014
Next-generation JavaScript - OpenSlava 2014
 
Building a SIMD Supported Vectorized Native Engine for Spark SQL
Building a SIMD Supported Vectorized Native Engine for Spark SQLBuilding a SIMD Supported Vectorized Native Engine for Spark SQL
Building a SIMD Supported Vectorized Native Engine for Spark SQL
 
Graal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian WimmerGraal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian Wimmer
 
Apache Big Data Europe 2016
Apache Big Data Europe 2016Apache Big Data Europe 2016
Apache Big Data Europe 2016
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java
 
JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the rest
 
Cluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards KubernetesCluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards Kubernetes
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir Ivanov
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2
 
Simple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmSimple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvm
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
 
After the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEANAfter the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEAN
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
 
JAVA BYTE CODE
JAVA BYTE CODEJAVA BYTE CODE
JAVA BYTE CODE
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 

More from Sarath Soman (6)

Zero hype intro to machine learning
Zero hype intro to machine learningZero hype intro to machine learning
Zero hype intro to machine learning
 
Introduction to jvm with asm
Introduction to jvm with asmIntroduction to jvm with asm
Introduction to jvm with asm
 
A peek into the implementation of lambda expression
A peek into the implementation of lambda expressionA peek into the implementation of lambda expression
A peek into the implementation of lambda expression
 
Java virtual machine 101
Java virtual machine 101Java virtual machine 101
Java virtual machine 101
 
Reflections the most important feature in java
Reflections   the most important feature in javaReflections   the most important feature in java
Reflections the most important feature in java
 
Kmug 21-jan-2017-presentation.pptx
Kmug 21-jan-2017-presentation.pptxKmug 21-jan-2017-presentation.pptx
Kmug 21-jan-2017-presentation.pptx
 

Recently uploaded

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Recently uploaded (20)

Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 

Java virtual machine 101

  • 1. Java Virtual Machine 101 Sarath Soman https://sarathsoman.wordpress.com/ @sarathsom4
  • 2. About Me ● Software Engineer @ Hifx ● Ported SlangForDotNet to JVM ● Added Lambda expression support and local variable type inference to SLANG ● Writing a Matrix and Stat library and trying to implement machine learning algorithms on top of that ● Started writing LKMs and interfacing C/C++ with Java, C# and Python ● At work I write Scala & Java code
  • 3. Why you should learn VM internals ? 3 types of programmers Application programmer – Is one who has knowledge in commonly used frameworks, libraries and common design patterns Library designer – Is one who has knowledge in DSA, design patterns / principles and API design System programmer – Is one who has knowledge in architecture of the VM / cpu, native code programming and cross platform programming
  • 4. Where do you belong now ? If you want to remain as a average application developer you don’t need to know anything other than the commonly used frameworks and libraries in the industry.
  • 5. Specialization is for insects. A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. -Robert A. Heinlein
  • 6. 0xcafebabe ● Minor & Major version ● Access Flags ● Constant Pool ● Field Instructions ● Method Instructions
  • 10.
  • 11. Postfix arithmetic expression evaluation Ex: 4 5 6 * +
  • 12.
  • 13. JVM Instruction Set Load & Store ● load ● store ● ldc Method invoke & ret ● invokevirtual ● invokestatic ● invokeinterface ● invokespecial ● invokedynamic ● return Others ● putstatic ● getstatic ● putfield ● getfield ● div ● add ● mul ● …....
  • 14. JVM, CLR, Dalvik comparison ● Register based vs Stack based
  • 15. What happens when Method A->x() calls Method B->y()
  • 17. Bytecode engineering Modifying existing bytecode - Proxy Obj, AOP Creating bytecode from scratch - Scala, Spring Data JPA, Slang4JVM
  • 19. Method Handles & Invokedynamic ● JSR 292 ● Dynamic languages on JVM ● Lambda expressions
  • 21. Links ● https://archive.codeplex.com/?p=slangfordotnet ● https://github.com/nsarathsoman/SlangCompiler ● https://github.com/nsarathsoman/slango ● https://github.com/nsarathsoman/FAYA-JVM-101