Skip to content

Commit a504184

Browse files
qinsoonk-sareen
andauthored
Add ExternalPageResource and allow discontiguous VM space (#864)
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]>
1 parent 66e8cb8 commit a504184

File tree

7 files changed

+270
-139
lines changed

7 files changed

+270
-139
lines changed

src/memory_manager.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,13 @@ pub fn mmtk_init<VM: VMBinding>(builder: &MMTKBuilder) -> Box<MMTK<VM>> {
8686
Box::new(mmtk)
8787
}
8888

89+
/// 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`),
90+
/// and can also be set through this function call. A VM space can be discontiguous. This function can be called multiple times,
91+
/// and all the address ranges passed as arguments in the function will be considered as part of the VM space.
92+
/// Currently we do not allow removing regions from VM space.
8993
#[cfg(feature = "vm_space")]
90-
pub fn lazy_init_vm_space<VM: VMBinding>(mmtk: &'static mut MMTK<VM>, start: Address, size: usize) {
91-
unsafe {
92-
mmtk.get_plan_mut()
93-
.base_mut()
94-
.vm_space
95-
.lazy_initialize(start, size);
96-
}
94+
pub fn set_vm_space<VM: VMBinding>(mmtk: &'static mut MMTK<VM>, start: Address, size: usize) {
95+
unsafe { mmtk.get_plan_mut() }.base_mut().vm_space.set_vm_region(start, size);
9796
}
9897

9998
/// Request MMTk to create a mutator for the given thread. The ownership

src/plan/global.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,11 @@ impl<VM: VMBinding> BasePlan<VM> {
529529
VMRequest::discontiguous(),
530530
)),
531531
#[cfg(feature = "vm_space")]
532-
vm_space: VMSpace::new(&mut args),
532+
vm_space: VMSpace::new(args.get_space_args(
533+
"vm_space",
534+
false,
535+
VMRequest::discontiguous(),
536+
)),
533537

534538
initialized: AtomicBool::new(false),
535539
trigger_gc_when_heap_is_full: AtomicBool::new(true),

src/plan/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ pub use global::AllocationSemantics;
2626
pub(crate) use global::GcStatus;
2727
pub use global::Plan;
2828
pub(crate) use global::PlanTraceObject;
29-
#[cfg(feature = "vm_space")] // This is used for creating VM space
30-
pub(crate) use global::{CreateGeneralPlanArgs, CreateSpecificPlanArgs};
3129

3230
mod mutator_context;
3331
pub use mutator_context::Mutator;

0 commit comments

Comments
 (0)