use enum_map::EnumMap;
use crate::plan::barriers::BarrierSelector;
use crate::plan::mutator_context::create_allocator_mapping;
use crate::plan::AllocationSemantics;
use crate::plan::PlanConstraints;
use crate::policy::copyspace::CopySpace;
use crate::policy::space::Space;
use crate::util::alloc::AllocatorSelector;
use crate::util::metadata::side_metadata::SideMetadataContext;
use crate::util::metadata::side_metadata::SideMetadataSpec;
use crate::vm::ObjectModel;
use crate::vm::VMBinding;
use crate::Plan;
use super::mutator_context::create_space_mapping;
use super::mutator_context::ReservedAllocators;
pub mod barrier;
pub mod copying;
pub mod immix;
pub(super) mod gc_work;
pub(super) mod global;
pub const ACTIVE_BARRIER: BarrierSelector = BarrierSelector::ObjectBarrier;
pub const FULL_NURSERY_GC: bool = false;
pub const GEN_CONSTRAINTS: PlanConstraints = PlanConstraints {
moves_objects: true,
needs_log_bit: ACTIVE_BARRIER.equals(BarrierSelector::ObjectBarrier),
barrier: ACTIVE_BARRIER,
may_trace_duplicate_edges: ACTIVE_BARRIER.equals(BarrierSelector::ObjectBarrier),
max_non_los_default_alloc_bytes:
crate::plan::plan_constraints::MAX_NON_LOS_ALLOC_BYTES_COPYING_PLAN,
needs_prepare_mutator: false,
..PlanConstraints::default()
};
pub fn new_generational_global_metadata_specs<VM: VMBinding>() -> Vec<SideMetadataSpec> {
let specs = if ACTIVE_BARRIER == BarrierSelector::ObjectBarrier {
crate::util::metadata::extract_side_metadata(&[*VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC])
} else {
vec![]
};
SideMetadataContext::new_global_specs(&specs)
}
const RESERVED_ALLOCATORS: ReservedAllocators = ReservedAllocators {
n_bump_pointer: 1,
..ReservedAllocators::DEFAULT
};
lazy_static! {
static ref ALLOCATOR_MAPPING: EnumMap<AllocationSemantics, AllocatorSelector> = {
let mut map = create_allocator_mapping(RESERVED_ALLOCATORS, true);
map[AllocationSemantics::Default] = AllocatorSelector::BumpPointer(0);
map
};
}
fn create_gen_space_mapping<VM: VMBinding>(
plan: &'static dyn Plan<VM = VM>,
nursery: &'static CopySpace<VM>,
) -> Vec<(AllocatorSelector, &'static dyn Space<VM>)> {
let mut vec = create_space_mapping(RESERVED_ALLOCATORS, true, plan);
vec.push((AllocatorSelector::BumpPointer(0), nursery));
vec
}