Clean up Line/ObjectReference/Address conversions in RefCountHelper - #1558
Conversation
Line/ObjectReference/Address conversions in RefCountHelper
|
|
||
| /// Return the line that contains the raw address of the object reference. | ||
| pub fn containing_obj_ref(object: ObjectReference) -> Self { | ||
| Self(object.to_raw_address()) |
There was a problem hiding this comment.
This creates an invalid Line (unaligned address). All the call sites of this method are now switched to object_is_in_straddle_line_no_rc_check
There was a problem hiding this comment.
We can remove the unused containing_obj_start method above this one, too.
|
This tracks the correctness of this PR for LXR: mmtk/mmtk-openjdk#378 |
wks
left a comment
There was a problem hiding this comment.
This PR is good enough for cleaning up and removing Address::to_object_reference. But the predicate object_is_in_straddle_line may not make sense if the object_start != raw address because the start may be in one line and the raw address may be in another line. But that will require algorithm change, and we can do it later.
One change should be made in this PR. Because we removed Line::containing_obj_ref, we should remove Line::containing_obj_start, too for consistency. containing_obj_start is unused anyway.
| if c != 0 { | ||
| // Safety: cur_cursor is either a valid object reference, or a straddle line | ||
| let o = unsafe { ObjectReference::from_raw_address_unchecked(cur_cursor) }; | ||
| if !immix_space.is_marked(o) { |
There was a problem hiding this comment.
At this line, we have not checked whether o is a valid ObjectReference, yet. It actually checks the mark bit at the the raw address of o. This is only possible if the mark bit is on the side, which the ImmixSpace seems to require for now, but not formally specified.
We can eliminate this by introducing ImmixSpace::is_address_marked(addr) which only works if the mark bit is on the side. But I think it is OK for now. We can fix it in the future when we reach a consensus about whether mark bits must be on the side for Immix, whether LXR requires side mark bits, and whether we can implement this method better without this check.
There was a problem hiding this comment.
Yeah. It is unsound to check immix_space.is_marked(o) here -- we don't even know if o is an object. But this is the same code as the original LXR PR. I don't intend to address that issue in this PR.
|
I saw this error with this PR in the binding CI: https://github.com/mmtk/mmtk-openjdk/actions/runs/32333739772/job/96323577549?pr=378 I haven't seen this error before. So there is a chance that this PR introduced the issue. But I checked the PR a few times, I don't see how this PR changed any LXR's behavior. And I couldn't reproduce the bug locally. @wks Can you double check this PR and see you find any issue? |
|
@qinsoon I ran |
Thank you. I will open a bug report for the issue then. |
This PR cleans up the conversions between
Line/ObjectReference/AddressinRefCountHelper. It does not address the confusion in LXR between object start and object ref.