JLang
JLang copied to clipboard
Using jclass objects for metadata
Currently our runtime representation for Class<?> objects contains no extra information over the Java-specified Class object information.
We save all of the class metadata (# fields, field names, object size in bytes, etc) in a HashMap<jclass,metadata>.
Therefore every metadata lookup requires a hash map lookup and we need to allocate some extra memory for the map itself.
It is reasonable to store this metadata in the jclass
objects themselves, in front of the Class> objects so `*jclass == head of metadata` and `*(jclass + sizeof(metadata))` is a reference to the Class> object.
This is a performance optimization that requires some compiler and runtime restructuring.