Skip to content

Commit 017a060

Browse files
committed
Refactor log bits
1 parent 83dc4c4 commit 017a060

File tree

17 files changed

+157
-47
lines changed

17 files changed

+157
-47
lines changed

src/plan/generational/copying/global.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ impl<VM: VMBinding> Plan for GenCopy<VM> {
110110
let full_heap = !self.gen.is_current_gc_nursery();
111111
self.gen.release(tls);
112112
if full_heap {
113+
if VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC.is_on_side() {
114+
self.fromspace().clear_side_log_bits();
115+
}
113116
self.fromspace().release();
114117
}
115118
}

src/plan/generational/global.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ impl<VM: VMBinding> CommonGenPlan<VM> {
7474
/// Release Gen. This should be called by a single thread in GC release work.
7575
pub fn release(&mut self, tls: VMWorkerThread) {
7676
let full_heap = !self.is_current_gc_nursery();
77+
if VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC.is_on_side() {
78+
self.nursery.clear_side_log_bits();
79+
}
7780
self.common.release(tls, full_heap);
7881
self.nursery.release();
7982
}

src/plan/generational/immix/global.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ impl<VM: VMBinding> Plan for GenImmix<VM> {
129129
let full_heap = !self.gen.is_current_gc_nursery();
130130
self.gen.prepare(tls);
131131
if full_heap {
132+
if VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC.is_on_side() {
133+
self.immix_space.clear_side_log_bits();
134+
}
132135
self.immix_space.prepare(
133136
full_heap,
134137
Some(crate::policy::immix::defrag::StatsForDefrag::new(self)),
@@ -249,8 +252,6 @@ impl<VM: VMBinding> GenImmix<VM> {
249252
let immix_space = ImmixSpace::new(
250253
plan_args.get_space_args("immix_mature", true, false, VMRequest::discontiguous()),
251254
ImmixSpaceArgs {
252-
// We need to unlog objects at tracing time since we currently clear all log bits during a major GC
253-
unlog_object_when_traced: true,
254255
// In GenImmix, young objects are not allocated in ImmixSpace directly.
255256
#[cfg(feature = "vo_bit")]
256257
mixed_age: false,

src/plan/generational/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub const FULL_NURSERY_GC: bool = false;
4545
pub const GEN_CONSTRAINTS: PlanConstraints = PlanConstraints {
4646
moves_objects: true,
4747
needs_log_bit: ACTIVE_BARRIER.equals(BarrierSelector::ObjectBarrier),
48+
unlog_allocated_object: true,
49+
unlog_traced_object: true,
4850
barrier: ACTIVE_BARRIER,
4951
// We may trace duplicate edges in sticky immix (or any plan that uses object remembering barrier). See https://github.com/mmtk/mmtk-core/issues/743.
5052
may_trace_duplicate_edges: ACTIVE_BARRIER.equals(BarrierSelector::ObjectBarrier),

src/plan/global.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ impl<VM: VMBinding> CreateSpecificPlanArgs<'_, VM> {
416416
zeroed,
417417
permission_exec,
418418
vmrequest,
419+
unlog_allocated_object: self.constraints.unlog_allocated_object,
420+
unlog_traced_object: self.constraints.unlog_traced_object,
419421
global_side_metadata_specs: self.global_side_metadata_specs.clone(),
420422
vm_map: self.global_args.vm_map,
421423
mmapper: self.global_args.mmapper,
@@ -517,6 +519,28 @@ impl<VM: VMBinding> BasePlan<VM> {
517519
self.vm_space.release();
518520
}
519521

522+
pub fn clear_side_log_bits(&self) {
523+
#[cfg(feature = "code_space")]
524+
self.code_space.clear_side_log_bits();
525+
#[cfg(feature = "code_space")]
526+
self.code_lo_space.clear_side_log_bits();
527+
#[cfg(feature = "ro_space")]
528+
self.ro_space.clear_side_log_bits();
529+
#[cfg(feature = "vm_space")]
530+
self.vm_space.clear_side_log_bits();
531+
}
532+
533+
pub fn set_side_log_bits(&self) {
534+
#[cfg(feature = "code_space")]
535+
self.code_space.set_side_log_bits();
536+
#[cfg(feature = "code_space")]
537+
self.code_lo_space.set_side_log_bits();
538+
#[cfg(feature = "ro_space")]
539+
self.ro_space.set_side_log_bits();
540+
#[cfg(feature = "vm_space")]
541+
self.vm_space.set_side_log_bits();
542+
}
543+
520544
pub fn end_of_gc(&mut self, _tls: VMWorkerThread) {
521545
// Do nothing here. None of the spaces needs end_of_gc.
522546
}
@@ -584,6 +608,7 @@ pub struct CommonPlan<VM: VMBinding> {
584608

585609
impl<VM: VMBinding> CommonPlan<VM> {
586610
pub fn new(mut args: CreateSpecificPlanArgs<VM>) -> CommonPlan<VM> {
611+
let needs_log_bit = args.constraints.needs_log_bit;
587612
CommonPlan {
588613
immortal: ImmortalSpace::new(args.get_space_args(
589614
"immortal",
@@ -594,6 +619,7 @@ impl<VM: VMBinding> CommonPlan<VM> {
594619
los: LargeObjectSpace::new(
595620
args.get_space_args("los", true, false, VMRequest::discontiguous()),
596621
false,
622+
needs_log_bit,
597623
),
598624
nonmoving: Self::new_nonmoving_space(&mut args),
599625
base: BasePlan::new(args),
@@ -621,6 +647,18 @@ impl<VM: VMBinding> CommonPlan<VM> {
621647
self.base.release(tls, full_heap)
622648
}
623649

650+
pub fn clear_side_log_bits(&self) {
651+
self.immortal.clear_side_log_bits();
652+
self.los.clear_side_log_bits();
653+
self.base.clear_side_log_bits();
654+
}
655+
656+
pub fn set_side_log_bits(&self) {
657+
self.immortal.set_side_log_bits();
658+
self.los.set_side_log_bits();
659+
self.base.set_side_log_bits();
660+
}
661+
624662
pub fn end_of_gc(&mut self, tls: VMWorkerThread) {
625663
self.end_of_gc_nonmoving_space();
626664
self.base.end_of_gc(tls);
@@ -648,7 +686,6 @@ impl<VM: VMBinding> CommonPlan<VM> {
648686
NonMovingSpace::new(
649687
space_args,
650688
crate::policy::immix::ImmixSpaceArgs {
651-
unlog_object_when_traced: false,
652689
#[cfg(feature = "vo_bit")]
653690
mixed_age: false,
654691
never_move_objects: true,

src/plan/immix/global.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ impl<VM: VMBinding> Immix<VM> {
138138
Self::new_with_args(
139139
plan_args,
140140
ImmixSpaceArgs {
141-
unlog_object_when_traced: false,
142141
#[cfg(feature = "vo_bit")]
143142
mixed_age: false,
144143
never_move_objects: false,

src/plan/pageprotect/global.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl<VM: VMBinding> PageProtect<VM> {
110110
space: LargeObjectSpace::new(
111111
plan_args.get_space_args("pageprotect", true, false, VMRequest::discontiguous()),
112112
true,
113+
false, // PageProtect does not use log bit
113114
),
114115
common: CommonPlan::new(plan_args),
115116
};

src/plan/plan_constraints.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ pub struct PlanConstraints {
4545
/// `MutatorConfig::prepare_func`). Those plans can set this to `false` so that the
4646
/// `PrepareMutator` work packets will not be created at all.
4747
pub needs_prepare_mutator: bool,
48+
/// Should a policy unlog newly allocated objects?
49+
pub unlog_allocated_object: bool,
50+
/// Should a policy unlog traced objects?
51+
pub unlog_traced_object: bool,
4852
}
4953

5054
impl PlanConstraints {
@@ -67,6 +71,8 @@ impl PlanConstraints {
6771
barrier: BarrierSelector::NoBarrier,
6872
// If we use mark sweep as non moving space, we need to prepare mutator. See [`common_prepare_func`].
6973
needs_prepare_mutator: cfg!(feature = "marksweep_as_nonmoving"),
74+
unlog_allocated_object: false,
75+
unlog_traced_object: false,
7076
}
7177
}
7278
}

src/plan/sticky/immix/global.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub const STICKY_IMMIX_CONSTRAINTS: PlanConstraints = PlanConstraints {
4646
barrier: crate::plan::BarrierSelector::ObjectBarrier,
4747
// We may trace duplicate edges in sticky immix (or any plan that uses object remembering barrier). See https://github.com/mmtk/mmtk-core/issues/743.
4848
may_trace_duplicate_edges: true,
49+
unlog_allocated_object: true,
50+
unlog_traced_object: true,
4951
..immix::IMMIX_CONSTRAINTS
5052
};
5153

@@ -122,6 +124,10 @@ impl<VM: VMBinding> Plan for StickyImmix<VM> {
122124
self.immix.common.los.prepare(false);
123125
} else {
124126
self.full_heap_gc_count.lock().unwrap().inc();
127+
if VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC.is_on_side() {
128+
self.immix.common.clear_side_log_bits();
129+
self.immix.immix_space.clear_side_log_bits();
130+
}
125131
self.immix.prepare(tls);
126132
}
127133
}
@@ -325,10 +331,6 @@ impl<VM: VMBinding> StickyImmix<VM> {
325331
let immix = immix::Immix::new_with_args(
326332
plan_args,
327333
crate::policy::immix::ImmixSpaceArgs {
328-
// Every object we trace in nursery GC becomes a mature object.
329-
// Every object we trace in full heap GC is a mature object. Thus in both cases,
330-
// they should be unlogged.
331-
unlog_object_when_traced: true,
332334
// In StickyImmix, both young and old objects are allocated in the ImmixSpace.
333335
#[cfg(feature = "vo_bit")]
334336
mixed_age: true,

src/policy/copyspace.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ impl<VM: VMBinding> CopySpace<VM> {
201201
side_forwarding_status_table.bzero_metadata(start, size);
202202
}
203203

204-
if self.common.needs_log_bit {
205-
if let MetadataSpec::OnSide(side) = *VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC {
206-
side.bzero_metadata(start, size);
207-
}
208-
}
209-
210204
// Clear VO bits because all objects in the space are dead.
211205
#[cfg(feature = "vo_bit")]
212206
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
@@ -218,6 +212,20 @@ impl<VM: VMBinding> CopySpace<VM> {
218212
self.from_space.store(false, Ordering::SeqCst);
219213
}
220214

215+
pub fn clear_side_log_bits(&self) {
216+
let log_bit = VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC.extract_side_spec();
217+
for (start, size) in self.pr.iterate_allocated_regions() {
218+
log_bit.bzero_metadata(start, size);
219+
}
220+
}
221+
222+
pub fn set_side_log_bits(&self) {
223+
let log_bit = VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC.extract_side_spec();
224+
for (start, size) in self.pr.iterate_allocated_regions() {
225+
log_bit.bset_metadata(start, size);
226+
}
227+
}
228+
221229
fn is_from_space(&self) -> bool {
222230
self.from_space.load(Ordering::SeqCst)
223231
}

0 commit comments

Comments
 (0)