-
Notifications
You must be signed in to change notification settings - Fork 771
Description
For instance fields smaller than 32-bit, they take 32-bit in current OpenJ9 object layout.
For example, a value type like the following has 4 fields:
value class SimpleVT {
byte b1;
byte b2;
byte b3;
byte b4;
}
These 4 fields take 128-bit.
Project Valhalla supports atomic value types, this limits what OpenJ9 can flatten. To support SimpleVT atomically, OpenJ9 cannot flatten SimpleVT in its container class (any class that has SimpleVT as instance field) now.
Openj9 is already distinguishing fields smaller than 32 bit in the interpreter via flag J9FieldTypeBoolean, J9FieldTypeByte, J9FieldTypeChar, J9FieldTypeShort
. Ideally in the object layout, boolean/byte
should only take 8 bits, short/char
should only take 16 bits, so that we can atomically flatten classes like SimpleVT, which will take only 32 bits.
We put 64-bit fields first, then followed by 32-bit fields. Additionally, we need to record the offsets for the first 16-bit and 8-bit field. The 16-bit and 8-bits fields should be put starting from these offsets. For atomic VTs size <= 32 bits, they need to be put at 32-bit aligned address. For atomic VTs 32-bit to 64-bit, they need to be put at 64-bit aligned address. For atomic VT larger than 64-bit, we won’t flatten them.
In the bytecode interpreter, getfieldLogic()
needs to be updated to check for J9FieldTypeBoolean, J9FieldTypeByte, J9FieldTypeChar, J9FieldTypeShort
. New helper inlineMixedObjectReadU16/I16/U8/I8()
need to be added.
Putfield()
also needs to be updated. Instead of using inlineMixedObjectStoreU32()
, New helper inlineMixedObjectWriteU16/I16/U8/I8()
need to be used accordingly.
16-bit and 8-bit fields cannot be reference, so there is no impact on the instanceDescription
. Also each instanceDescription
bit represent 1 reference size data, so that the final object size needs to be rounded up to a multiple of reference size if necessary,
This issue only deals with instance fields now. Similar change could be applied to static field as well in the future.
This is not limited to Valhalla. We can implement this in Valhalla first, then look at extending the new layout to non-Valhalla builds as well.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status