Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fl_map and refactor FreeListPageResoure #953

Merged
merged 12 commits into from
May 10, 2024
15 changes: 12 additions & 3 deletions src/mmtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<VM: VMBinding> MMTK<VM> {
// So we do not save it in MMTK. This may change in the future.
let mut heap = HeapMeta::new();

let plan = crate::plan::create_plan(
let mut plan = crate::plan::create_plan(
*options.plan,
CreateGeneralPlanArgs {
vm_map: VM_MAP.as_ref(),
Expand All @@ -188,9 +188,18 @@ impl<VM: VMBinding> MMTK<VM> {
}

// TODO: This probably does not work if we have multiple MMTk instances.
VM_MAP.boot();
// This needs to be called after we create Plan. It needs to use HeapMeta, which is gradually built when we create spaces.
VM_MAP.finalize_static_space_map(heap.get_discontig_start(), heap.get_discontig_end());
VM_MAP.finalize_static_space_map(
heap.get_discontig_start(),
heap.get_discontig_end(),
&mut |start_address| {
qinsoon marked this conversation as resolved.
Show resolved Hide resolved
plan.for_each_space_mut(&mut |space| {
if let Some(pr) = space.maybe_get_page_resource_mut() {
pr.update_discontiguous_start(start_address);
}
})
},
);

if *options.transparent_hugepages {
MMAPPER.set_mmap_strategy(crate::util::memory::MmapStrategy::TransparentHugePages);
Expand Down
4 changes: 4 additions & 0 deletions src/policy/copyspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl<VM: VMBinding> Space<VM> for CopySpace<VM> {
&self.pr
}

fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}

fn common(&self) -> &CommonSpace<VM> {
&self.common
}
Expand Down
3 changes: 3 additions & 0 deletions src/policy/immix/immixspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ impl<VM: VMBinding> Space<VM> for ImmixSpace<VM> {
fn get_page_resource(&self) -> &dyn PageResource<VM> {
&self.pr
}
fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}
fn common(&self) -> &CommonSpace<VM> {
&self.common
}
Expand Down
3 changes: 3 additions & 0 deletions src/policy/immortalspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ impl<VM: VMBinding> Space<VM> for ImmortalSpace<VM> {
fn get_page_resource(&self) -> &dyn PageResource<VM> {
&self.pr
}
fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}
fn common(&self) -> &CommonSpace<VM> {
&self.common
}
Expand Down
3 changes: 3 additions & 0 deletions src/policy/largeobjectspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ impl<VM: VMBinding> Space<VM> for LargeObjectSpace<VM> {
fn get_page_resource(&self) -> &dyn PageResource<VM> {
&self.pr
}
fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}

fn initialize_sft(&self, sft_map: &mut dyn crate::policy::sft_map::SFTMap) {
self.common().initialize_sft(self.as_sft(), sft_map)
Expand Down
3 changes: 3 additions & 0 deletions src/policy/lockfreeimmortalspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ impl<VM: VMBinding> Space<VM> for LockFreeImmortalSpace<VM> {
fn get_page_resource(&self) -> &dyn PageResource<VM> {
unimplemented!()
}
fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
None
}
fn common(&self) -> &CommonSpace<VM> {
unimplemented!()
}
Expand Down
4 changes: 4 additions & 0 deletions src/policy/markcompactspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ impl<VM: VMBinding> Space<VM> for MarkCompactSpace<VM> {
&self.pr
}

fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}

fn common(&self) -> &CommonSpace<VM> {
&self.common
}
Expand Down
4 changes: 4 additions & 0 deletions src/policy/marksweepspace/malloc_ms/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ impl<VM: VMBinding> Space<VM> for MallocSpace<VM> {
unreachable!()
}

fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
None
}

fn common(&self) -> &CommonSpace<VM> {
unreachable!()
}
Expand Down
6 changes: 5 additions & 1 deletion src/policy/marksweepspace/native_ms/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
scheduler::{GCWorkScheduler, GCWorker},
util::{
copy::CopySemantics,
heap::FreeListPageResource,
heap::{FreeListPageResource, PageResource},
metadata::{self, side_metadata::SideMetadataSpec, MetadataSpec},
ObjectReference,
},
Expand Down Expand Up @@ -209,6 +209,10 @@ impl<VM: VMBinding> Space<VM> for MarkSweepSpace<VM> {
&self.pr
}

fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}

fn initialize_sft(&self, sft_map: &mut dyn crate::policy::sft_map::SFTMap) {
self.common().initialize_sft(self.as_sft(), sft_map)
}
Expand Down
4 changes: 4 additions & 0 deletions src/policy/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pub trait Space<VM: VMBinding>: 'static + SFT + Sync + Downcast {
fn as_sft(&self) -> &(dyn SFT + Sync + 'static);
fn get_page_resource(&self) -> &dyn PageResource<VM>;

/// Get a mutable reference to the underlying page resource, or `None` if the space does not
/// have a page resource.
fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>>;

/// Initialize entires in SFT map for the space. This is called when the Space object
/// has a non-moving address, as we will use the address to set sft.
/// Currently after we create a boxed plan, spaces in the plan have a non-moving address.
Expand Down
3 changes: 3 additions & 0 deletions src/policy/vmspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ impl<VM: VMBinding> Space<VM> for VMSpace<VM> {
fn get_page_resource(&self) -> &dyn PageResource<VM> {
&self.pr
}
fn maybe_get_page_resource_mut(&mut self) -> Option<&mut dyn PageResource<VM>> {
Some(&mut self.pr)
}
fn common(&self) -> &CommonSpace<VM> {
&self.common
}
Expand Down
4 changes: 4 additions & 0 deletions src/util/heap/blockpageresource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ impl<VM: VMBinding, B: Region> PageResource<VM> for BlockPageResource<VM, B> {
self.flpr.common_mut()
}

fn update_discontiguous_start(&mut self, start: Address) {
self.flpr.update_discontiguous_start(start)
}

fn alloc_pages(
&self,
space_descriptor: SpaceDescriptor,
Expand Down
Loading
Loading