Skip to content

Commit

Permalink
Add ExternalPageResource and allow discontiguous VM space (#864)
Browse files Browse the repository at this point in the history
This PR changes `VMSpace` to multiple discontiguous regions as VM space.
This PR is used in mmtk/mmtk-julia#71 to support
system and package images.
* add an `ExternalPageResource` to manage the discontiguous regions.
* implement `VMSpace` with `ExternalPageResource`. `VMSpace` no longer
uses `ImmortalSpace`.
* rename `lazy_init_vm_space` to `set_vm_space`, as we allow setting vm
space multiple times with non overlapping regions.

---------

Co-authored-by: Kunal Sareen <[email protected]>
  • Loading branch information
qinsoon and k-sareen authored Aug 31, 2023
1 parent 66e8cb8 commit a504184
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 139 deletions.
13 changes: 6 additions & 7 deletions src/memory_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,13 @@ pub fn mmtk_init<VM: VMBinding>(builder: &MMTKBuilder) -> Box<MMTK<VM>> {
Box::new(mmtk)
}

/// Add an externally mmapped region to the VM space. A VM space can be set through MMTk options (`vm_space_start` and `vm_space_size`),
/// and can also be set through this function call. A VM space can be discontiguous. This function can be called multiple times,
/// and all the address ranges passed as arguments in the function will be considered as part of the VM space.
/// Currently we do not allow removing regions from VM space.
#[cfg(feature = "vm_space")]
pub fn lazy_init_vm_space<VM: VMBinding>(mmtk: &'static mut MMTK<VM>, start: Address, size: usize) {
unsafe {
mmtk.get_plan_mut()
.base_mut()
.vm_space
.lazy_initialize(start, size);
}
pub fn set_vm_space<VM: VMBinding>(mmtk: &'static mut MMTK<VM>, start: Address, size: usize) {
unsafe { mmtk.get_plan_mut() }.base_mut().vm_space.set_vm_region(start, size);
}

/// Request MMTk to create a mutator for the given thread. The ownership
Expand Down
6 changes: 5 additions & 1 deletion src/plan/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,11 @@ impl<VM: VMBinding> BasePlan<VM> {
VMRequest::discontiguous(),
)),
#[cfg(feature = "vm_space")]
vm_space: VMSpace::new(&mut args),
vm_space: VMSpace::new(args.get_space_args(
"vm_space",
false,
VMRequest::discontiguous(),
)),

initialized: AtomicBool::new(false),
trigger_gc_when_heap_is_full: AtomicBool::new(true),
Expand Down
2 changes: 0 additions & 2 deletions src/plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub use global::AllocationSemantics;
pub(crate) use global::GcStatus;
pub use global::Plan;
pub(crate) use global::PlanTraceObject;
#[cfg(feature = "vm_space")] // This is used for creating VM space
pub(crate) use global::{CreateGeneralPlanArgs, CreateSpecificPlanArgs};

mod mutator_context;
pub use mutator_context::Mutator;
Expand Down
Loading

0 comments on commit a504184

Please sign in to comment.