From d14bcf20b79850ac12138c5b258c6f530c02edcc Mon Sep 17 00:00:00 2001 From: Tianle Qiu Date: Tue, 2 May 2023 16:14:16 +1000 Subject: [PATCH 1/3] remove redundant code & add comment --- src/policy/largeobjectspace.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/policy/largeobjectspace.rs b/src/policy/largeobjectspace.rs index ea4ea66b1d..a6c01d9919 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 @@ -262,6 +262,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, From 2e15bd66c3640aa3a21dfd14b35f1b5c4c5b5b45 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Tue, 2 May 2023 06:43:47 +0000 Subject: [PATCH 2/3] Remove unused clear_nursery --- src/policy/largeobjectspace.rs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/policy/largeobjectspace.rs b/src/policy/largeobjectspace.rs index a6c01d9919..00afef6e21 100644 --- a/src/policy/largeobjectspace.rs +++ b/src/policy/largeobjectspace.rs @@ -298,31 +298,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 { From 464076daa3606a573e7be4a847490fc1e0ce8b11 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Tue, 2 May 2023 20:11:18 +1200 Subject: [PATCH 3/3] Add comments for test_and_mark --- src/policy/largeobjectspace.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/policy/largeobjectspace.rs b/src/policy/largeobjectspace.rs index 00afef6e21..745f6b3db3 100644 --- a/src/policy/largeobjectspace.rs +++ b/src/policy/largeobjectspace.rs @@ -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 {