Skip to content

Commit

Permalink
Make MarkCompact LOS support 2nd transitive closure (#944)
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
wenyuzhao authored Sep 6, 2023
1 parent 40777ed commit 42991c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/plan/markcompact/gc_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ impl<VM: VMBinding> CalculateForwardingAddress<VM> {
/// create another round of root scanning work packets
/// to update object references
pub struct UpdateReferences<VM: VMBinding> {
plan: *const MarkCompact<VM>,
p: PhantomData<VM>,
}

unsafe impl<VM: VMBinding> Send for UpdateReferences<VM> {}

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

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

impl<VM: VMBinding> UpdateReferences<VM> {
pub fn new() -> Self {
Self { p: PhantomData }
pub fn new(plan: &MarkCompact<VM>) -> Self {
Self {
plan,
p: PhantomData,
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plan/markcompact/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<VM: VMBinding> Plan for MarkCompact<VM> {
scheduler.work_buckets[WorkBucketStage::CalculateForwarding]
.add(CalculateForwardingAddress::<VM>::new(&self.mc_space));
// do another trace to update references
scheduler.work_buckets[WorkBucketStage::SecondRoots].add(UpdateReferences::<VM>::new());
scheduler.work_buckets[WorkBucketStage::SecondRoots].add(UpdateReferences::<VM>::new(self));
scheduler.work_buckets[WorkBucketStage::Compact].add(Compact::<VM>::new(&self.mc_space));

// Release global/collectors/mutators
Expand Down

0 comments on commit 42991c2

Please sign in to comment.