Skip to content

Commit

Permalink
Rename types and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Oct 30, 2023
1 parent 3d78a80 commit 2ff2116
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 143 deletions.
18 changes: 9 additions & 9 deletions docs/userguide/src/tutorial/code/mygc_semispace/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use crate::policy::space::Space;
use crate::scheduler::*; // Modify
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::copy::*;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::metadata::side_metadata::SideMetadataContext;
use crate::util::opaque_pointer::*;
use crate::vm::VMBinding;
use enum_map::EnumMap;
use std::sync::atomic::{AtomicBool, Ordering}; // Add
// ANCHOR_END: imports_no_gc_work
// ANCHOR_END: imports_no_gc_work

// Remove #[allow(unused_imports)].
// Remove handle_user_collection_request().
Expand Down Expand Up @@ -66,7 +66,7 @@ impl<VM: VMBinding> Plan for MyGC<VM> {
},
space_mapping: vec![
// The tospace argument doesn't matter, we will rebind before a GC anyway.
(CopySelector::CopySpace(0), &self.copyspace0)
(CopySelector::CopySpace(0), &self.copyspace0),
],
constraints: &MYGC_CONSTRAINTS,
}
Expand Down Expand Up @@ -168,14 +168,14 @@ impl<VM: VMBinding> MyGC<VM> {
};

// ANCHOR: specify_spaces
let copyspace0_meta = plan_args
let copyspace0_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
let copyspace1_meta = plan_args
.specify_space(VMRequest::Unrestricted);
let copyspace1_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
.specify_space(VMRequest::Unrestricted);
// ANCHOR_END: specify_spaces

// ANCHOR: create_common_plan
Expand All @@ -187,11 +187,11 @@ impl<VM: VMBinding> MyGC<VM> {
hi: AtomicBool::new(false),
// ANCHOR: copyspaces_new
copyspace0: CopySpace::new(
plan_args.get_space_args("copyspace0", true, copyspace0_meta.unwrap()),
plan_args.get_space_args("copyspace0", true, copyspace0_resp.unwrap()),
false,
),
copyspace1: CopySpace::new(
plan_args.get_space_args("copyspace1", true, copyspace1_meta.unwrap()),
plan_args.get_space_args("copyspace1", true, copyspace1_resp.unwrap()),
true,
),
// ANCHOR_END: copyspaces_new
Expand Down
17 changes: 9 additions & 8 deletions docs/userguide/src/tutorial/mygc/ss/alloc.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ spaces that will be created in the current plan.
```

We do not have special requirements for either of the copy-spaces, so we just
specify `SpaceSpec::DontCare` here. At this step, the return values
`copyspace0_meta` and `copyspace1_meta` has not become usable, yet.
specify `VMRequest::Unrestricted` here. At this step, the return values
`copyspace0_resp` and `copyspace1_resp` has not become usable, yet.

Then, we construct the parent structure `CommonPlan::new()`.

Expand All @@ -112,17 +112,18 @@ Then, we construct the parent structure `CommonPlan::new()`.
`HeapMeta::place_spaces()`. That will determine the address range of all
spaces we specified.

After this, we can call `copyspace0_meta.unwrap()` to retrieve the compute
metadata for creating `copyspace0`, and `copyspace1` is similar. We can now
create the two `CopySpace` instances.
After this, we can call `copyspace0_resp.unwrap()` to retrieve the computed
placement information for creating `copyspace0`. `copyspace1` is similar. We
can now create the two `CopySpace` instances.

```rust
{{#include ../../code/mygc_semispace/global.rs:copyspaces_new}}
```

Note that `CommonSpace` and `BaseSpace` define other spaces, such as the large
object space. Their constructors specify their spaces before determining their
address ranges and instantiating them, just like we discribed here.
Note that `CommonSpace` and `BaseSpace` also define other spaces, such as the
large object space. Their constructors specify their spaces before
determining their address ranges and instantiating them, just like we
discribed here.

### Access MyGC spaces

Expand Down
14 changes: 7 additions & 7 deletions src/plan/generational/copying/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::policy::space::Space;
use crate::scheduler::*;
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::copy::*;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::Address;
use crate::util::ObjectReference;
use crate::util::VMWorkerThread;
Expand Down Expand Up @@ -200,24 +200,24 @@ impl<VM: VMBinding> GenCopy<VM> {
crate::plan::generational::new_generational_global_metadata_specs::<VM>(),
};

let copyspace0_spec = plan_args
let copyspace0_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
let copyspace1_spec = plan_args
.specify_space(VMRequest::Unrestricted);
let copyspace1_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
.specify_space(VMRequest::Unrestricted);

// Spaces will eventually be placed by `BasePlan`.
let gen = CommonGenPlan::new(&mut plan_args);

let copyspace0 = CopySpace::new(
plan_args.get_space_args("copyspace0", true, copyspace0_spec.unwrap()),
plan_args.get_space_args("copyspace0", true, copyspace0_resp.unwrap()),
false,
);
let copyspace1 = CopySpace::new(
plan_args.get_space_args("copyspace1", true, copyspace1_spec.unwrap()),
plan_args.get_space_args("copyspace1", true, copyspace1_resp.unwrap()),
true,
);

Expand Down
6 changes: 3 additions & 3 deletions src/plan/generational/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::policy::copyspace::CopySpace;
use crate::policy::space::Space;
use crate::scheduler::*;
use crate::util::copy::CopySemantics;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::statistics::counter::EventCounter;
use crate::util::Address;
use crate::util::ObjectReference;
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct CommonGenPlan<VM: VMBinding> {

impl<VM: VMBinding> CommonGenPlan<VM> {
pub fn new(args: &mut CreateSpecificPlanArgs<VM>) -> Self {
let nursery_meta = args.global_args.heap.specify_space(SpaceSpec::Extent {
let nursery_resp = args.global_args.heap.specify_space(VMRequest::Extent {
extent: args.global_args.options.get_max_nursery_bytes(),
top: false,
});
Expand All @@ -47,7 +47,7 @@ impl<VM: VMBinding> CommonGenPlan<VM> {
let common = CommonPlan::new(args);

let nursery = CopySpace::new(
args.get_space_args("nursery", true, nursery_meta.unwrap()),
args.get_space_args("nursery", true, nursery_resp.unwrap()),
true,
);

Expand Down
8 changes: 4 additions & 4 deletions src/plan/generational/immix/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::scheduler::GCWorkScheduler;
use crate::scheduler::GCWorker;
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::copy::*;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::Address;
use crate::util::ObjectReference;
use crate::util::VMWorkerThread;
Expand Down Expand Up @@ -232,16 +232,16 @@ impl<VM: VMBinding> GenImmix<VM> {
crate::plan::generational::new_generational_global_metadata_specs::<VM>(),
};

let immix_space_spec = plan_args
let immix_space_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
.specify_space(VMRequest::Unrestricted);

// Spaces will eventually be placed by `BasePlan`.
let gen = CommonGenPlan::new(&mut plan_args);

let immix_space = ImmixSpace::new(
plan_args.get_space_args("immix_mature", true, immix_space_spec.unwrap()),
plan_args.get_space_args("immix_mature", true, immix_space_resp.unwrap()),
ImmixSpaceArgs {
reset_log_bit_in_major_gc: false,
// We don't need to unlog objects at tracing. Instead, we unlog objects at copying.
Expand Down
32 changes: 16 additions & 16 deletions src/plan/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::scheduler::*;
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::copy::{CopyConfig, GCWorkerCopyContext};
use crate::util::heap::gc_trigger::GCTrigger;
use crate::util::heap::heap_meta::{HeapMeta, SpaceMeta, SpaceSpec};
use crate::util::heap::heap_meta::{HeapMeta, VMResponse, VMRequest};
use crate::util::heap::layout::Mmapper;
use crate::util::heap::layout::VMMap;
use crate::util::metadata::side_metadata::SideMetadataSanity;
Expand Down Expand Up @@ -365,7 +365,7 @@ impl<'a, VM: VMBinding> CreateSpecificPlanArgs<'a, VM> {
&mut self,
name: &'static str,
zeroed: bool,
space_meta: SpaceMeta,
space_meta: VMResponse,
) -> PlanCreateSpaceArgs<VM> {
PlanCreateSpaceArgs {
name,
Expand All @@ -387,12 +387,12 @@ impl<VM: VMBinding> BasePlan<VM> {
#[allow(unused_mut)] // 'args' only needs to be mutable for certain features
pub fn new(args: &mut CreateSpecificPlanArgs<VM>) -> BasePlan<VM> {
#[cfg(feature = "code_space")]
let code_space_meta = args.global_args.heap.specify_space(SpaceSpec::DontCare);
let code_space_resp = args.global_args.heap.specify_space(VMRequest::Unrestricted);
#[cfg(feature = "code_space")]
let code_lo_space_meta = args.global_args.heap.specify_space(SpaceSpec::DontCare);
let code_lo_space_resp = args.global_args.heap.specify_space(VMRequest::Unrestricted);
#[cfg(feature = "ro_space")]
let ro_space_meta = args.global_args.heap.specify_space(SpaceSpec::DontCare);
// NOTE: We don't specify VM space because it doesn't use SpaceMeta anyway.
let ro_space_resp = args.global_args.heap.specify_space(VMRequest::Unrestricted);
// NOTE: We don't specify VM space because it doesn't use any information in `VMResponse`.

// BasePlan does not have any nested structs with spaces. We now place spaces.
args.global_args.heap.place_spaces();
Expand All @@ -402,25 +402,25 @@ impl<VM: VMBinding> BasePlan<VM> {
code_space: ImmortalSpace::new(args.get_space_args(
"code_space",
true,
code_space_meta.unwrap(),
code_space_resp.unwrap(),
)),
#[cfg(feature = "code_space")]
code_lo_space: ImmortalSpace::new(args.get_space_args(
"code_lo_space",
true,
code_lo_space_meta.unwrap(),
code_lo_space_resp.unwrap(),
)),
#[cfg(feature = "ro_space")]
ro_space: ImmortalSpace::new(args.get_space_args(
"ro_space",
true,
ro_space_meta.unwrap(),
ro_space_resp.unwrap(),
)),
#[cfg(feature = "vm_space")]
vm_space: VMSpace::new(args.get_space_args(
"vm_space",
false,
SpaceMeta::vm_space_dummy(),
VMResponse::vm_space_dummy(),
)),

global_state: args.global_args.state.clone(),
Expand Down Expand Up @@ -560,23 +560,23 @@ pub struct CommonPlan<VM: VMBinding> {

impl<VM: VMBinding> CommonPlan<VM> {
pub fn new(args: &mut CreateSpecificPlanArgs<VM>) -> CommonPlan<VM> {
let immortal_meta = args.global_args.heap.specify_space(SpaceSpec::DontCare);
let los_meta = args.global_args.heap.specify_space(SpaceSpec::DontCare);
let nonmoving_meta = args.global_args.heap.specify_space(SpaceSpec::DontCare);
let immortal_resp = args.global_args.heap.specify_space(VMRequest::Unrestricted);
let los_resp = args.global_args.heap.specify_space(VMRequest::Unrestricted);
let nonmoving_resp = args.global_args.heap.specify_space(VMRequest::Unrestricted);

let base = BasePlan::new(args);

CommonPlan {
immortal: ImmortalSpace::new(args.get_space_args(
"immortal",
true,
immortal_meta.unwrap(),
immortal_resp.unwrap(),
)),
los: LargeObjectSpace::new(args.get_space_args("los", true, los_meta.unwrap()), false),
los: LargeObjectSpace::new(args.get_space_args("los", true, los_resp.unwrap()), false),
nonmoving: ImmortalSpace::new(args.get_space_args(
"nonmoving",
true,
nonmoving_meta.unwrap(),
nonmoving_resp.unwrap(),
)),
base,
}
Expand Down
8 changes: 4 additions & 4 deletions src/plan/immix/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::policy::space::Space;
use crate::scheduler::*;
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::copy::*;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::metadata::side_metadata::SideMetadataContext;
use crate::vm::VMBinding;
use crate::{policy::immix::ImmixSpace, util::opaque_pointer::VMWorkerThread};
Expand Down Expand Up @@ -140,17 +140,17 @@ impl<VM: VMBinding> Immix<VM> {
mut plan_args: CreateSpecificPlanArgs<VM>,
space_args: ImmixSpaceArgs,
) -> Self {
let immix_space_meta = plan_args
let immix_space_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
.specify_space(VMRequest::Unrestricted);

// Spaces will eventually be placed by `BasePlan`.
let common = CommonPlan::new(&mut plan_args);

let immix = Immix {
immix_space: ImmixSpace::new(
plan_args.get_space_args("immix", true, immix_space_meta.unwrap()),
plan_args.get_space_args("immix", true, immix_space_resp.unwrap()),
space_args,
),
common,
Expand Down
8 changes: 4 additions & 4 deletions src/plan/markcompact/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::scheduler::gc_work::*;
use crate::scheduler::*;
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::copy::CopySemantics;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::metadata::side_metadata::SideMetadataContext;
#[cfg(not(feature = "vo_bit"))]
use crate::util::metadata::vo_bit::VO_BIT_SIDE_METADATA_SPEC;
Expand Down Expand Up @@ -192,16 +192,16 @@ impl<VM: VMBinding> MarkCompact<VM> {
global_side_metadata_specs,
};

let mc_space_meta = plan_args
let mc_space_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
.specify_space(VMRequest::Unrestricted);

// Spaces will eventually be placed by `BasePlan`.
let common = CommonPlan::new(&mut plan_args);

let mc_space =
MarkCompactSpace::new(plan_args.get_space_args("mc", true, mc_space_meta.unwrap()));
MarkCompactSpace::new(plan_args.get_space_args("mc", true, mc_space_resp.unwrap()));

let res = MarkCompact { mc_space, common };

Expand Down
8 changes: 4 additions & 4 deletions src/plan/marksweep/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::plan::PlanConstraints;
use crate::policy::space::Space;
use crate::scheduler::GCWorkScheduler;
use crate::util::alloc::allocators::AllocatorSelector;
use crate::util::heap::heap_meta::SpaceSpec;
use crate::util::heap::heap_meta::VMRequest;
use crate::util::metadata::side_metadata::SideMetadataContext;
use crate::util::VMWorkerThread;
use crate::vm::VMBinding;
Expand Down Expand Up @@ -102,16 +102,16 @@ impl<VM: VMBinding> MarkSweep<VM> {
global_side_metadata_specs,
};

let ms_meta = plan_args
let ms_resp = plan_args
.global_args
.heap
.specify_space(SpaceSpec::DontCare);
.specify_space(VMRequest::Unrestricted);

// Spaces will eventually be placed by `BasePlan`.
let common = CommonPlan::new(&mut plan_args);

let res = MarkSweep {
ms: MarkSweepSpace::new(plan_args.get_space_args("ms", true, ms_meta.unwrap())),
ms: MarkSweepSpace::new(plan_args.get_space_args("ms", true, ms_resp.unwrap())),
common,
};

Expand Down
Loading

0 comments on commit 2ff2116

Please sign in to comment.