SlideShare une entreprise Scribd logo
1  sur  36
Lecture 14 Java Virtual Machine  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1
Java Program ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],2
Java ByteCode ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],3
Java ByteCode ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],3
Internal Architecture of JVM Execution engine Class loader subsystem method area heap Java stacks pc registers native method stacks Runtime data area class files Native  Method Interface Native Method Libraries
Internal Architecture of JVM ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JVM Execution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Runtime Data Area Shared among threads class  data class  data class  data class  data class  data class  data Method area object object object object object object object object object heap
Threads  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thread’s Runtime Data Area thread 1 thread 2 thread 3 pc registers stack  frame stack  frame stack  frame stack  frame thread 1 stack  frame stack  frame stack  frame thread 2 java stacks stack  frame stack  frame thread 3 thread 3 native  method stacks
Thread’s Runtime Data Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Loader Subsystem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Loader Subsystem B. Linking:  2. Preparation:  A. allocating memory for class variables   and initializing the memory to default values. B. allocating data structures that are used internally    by the virtual machine:   1. method tables.   2. data structure that allows any method to be  invoked on instances of a class without  requiring a search of superclasses at invocation  time.
Class Loader Subsystem B. Linking:  3. Resolution:  A. transforming symbolic references (e.g. class.field)   into direct references. B. symbolic reference is replaced with a direct    reference that can be more efficiently processed    if the reference is used repeatedly.    (Quick instructions) C. Implementation choice:  static linkage vs. laziest resolution
Class Loader Subsystem C. Initialization: invoke java code that initializes class  variables to their proper staring values. A. execution of any class variable initializers  B. Before a class can be initialized, its direct superclass  must be initialized, as well as the direct superclass  of its direct superclass, and so on, recursively. C. Initialization may cause loading, linking, and initialization errors D. Because Java is multithreaded, initialization of a  class or interface requires careful synchronization.
Class Loader Subsystem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Loader Subsystem ,[object Object],[object Object],[object Object],[object Object],[object Object]
Method Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type Information stored in Method Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type Information stored in Method Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Method Table ,[object Object],[object Object],[object Object],[object Object],[object Object]
Heap ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Object Representation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ptr to object pool ptr to class data the handle pool the heap instance data instance data instance data instance data the object pool class data the method area ptr to handle pool an object reference ,[object Object]
ptr to class data the heap instance data instance data instance data instance data The method area class  data ptr to heap an object reference Keeping object data all in one place.
prt to class data length=(2) ar[0] (ref)  ar[1] (ref) the heap prt to class data length=(2) ar[0][0](int)  ar[0][1] (int) prt to class data length=(2) ar[1][0] (int) ar[1][1] (int) class  data for  [[I class  data for  [I the method area ar (an array ref) int [ ] [ ] ar= new int [2][2]; One possible heap representation for arrays.
prt to full class data prt to method data prt to method data prt to method data ● ● ● entry point  into all data  for the class method  data method  data method  data prt to special structure instance data instance data the heap ptr into heap method  table the method area Keeping the method table close at hand.
Object Representation ,[object Object],[object Object],[object Object],[object Object],[object Object]
Program Counter ,[object Object],[object Object],[object Object],[object Object]
Java Stack ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
type long float double reference int type index 0 1 3 4 6 7 parameter int i long l float f double d Object o byte b reference int double int int type index 0 1 2 4 5 parameter hidden this char c short s boolean b double d runClassMethod() runInstanceMethod() Class Example3a {  // local variable in stack frame public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) { return 0;} public int runInstanceMethod(int i, double d, short s, boolean b) { return 0;} }
100 98 0 1 2 local  variables operand  stack 100 98 100 0 1 2 100 98 100 98 0 1 2 100 98 198 0 1 2 100 98 198 0 1 2 before  starting after  iload_0 after  iload_1 after  iadd after  istore_2 iload_0 // push local variable 0 (an int)  iload_1 // push local variable 1 (an int) iadd  // pop two ints, add them and push result istore_2 // pop int, store into  local variable 2
Class Example3c { public static void addAndPrint() { double result = addTwoTypes(1, 88.88); System.out.println(result); } public static double addTwoTypes (int i, double d) { return i + d; } } Java Stack Example
1 88.88 0 1 0 1 1 88.88 0 1 89.88 0 1 before invoke  addTwoTypes()  After invoke  addTwoTypes()  addTwoTypes() returns frames for  addAndPrint( ) frame for  addTwoTypes( ) local  variables frame data operand  stack
0 1 0 1 0 1 before invoke  addTwoTypes()  After invoke  addTwoTypes()  addTwoTypes() returns frames for  addAndPrint( ) frame for  addTwoTypes( ) 1 88.88 1 88.88 89.88
stack frame stack frame stack frame stack frame Java stacks a native method  stack this Java method invokes  a native method. the current frame This C function invokes another C function This C function invokes a Java  method

Contenu connexe

Tendances (20)

More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
Oops
OopsOops
Oops
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Core java
Core javaCore java
Core java
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
 
Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)
 
Io streams
Io streamsIo streams
Io streams
 
Ppt chapter03
Ppt chapter03Ppt chapter03
Ppt chapter03
 
Java API, Exceptions and IO
Java API, Exceptions and IOJava API, Exceptions and IO
Java API, Exceptions and IO
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Jist of Java
Jist of JavaJist of Java
Jist of Java
 
JAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESJAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICES
 
Taking User Input in Java
Taking User Input in JavaTaking User Input in Java
Taking User Input in Java
 
Basic of Javaio
Basic of JavaioBasic of Javaio
Basic of Javaio
 
Lecture d-inheritance
Lecture d-inheritanceLecture d-inheritance
Lecture d-inheritance
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 

Similaire à Java14

Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction AKR Education
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAVINASH KUMAR
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya Johnny
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
OOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdfOOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdfArthyR3
 
Java quick reference
Java quick referenceJava quick reference
Java quick referenceArthyR3
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performanceRoger Xia
 

Similaire à Java14 (20)

JVM
JVMJVM
JVM
 
17515
1751517515
17515
 
Java mcq
Java mcqJava mcq
Java mcq
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
First fare 2010 java-introduction
First fare 2010 java-introductionFirst fare 2010 java-introduction
First fare 2010 java-introduction
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
OOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdfOOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdf
 
Java quick reference
Java quick referenceJava quick reference
Java quick reference
 
JAVA CONCEPTS
JAVA CONCEPTS JAVA CONCEPTS
JAVA CONCEPTS
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
 

Dernier

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Java14

  • 1.
  • 2.
  • 3.
  • 4.
  • 5. Internal Architecture of JVM Execution engine Class loader subsystem method area heap Java stacks pc registers native method stacks Runtime data area class files Native Method Interface Native Method Libraries
  • 6.
  • 7.
  • 8. Runtime Data Area Shared among threads class data class data class data class data class data class data Method area object object object object object object object object object heap
  • 9.
  • 10. Thread’s Runtime Data Area thread 1 thread 2 thread 3 pc registers stack frame stack frame stack frame stack frame thread 1 stack frame stack frame stack frame thread 2 java stacks stack frame stack frame thread 3 thread 3 native method stacks
  • 11.
  • 12.
  • 13. Class Loader Subsystem B. Linking: 2. Preparation: A. allocating memory for class variables and initializing the memory to default values. B. allocating data structures that are used internally by the virtual machine: 1. method tables. 2. data structure that allows any method to be invoked on instances of a class without requiring a search of superclasses at invocation time.
  • 14. Class Loader Subsystem B. Linking: 3. Resolution: A. transforming symbolic references (e.g. class.field) into direct references. B. symbolic reference is replaced with a direct reference that can be more efficiently processed if the reference is used repeatedly. (Quick instructions) C. Implementation choice: static linkage vs. laziest resolution
  • 15. Class Loader Subsystem C. Initialization: invoke java code that initializes class variables to their proper staring values. A. execution of any class variable initializers B. Before a class can be initialized, its direct superclass must be initialized, as well as the direct superclass of its direct superclass, and so on, recursively. C. Initialization may cause loading, linking, and initialization errors D. Because Java is multithreaded, initialization of a class or interface requires careful synchronization.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. ptr to class data the heap instance data instance data instance data instance data The method area class data ptr to heap an object reference Keeping object data all in one place.
  • 26. prt to class data length=(2) ar[0] (ref) ar[1] (ref) the heap prt to class data length=(2) ar[0][0](int) ar[0][1] (int) prt to class data length=(2) ar[1][0] (int) ar[1][1] (int) class data for [[I class data for [I the method area ar (an array ref) int [ ] [ ] ar= new int [2][2]; One possible heap representation for arrays.
  • 27. prt to full class data prt to method data prt to method data prt to method data ● ● ● entry point into all data for the class method data method data method data prt to special structure instance data instance data the heap ptr into heap method table the method area Keeping the method table close at hand.
  • 28.
  • 29.
  • 30.
  • 31. type long float double reference int type index 0 1 3 4 6 7 parameter int i long l float f double d Object o byte b reference int double int int type index 0 1 2 4 5 parameter hidden this char c short s boolean b double d runClassMethod() runInstanceMethod() Class Example3a { // local variable in stack frame public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) { return 0;} public int runInstanceMethod(int i, double d, short s, boolean b) { return 0;} }
  • 32. 100 98 0 1 2 local variables operand stack 100 98 100 0 1 2 100 98 100 98 0 1 2 100 98 198 0 1 2 100 98 198 0 1 2 before starting after iload_0 after iload_1 after iadd after istore_2 iload_0 // push local variable 0 (an int) iload_1 // push local variable 1 (an int) iadd // pop two ints, add them and push result istore_2 // pop int, store into local variable 2
  • 33. Class Example3c { public static void addAndPrint() { double result = addTwoTypes(1, 88.88); System.out.println(result); } public static double addTwoTypes (int i, double d) { return i + d; } } Java Stack Example
  • 34. 1 88.88 0 1 0 1 1 88.88 0 1 89.88 0 1 before invoke addTwoTypes() After invoke addTwoTypes() addTwoTypes() returns frames for addAndPrint( ) frame for addTwoTypes( ) local variables frame data operand stack
  • 35. 0 1 0 1 0 1 before invoke addTwoTypes() After invoke addTwoTypes() addTwoTypes() returns frames for addAndPrint( ) frame for addTwoTypes( ) 1 88.88 1 88.88 89.88
  • 36. stack frame stack frame stack frame stack frame Java stacks a native method stack this Java method invokes a native method. the current frame This C function invokes another C function This C function invokes a Java method

Notes de l'éditeur

  1. 1