Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce JikesRVM-specific object accessor types (#177)
The main purpose of this PR is make a clear distinction between the `ObjectReference` type in JikesRVM and the `ObjectReference` type in mmtk-core. This PR introduced `JikesObj`, a Rust type that represents the JikesRVM-level `ObjectReference`. It needs an explicit conversion to convert to/from the MMTk-level `ObjectReference` types. The interface between mmtk-core and the mmtk-jikesrvm binding is refactored to do fewer things with the MMTk-level `ObjectReference`. - Trait methods that pass `ObjectReference` to the binding, notably the methods in `ObjectModel`, now simply convert the MMTk-level `ObjectReference` to `JikesObj`, and then call methods of `JikesObj`. - Concrete methods for accessing object headers, fields, and layout information are now implemented by `JikesObj` (and other wrapper types including `TIB` and `RVMType`). - The `JikesRVMSlot` trait now does the conversion between `JikesObj` and the MMTk-level `ObjectReference` when loading or storing a slot. This allows us to change the definition of the MMTk-level `ObjectReference` in the future, while concrete methods of `JikesObj` still use offset constants relative to the JikesRVM-level `ObjectReference` which will not change. The interface between the Rust part and the Java part of the binding are refactored to involve `JikesObj` only. - API functions in `api.rs` accept `JikesObj` parameters from JikesRVM and return `JikeObj` to JikesRVM where JikesRVM uses the JikesRVM-level `ObjectReference`. - We wrap all JTOC calls into strongly-typed Rust functions, and make the weakly-typed `jtoc_call!` macro private to the wrappers. In this way, we ensure none of the API functions or JTOC calls leak the MMTk-level `ObjectReference` values to JikesRVM, or accidentally interpret a JikesRVM-level `ObjectReference` as an MMTk-level `ObjectReference`. We also do some obvious refactoring that makes the code more readable.: - Encapsulated many field-loading statements in the form of `(addr + XXXX_OFFSET)::load<T>()` into dedicated methods. - Encapsulated the code for determining the overhead of hash fields into a function `JikesObj::hashcode_overhead` and simplified many methods that depend on that. - Renaming "edge" to "slot" in `RustScanThread.java`. And obvious bug fixes: - The call to `DO_REFERENCE_PROCESSING_HELPER_SCAN_METHOD_OFFSET` used to erroneously interpret 0 as `true`. This has been fixed by relying on the conversion trait. - `scan_boot_image_sanity` used to declare an immutable array and let unsafe `jtoc_call!` code modify it. The array is now defined as mutable. Related issues and PRs: - This PR is the 1st step of #178 - It will ultimately allow mmtk/mmtk-core#1170 to be implemented.
- Loading branch information