Skip to content

Commit 6149721

Browse files
committed
Remove unlog_allocated/traced_object from PlanConstraints. Move them to
args for creating spaces.
1 parent 9c7695c commit 6149721

File tree

18 files changed

+173
-63
lines changed

18 files changed

+173
-63
lines changed

src/plan/compressor/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<VM: VMBinding> Compressor<VM> {
183183
};
184184

185185
let res = Compressor {
186-
compressor_space: CompressorSpace::new(plan_args.get_space_args(
186+
compressor_space: CompressorSpace::new(plan_args.get_normal_space_args(
187187
"compressor_space",
188188
true,
189189
false,

src/plan/generational/copying/global.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ impl<VM: VMBinding> GenCopy<VM> {
212212
};
213213

214214
let copyspace0 = CopySpace::new(
215-
plan_args.get_space_args("copyspace0", true, false, VMRequest::discontiguous()),
215+
plan_args.get_mature_space_args("copyspace0", true, false, VMRequest::discontiguous()),
216216
false,
217217
);
218218
let copyspace1 = CopySpace::new(
219-
plan_args.get_space_args("copyspace1", true, false, VMRequest::discontiguous()),
219+
plan_args.get_mature_space_args("copyspace1", true, false, VMRequest::discontiguous()),
220220
true,
221221
);
222222

src/plan/generational/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct CommonGenPlan<VM: VMBinding> {
4141
impl<VM: VMBinding> CommonGenPlan<VM> {
4242
pub fn new(mut args: CreateSpecificPlanArgs<VM>) -> Self {
4343
let nursery = CopySpace::new(
44-
args.get_space_args("nursery", true, false, VMRequest::discontiguous()),
44+
args.get_nursery_space_args("nursery", true, false, VMRequest::discontiguous()),
4545
true,
4646
);
4747
let full_heap_gc_count = args

src/plan/generational/immix/global.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,14 @@ impl<VM: VMBinding> GenImmix<VM> {
250250
crate::plan::generational::new_generational_global_metadata_specs::<VM>(),
251251
};
252252
let immix_space = ImmixSpace::new(
253-
plan_args.get_space_args("immix_mature", true, false, VMRequest::discontiguous()),
253+
plan_args.get_mature_space_args(
254+
"immix_mature",
255+
true,
256+
false,
257+
VMRequest::discontiguous(),
258+
),
254259
ImmixSpaceArgs {
255260
// In GenImmix, young objects are not allocated in ImmixSpace directly.
256-
#[cfg(feature = "vo_bit")]
257261
mixed_age: false,
258262
never_move_objects: false,
259263
},

src/plan/generational/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ 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,
48+
generational: true,
5049
barrier: ACTIVE_BARRIER,
5150
// 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.
5251
may_trace_duplicate_edges: ACTIVE_BARRIER.equals(BarrierSelector::ObjectBarrier),

src/plan/global.rs

Lines changed: 108 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -404,20 +404,22 @@ pub struct CreateSpecificPlanArgs<'a, VM: VMBinding> {
404404

405405
impl<VM: VMBinding> CreateSpecificPlanArgs<'_, VM> {
406406
/// Get a PlanCreateSpaceArgs that can be used to create a space
407-
pub fn get_space_args(
407+
pub fn _get_space_args(
408408
&mut self,
409409
name: &'static str,
410410
zeroed: bool,
411411
permission_exec: bool,
412+
unlog_allocated_object: bool,
413+
unlog_traced_object: bool,
412414
vmrequest: VMRequest,
413415
) -> PlanCreateSpaceArgs<VM> {
414416
PlanCreateSpaceArgs {
415417
name,
416418
zeroed,
417419
permission_exec,
418420
vmrequest,
419-
unlog_allocated_object: self.constraints.unlog_allocated_object,
420-
unlog_traced_object: self.constraints.unlog_traced_object,
421+
unlog_allocated_object,
422+
unlog_traced_object,
421423
global_side_metadata_specs: self.global_side_metadata_specs.clone(),
422424
vm_map: self.global_args.vm_map,
423425
mmapper: self.global_args.mmapper,
@@ -429,39 +431,121 @@ impl<VM: VMBinding> CreateSpecificPlanArgs<'_, VM> {
429431
global_state: self.global_args.state.clone(),
430432
}
431433
}
434+
435+
// The following are some convenience methods for common presets.
436+
// These are not an exhaustive list -- it is just common presets that are used by most plans.
437+
438+
/// Get a preset for a nursery space (where young objects are located).
439+
pub fn get_nursery_space_args(
440+
&mut self,
441+
name: &'static str,
442+
zeroed: bool,
443+
permission_exec: bool,
444+
vmrequest: VMRequest,
445+
) -> PlanCreateSpaceArgs<VM> {
446+
// Objects are allocatd as young, and when traced, they stay young. If they are copied out of the nursery space, they will be moved to a mature space,
447+
// and log bits will be set in that case by the mature space.
448+
self._get_space_args(name, zeroed, permission_exec, false, false, vmrequest)
449+
}
450+
451+
/// Get a preset for a mature space (where mature objects are located).
452+
pub fn get_mature_space_args(
453+
&mut self,
454+
name: &'static str,
455+
zeroed: bool,
456+
permission_exec: bool,
457+
vmrequest: VMRequest,
458+
) -> PlanCreateSpaceArgs<VM> {
459+
// Objects are allocated as mature (pre-tenured), and when traced, they stay mature.
460+
// If an object gets copied into a mature space, the object is also mature,
461+
self._get_space_args(name, zeroed, permission_exec, true, true, vmrequest)
462+
}
463+
464+
// Get a preset for a mixed age space (where both young and mature objects are located).
465+
pub fn get_mixed_age_space_args(
466+
&mut self,
467+
name: &'static str,
468+
zeroed: bool,
469+
permission_exec: bool,
470+
vmrequest: VMRequest,
471+
) -> PlanCreateSpaceArgs<VM> {
472+
// Objects are allocated as young, and when traced, they become mature objects.
473+
self._get_space_args(name, zeroed, permission_exec, false, true, vmrequest)
474+
}
475+
476+
/// Get a preset for spaces in a non-generational plan.
477+
pub fn get_normal_space_args(
478+
&mut self,
479+
name: &'static str,
480+
zeroed: bool,
481+
permission_exec: bool,
482+
vmrequest: VMRequest,
483+
) -> PlanCreateSpaceArgs<VM> {
484+
// Non generational plan: we do not use any of the flags about log bits.
485+
self._get_space_args(name, zeroed, permission_exec, false, false, vmrequest)
486+
}
487+
488+
/// Get a preset for spaces in [`crate::plan::global::CommonPlan`].
489+
/// Spaces like LOS which may include both young and mature objects should not use this method.
490+
pub fn get_common_space_args(
491+
&mut self,
492+
generational: bool,
493+
name: &'static str,
494+
) -> PlanCreateSpaceArgs<VM> {
495+
self.get_base_space_args(
496+
generational,
497+
name,
498+
false, // Common spaces are not executable.
499+
)
500+
}
501+
502+
/// Get a preset for spaces in [`crate::plan::global::BasePlan`].
503+
pub fn get_base_space_args(
504+
&mut self,
505+
generational: bool,
506+
name: &'static str,
507+
permission_exec: bool,
508+
) -> PlanCreateSpaceArgs<VM> {
509+
if generational {
510+
// In generational plans, common/base spaces behave like a mature space:
511+
// * the objects in these spaces are not traced in a nursery GC
512+
// * the log bits for the objects are maintained exactly the same as a mature space.
513+
// Thus we consider them as mature spaces.
514+
self.get_mature_space_args(name, true, permission_exec, VMRequest::discontiguous())
515+
} else {
516+
self.get_normal_space_args(name, true, permission_exec, VMRequest::discontiguous())
517+
}
518+
}
432519
}
433520

434521
impl<VM: VMBinding> BasePlan<VM> {
435522
#[allow(unused_mut)] // 'args' only needs to be mutable for certain features
436523
pub fn new(mut args: CreateSpecificPlanArgs<VM>) -> BasePlan<VM> {
524+
let _generational = args.constraints.generational;
437525
BasePlan {
438526
#[cfg(feature = "code_space")]
439-
code_space: ImmortalSpace::new(args.get_space_args(
527+
code_space: ImmortalSpace::new(args.get_base_space_args(
528+
_generational,
440529
"code_space",
441530
true,
442-
true,
443-
VMRequest::discontiguous(),
444531
)),
445532
#[cfg(feature = "code_space")]
446-
code_lo_space: ImmortalSpace::new(args.get_space_args(
533+
code_lo_space: ImmortalSpace::new(args.get_base_space_args(
534+
_generational,
447535
"code_lo_space",
448536
true,
449-
true,
450-
VMRequest::discontiguous(),
451537
)),
452538
#[cfg(feature = "ro_space")]
453-
ro_space: ImmortalSpace::new(args.get_space_args(
539+
ro_space: ImmortalSpace::new(args.get_base_space_args(
540+
_generational,
454541
"ro_space",
455-
true,
456542
false,
457-
VMRequest::discontiguous(),
458543
)),
459544
#[cfg(feature = "vm_space")]
460-
vm_space: VMSpace::new(args.get_space_args(
545+
vm_space: VMSpace::new(args.get_base_space_args(
546+
_generational,
461547
"vm_space",
462-
false,
463548
false, // it doesn't matter -- we are not mmapping for VM space.
464-
VMRequest::discontiguous(),
465549
)),
466550

467551
global_state: args.global_args.state.clone(),
@@ -609,15 +693,16 @@ pub struct CommonPlan<VM: VMBinding> {
609693
impl<VM: VMBinding> CommonPlan<VM> {
610694
pub fn new(mut args: CreateSpecificPlanArgs<VM>) -> CommonPlan<VM> {
611695
let needs_log_bit = args.constraints.needs_log_bit;
696+
let generational = args.constraints.generational;
612697
CommonPlan {
613-
immortal: ImmortalSpace::new(args.get_space_args(
614-
"immortal",
615-
true,
616-
false,
617-
VMRequest::discontiguous(),
618-
)),
698+
immortal: ImmortalSpace::new(args.get_common_space_args(generational, "immortal")),
619699
los: LargeObjectSpace::new(
620-
args.get_space_args("los", true, false, VMRequest::discontiguous()),
700+
// LOS is a bit special, as it is a mixed age space. It has a logical nursery.
701+
if generational {
702+
args.get_mixed_age_space_args("los", true, false, VMRequest::discontiguous())
703+
} else {
704+
args.get_normal_space_args("los", true, false, VMRequest::discontiguous())
705+
},
621706
false,
622707
needs_log_bit,
623708
),
@@ -677,7 +762,7 @@ impl<VM: VMBinding> CommonPlan<VM> {
677762
}
678763

679764
fn new_nonmoving_space(args: &mut CreateSpecificPlanArgs<VM>) -> NonMovingSpace<VM> {
680-
let space_args = args.get_space_args("nonmoving", true, false, VMRequest::discontiguous());
765+
let space_args = args.get_common_space_args(args.constraints.generational, "nonmoving");
681766
cfg_if::cfg_if! {
682767
if #[cfg(any(feature = "immortal_as_nonmoving", feature = "marksweep_as_nonmoving"))] {
683768
NonMovingSpace::new(space_args)
@@ -686,7 +771,6 @@ impl<VM: VMBinding> CommonPlan<VM> {
686771
NonMovingSpace::new(
687772
space_args,
688773
crate::policy::immix::ImmixSpaceArgs {
689-
#[cfg(feature = "vo_bit")]
690774
mixed_age: false,
691775
never_move_objects: true,
692776
},

src/plan/immix/global.rs

Lines changed: 15 additions & 2 deletions
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-
#[cfg(feature = "vo_bit")]
142141
mixed_age: false,
143142
never_move_objects: false,
144143
},
@@ -151,7 +150,21 @@ impl<VM: VMBinding> Immix<VM> {
151150
) -> Self {
152151
let immix = Immix {
153152
immix_space: ImmixSpace::new(
154-
plan_args.get_space_args("immix", true, false, VMRequest::discontiguous()),
153+
if space_args.mixed_age {
154+
plan_args.get_mixed_age_space_args(
155+
"immix",
156+
true,
157+
false,
158+
VMRequest::discontiguous(),
159+
)
160+
} else {
161+
plan_args.get_normal_space_args(
162+
"immix",
163+
true,
164+
false,
165+
VMRequest::discontiguous(),
166+
)
167+
},
155168
space_args,
156169
),
157170
common: CommonPlan::new(plan_args),

src/plan/markcompact/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<VM: VMBinding> MarkCompact<VM> {
198198
global_side_metadata_specs,
199199
};
200200

201-
let mc_space = MarkCompactSpace::new(plan_args.get_space_args(
201+
let mc_space = MarkCompactSpace::new(plan_args.get_normal_space_args(
202202
"mc",
203203
true,
204204
false,

src/plan/marksweep/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<VM: VMBinding> MarkSweep<VM> {
112112
};
113113

114114
let res = MarkSweep {
115-
ms: MarkSweepSpace::new(plan_args.get_space_args(
115+
ms: MarkSweepSpace::new(plan_args.get_normal_space_args(
116116
"ms",
117117
true,
118118
false,

src/plan/nogc/global.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ impl<VM: VMBinding> NoGC<VM> {
9999
};
100100

101101
let res = NoGC {
102-
nogc_space: NoGCImmortalSpace::new(plan_args.get_space_args(
102+
nogc_space: NoGCImmortalSpace::new(plan_args.get_normal_space_args(
103103
"nogc_space",
104104
cfg!(not(feature = "nogc_no_zeroing")),
105105
false,
106106
VMRequest::discontiguous(),
107107
)),
108-
immortal: ImmortalSpace::new(plan_args.get_space_args(
108+
immortal: ImmortalSpace::new(plan_args.get_normal_space_args(
109109
"immortal",
110110
true,
111111
false,
112112
VMRequest::discontiguous(),
113113
)),
114-
los: ImmortalSpace::new(plan_args.get_space_args(
114+
los: ImmortalSpace::new(plan_args.get_normal_space_args(
115115
"los",
116116
true,
117117
false,

0 commit comments

Comments
 (0)