mmtk/util/heap/layout/
mod.rs

1pub mod heap_parameters;
2pub mod vm_layout;
3
4mod mmapper;
5pub use self::mmapper::Mmapper;
6
7mod map;
8pub(crate) use self::map::CreateFreeListResult;
9pub use self::map::VMMap;
10use self::vm_layout::vm_layout;
11mod map32;
12#[cfg(target_pointer_width = "64")]
13mod map64;
14
15#[cfg(target_pointer_width = "32")]
16pub fn create_vm_map() -> Box<dyn VMMap + Send + Sync> {
17    Box::new(map32::Map32::new())
18}
19
20#[cfg(target_pointer_width = "64")]
21pub fn create_vm_map() -> Box<dyn VMMap + Send + Sync> {
22    if !vm_layout().force_use_contiguous_spaces {
23        Box::new(map32::Map32::new())
24    } else {
25        Box::new(map64::Map64::new())
26    }
27}
28
29pub fn create_mmapper() -> Box<dyn Mmapper> {
30    // TODO: Select a MapStateStorage based on the actuall address space size.
31    // For example, choose ByteMapStateStorage for 39-bit or less virtual space.
32
33    use crate::util::heap::layout::mmapper::csm::ChunkStateMmapper;
34    Box::new(ChunkStateMmapper::new())
35}
36
37use crate::util::Address;
38use std::ops::Range;
39
40/// The heap range between HEAP_START and HEAP_END
41/// Heap range include the availble range, but may include some address ranges
42/// that we count as part of the heap but we do not allocate into, such as
43/// VM spaces. However, currently, heap range is the same as available range.
44pub fn heap_range() -> Range<Address> {
45    vm_layout().heap_start..vm_layout().heap_end
46}
47
48/// The avialable heap range between AVAILABLE_START and AVAILABLE_END.
49/// Available range is what MMTk may allocate into.
50pub fn available_range() -> Range<Address> {
51    vm_layout().available_start()..vm_layout().available_end()
52}