| Object layout for Java objects and array objects |
| ------------------------------------------------ |
| |
| 1) objects |
| |
| Need extensible header for the use of: |
| |
| a) VM: locking, hashing, dynamic type checking, virtual function |
| invocation. |
| |
| b) GC: garbage collection (can be the reference count for a |
| reference counting garbage collector) |
| |
| obj_t : { <header_t>, <field_t1>, <field_t2>, ..., <field_tN> } |
| |
| +--------+ <-- pointer to object |
| | header | |
| +--------+ |
| | field1 | |
| +--------+ |
| | field2 | |
| +--------+ |
| | ...... | |
| +--------+ |
| | fieldN | |
| +--------+ |
| |
| 2) arrays |
| |
| +--------+ <-- pointer to array object |
| | len | |
| +--------+ |
| | header | |
| +--------+ |
| | obj_t* | |
| +--------+ |
| | ...... | |
| +--------+ |
| | ...... | |
| +--------+ |
| |
| array_object_t : { uint, <header_t>, [ 0 x <obj_t>* ] } |
| |
| |
| Type information for java objects |
| --------------------------------- |
| |
| VM_Class object for each class. This object needs at least the |
| following fields: |
| |
| a) pointer to VM_Class object of its super class |
| b) list of interfaces implemented |
| c) list of field descriptors |
| d) list of methods (static, constructor, virtual, finalizer) |
| e) list of attributes (constant value, code, exceptions, inner |
| classes, synthetic, source file, line number table, local variable |
| table, deprecated) |
| |
| We would most likely need a method dispatch table as well (vtable). |