-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Issue mmtk/mmtk-core#1170 proposed requiring the ObjectReference
type in mmtk-core to always point into a byte inside an object (in addition to the already-added requirement that ObjectReference
must be word-aligned). That will make side metadata handling much easier, and eliminate the need to distinguish between ObjectReference.to_address::<VM>()
and ObjectReference.to_raw_address()
which is confusing.
JikesRVM is the only officially supported VM where object.to_address::<JikesRVM>()
is different from object.to_raw_address()
. In JikesRVM, ObjectReference
is defined as the address of the array payload. The entire JikesRVM is built around this definition. Constants (such as TIB_OFFSET
, STATUS_OFFSET
and ARRAY_LENGTH_OFFSET
) are all relative to the JikesRVM-level ObjectReference
.
However, to implement mmtk/mmtk-core#1170, we must redefine the MMTk-level ObjectReference
which the JikesRVM binding gives to mmtk-core. The address of the JavaHeader
of each object is a good candidate for the new definition because it is guaranteed to be inside an object. But from the software engineering's point of view,
- we can't change the JikesRVM-level
ObjectReference
because it is used throughout the VM, and - we don't want to change the constants in
mmtk-jikesrvm/mmtk/src/java_header_constants.rs
to be relative toJavaHeader
because it makes the code inconsistent and error-prone.
To solve this problem, we need to make a clear distinction between the MMTk-level ObjectReference
and the JikesRVM-level ObjectReference
. We'll create a new Rust type struct JikesObj(Address)
which is equal to the JikesRVM-level ObjectReference
. We can convert between JikesObj
and (the MMTk-level) ObjectReference
by adding/subtracting JAVA_HEADER_BYTES
. All the header / status / length fields are accessed using JikesObj
using existing constants which are relative to JikesObj
.
The refactoring will take three steps. The first two steps are local to mmtk-jikesrvm. Only the last step involves changes to mmtk-core.
- Step 1: Introducing the JikesRVM-specific
JikesObj
type. All methods that access object metadata and type info are off-loaded to theJikesObj
type and other wrapper types such asTIB
andRVMType
. That leaves the implementation of theObjectModel
trait as simple as converting the MMTk-levelObjectReference
parameter toJikesObj
, and calling its methods. In this step,JikeObj
andObjectReference
still have the same underlyingusize
value. This step only makes sure the new abstraction works. - Step 2: Redefining the MMTk-level
ObjectReference
to point toJavaHeader
. If the abstraction from Step 1 is correct, we only need to rewrite the conversion function betweenObjectReference
andJikesObj
, and change some constants (most importantlyIN_OBJECT_ADDRESS_OFFSET
) inVMObjectModel
. This step makes sure the JikesRVM binding can work with a changed definition of MMTk-levelObjectReference
. - Step 3: Modifying mmtk-core to require
ObjectReference
to point into an object. This will formally introduce the requirement into mmtk-core, and refactor functions (such as the algorithm that searches for the last VO bits) to take advantage of the new requirement. Since the JikesRVM binding already works withObjectReference
pointing into object bodies in Step 2, Step 3 should be as simple as removing redundant methods and constants in theObjectModel
trait.