diff --git a/src/policy/largeobjectspace.rs b/src/policy/largeobjectspace.rs index ea4ea66b1d..745f6b3db3 100644 --- a/src/policy/largeobjectspace.rs +++ b/src/policy/largeobjectspace.rs @@ -202,11 +202,11 @@ impl LargeObjectSpace { 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 @@ -246,6 +246,10 @@ impl LargeObjectSpace { 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 { @@ -262,6 +266,7 @@ impl LargeObjectSpace { 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::( object, @@ -297,31 +302,6 @@ impl LargeObjectSpace { ) & 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::( - object, - None, - Ordering::Relaxed, - ); - let new_val = old_val & !NURSERY_BIT; - if VM::VMObjectModel::LOCAL_LOS_MARK_NURSERY_SPEC - .compare_exchange_metadata::( - object, - old_val, - new_val, - None, - Ordering::SeqCst, - Ordering::SeqCst, - ) - .is_ok() - { - break; - } - } - } } fn get_super_page(cell: Address) -> Address {