Skip to content

Commit 42991c2

Browse files
authored
Make MarkCompact LOS support 2nd transitive closure (#944)
#939 makes MarkCompact GC allocate large objects into LOS, instead of mark-compacting everything. However, LOS should be released and re-prepared properly, otherwise marking in the pointer forwarding trace will not behave correctly. This should fix the OpenJDK binding test failures.
1 parent 40777ed commit 42991c2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/plan/markcompact/gc_work.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,21 @@ impl<VM: VMBinding> CalculateForwardingAddress<VM> {
3232
/// create another round of root scanning work packets
3333
/// to update object references
3434
pub struct UpdateReferences<VM: VMBinding> {
35+
plan: *const MarkCompact<VM>,
3536
p: PhantomData<VM>,
3637
}
3738

39+
unsafe impl<VM: VMBinding> Send for UpdateReferences<VM> {}
40+
3841
impl<VM: VMBinding> GCWork<VM> for UpdateReferences<VM> {
39-
fn do_work(&mut self, _worker: &mut GCWorker<VM>, mmtk: &'static MMTK<VM>) {
42+
fn do_work(&mut self, worker: &mut GCWorker<VM>, mmtk: &'static MMTK<VM>) {
4043
// The following needs to be done right before the second round of root scanning
4144
VM::VMScanning::prepare_for_roots_re_scanning();
4245
mmtk.get_plan().base().prepare_for_stack_scanning();
46+
// Prepare common and base spaces for the 2nd round of transitive closure
47+
let plan_mut = unsafe { &mut *(self.plan as *mut MarkCompact<VM>) };
48+
plan_mut.common.release(worker.tls, true);
49+
plan_mut.common.prepare(worker.tls, true);
4350
#[cfg(feature = "extreme_assertions")]
4451
mmtk.edge_logger.reset();
4552

@@ -60,8 +67,11 @@ impl<VM: VMBinding> GCWork<VM> for UpdateReferences<VM> {
6067
}
6168

6269
impl<VM: VMBinding> UpdateReferences<VM> {
63-
pub fn new() -> Self {
64-
Self { p: PhantomData }
70+
pub fn new(plan: &MarkCompact<VM>) -> Self {
71+
Self {
72+
plan,
73+
p: PhantomData,
74+
}
6575
}
6676
}
6777

src/plan/markcompact/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<VM: VMBinding> Plan for MarkCompact<VM> {
101101
scheduler.work_buckets[WorkBucketStage::CalculateForwarding]
102102
.add(CalculateForwardingAddress::<VM>::new(&self.mc_space));
103103
// do another trace to update references
104-
scheduler.work_buckets[WorkBucketStage::SecondRoots].add(UpdateReferences::<VM>::new());
104+
scheduler.work_buckets[WorkBucketStage::SecondRoots].add(UpdateReferences::<VM>::new(self));
105105
scheduler.work_buckets[WorkBucketStage::Compact].add(Compact::<VM>::new(&self.mc_space));
106106

107107
// Release global/collectors/mutators

0 commit comments

Comments
 (0)