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
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