-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce JikesRVM-specific object accessor types #177
Conversation
Change variable names for CopySemantics to `semantics` Not use the variable name `region` for the result of `alloc` because it is not a region (power-of-two sized/aligned range). Annotate unused functions.
This ensures we don't accidentally leak MMTk-level ObjectReference values to JikesRVM.
Add logs to methods of `ObjectModel<VM>` so that we know which callbacks mmtk-core calls in a given configuration. Remove other logs.
This will ensure we don't accidentally use the weakly-typed macros in other modules except `jikesrvm_calls` itself.
The other PR #179 demonstrates that we can modify MMTk-level ObjectReference to point to JavaHeader and it works. I have marked this PR as ready for reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We should run benchmarks, or keep an eye on the perf CI. The frequent cast between JikesObj
and ObjectReference
with unwrap()
may have overheads.
mmtk/src/api.rs
Outdated
bytes: usize, | ||
allocator: AllocationSemantics, | ||
) { | ||
memory_manager::post_alloc::<JikesRVM>(unsafe { &mut *mutator }, refer, bytes, allocator) | ||
debug_assert!(!refer.is_null()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null check seems unnecessary. There is always try_into/from
afterwards, which will fail if you have a null reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed all debug_assert!(!jikes_obj.is_null());
from API functions if the JikesObj
parameter is converted to ObjectReference
using try_from
or try_into
.
`ObjectReference::try_from(jikes_obj)` already performs null check, so we don't need an additional debug_assert for that.
I can't use moma machines for now. I ran lusearch in DaCapo 2006 locally, with RFastAdaptiveSemiSpace, and see no obvious performance difference. |
This PR changes the definition of MMTk-level `ObjectReference` for the JikesRVM binding so that it now points to the JavaHeader, and is different from the JikesRVM-level `ObjectReference` (a.k.a. `JikesObj`). This will guarantee that the MMTk-level ObjectReference is always inside an object. Note that this PR does not involve a change in mmtk-core. It changes `ObjectModel::IN_OBJECT_ADDRESS_OFFSET` to 0 so that the "in-object address" is identical to the raw address of `ObjectReference`. It demonstrates the JikesRVM binding can work well with MMTk-level `ObjectReference` being different from JikesRVM-level `ObjectReference`. Related issues and PRs. - This PR is based on #177 - This PR is the 2nd step of #178 - It will ultimately allow mmtk/mmtk-core#1170 to be implemented.
The main purpose of this PR is make a clear distinction between the
ObjectReference
type in JikesRVM and theObjectReference
type in mmtk-core.This PR introduced
JikesObj
, a Rust type that represents the JikesRVM-levelObjectReference
. It needs an explicit conversion to convert to/from the MMTk-levelObjectReference
types.The interface between mmtk-core and the mmtk-jikesrvm binding is refactored to do fewer things with the MMTk-level
ObjectReference
.ObjectReference
to the binding, notably the methods inObjectModel
, now simply convert the MMTk-levelObjectReference
toJikesObj
, and then call methods ofJikesObj
.JikesObj
(and other wrapper types includingTIB
andRVMType
).JikesRVMSlot
trait now does the conversion betweenJikesObj
and the MMTk-levelObjectReference
when loading or storing a slot.This allows us to change the definition of the MMTk-level
ObjectReference
in the future, while concrete methods ofJikesObj
still use offset constants relative to the JikesRVM-levelObjectReference
which will not change.The interface between the Rust part and the Java part of the binding are refactored to involve
JikesObj
only.api.rs
acceptJikesObj
parameters from JikesRVM and returnJikeObj
to JikesRVM where JikesRVM uses the JikesRVM-levelObjectReference
.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-levelObjectReference
as an MMTk-levelObjectReference
.We also do some obvious refactoring that makes the code more readable.:
(addr + XXXX_OFFSET)::load<T>()
into dedicated methods.JikesObj::hashcode_overhead
and simplified many methods that depend on that.RustScanThread.java
.And obvious bug fixes:
DO_REFERENCE_PROCESSING_HELPER_SCAN_METHOD_OFFSET
used to erroneously interpret 0 astrue
. This has been fixed by relying on the conversion trait.scan_boot_image_sanity
used to declare an immutable array and let unsafejtoc_call!
code modify it. The array is now defined as mutable.Related issues and PRs: