diff --git a/src/plan/barriers.rs b/src/plan/barriers.rs index 39932fda93..13d15853d6 100644 --- a/src/plan/barriers.rs +++ b/src/plan/barriers.rs @@ -231,6 +231,11 @@ impl Barrier for ObjectBarrier { target: Option, ) { if self.log_object(src) { + debug_assert!( + src.is_live(), + "{} was logged but is not live", + src + ); self.semantics .object_reference_write_slow(src, slot, target); } diff --git a/src/plan/generational/gc_work.rs b/src/plan/generational/gc_work.rs index 03240b4e93..f70ea0665f 100644 --- a/src/plan/generational/gc_work.rs +++ b/src/plan/generational/gc_work.rs @@ -108,22 +108,28 @@ impl ProcessModBuf { impl GCWork for ProcessModBuf { fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { - // Flip the per-object unlogged bits to "unlogged" state. - for obj in &self.modbuf { - ::VMObjectModel::GLOBAL_LOG_BIT_SPEC.store_atomic::( - *obj, - 1, - None, - Ordering::SeqCst, - ); - } - // scan modbuf only if the current GC is a nursery GC + // Process and scan modbuf only if the current GC is a nursery GC if mmtk .get_plan() .generational() .unwrap() .is_current_gc_nursery() { + // Flip the per-object unlogged bits to "unlogged" state. + for obj in &self.modbuf { + debug_assert!( + (*obj).is_live(), + "{} was logged but is not live", + *obj + ); + + ::VMObjectModel::GLOBAL_LOG_BIT_SPEC.store_atomic::( + *obj, + 1, + None, + Ordering::SeqCst, + ); + } // Scan objects in the modbuf and forward pointers let modbuf = std::mem::take(&mut self.modbuf); GCWork::do_work( @@ -131,6 +137,24 @@ impl GCWork for ProcessModBuf { worker, mmtk, ) + } else { + // Flip the per-object unlogged bits to "unlogged" state for objects inside the bootimage + #[cfg(feature = "vm_space")] + { + use crate::policy::space::Space; + + for obj in &self.modbuf { + if mmtk.get_plan().base().vm_space.in_space(*obj) { + ::VMObjectModel::GLOBAL_LOG_BIT_SPEC.store_atomic::( + *obj, + 1, + None, + Ordering::SeqCst, + ); + } + } + + } } } }