Skip to content
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

Remove redundant clear_nursery() #799

Merged
merged 3 commits into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions src/policy/largeobjectspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ impl<VM: VMBinding> LargeObjectSpace<VM> {
if nursery_object { "is" } else { "is not" }
);
if !self.in_nursery_gc || nursery_object {
// Note that test_and_mark() has side effects
// Note that test_and_mark() has side effects of
// clearing nursery bit/moving objects out of logical nursery
if self.test_and_mark(object, self.mark_state) {
trace!("LOS object {} is being marked now", object);
self.treadmill.copy(object, nursery_object);
self.clear_nursery(object);
// We just moved the object out of the logical nursery, mark it as unlogged.
if nursery_object && self.common.needs_log_bit {
VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC
Expand Down Expand Up @@ -246,6 +246,10 @@ impl<VM: VMBinding> LargeObjectSpace<VM> {
self.acquire(tls, pages)
}

/// Test if the object's mark bit is the same as the given value. If it is not the same,
/// the method will attemp to mark the object and clear its nursery bit. If the attempt
/// succeeds, the method will return true, meaning the object is marked by this invocation.
/// Otherwise, it returns false.
fn test_and_mark(&self, object: ObjectReference, value: u8) -> bool {
loop {
let mask = if self.in_nursery_gc {
Expand All @@ -262,6 +266,7 @@ impl<VM: VMBinding> LargeObjectSpace<VM> {
if mark_bit == value {
return false;
}
// using LOS_BIT_MASK have side effects of clearing nursery bit
if VM::VMObjectModel::LOCAL_LOS_MARK_NURSERY_SPEC
.compare_exchange_metadata::<VM, u8>(
object,
Expand Down Expand Up @@ -297,31 +302,6 @@ impl<VM: VMBinding> LargeObjectSpace<VM> {
) & NURSERY_BIT
== NURSERY_BIT
}

/// Move a given object out of nursery
fn clear_nursery(&self, object: ObjectReference) {
loop {
let old_val = VM::VMObjectModel::LOCAL_LOS_MARK_NURSERY_SPEC.load_atomic::<VM, u8>(
object,
None,
Ordering::Relaxed,
);
let new_val = old_val & !NURSERY_BIT;
if VM::VMObjectModel::LOCAL_LOS_MARK_NURSERY_SPEC
.compare_exchange_metadata::<VM, u8>(
object,
old_val,
new_val,
None,
Ordering::SeqCst,
Ordering::SeqCst,
)
.is_ok()
{
break;
}
}
}
}

fn get_super_page(cell: Address) -> Address {
Expand Down