1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use crate::util::{
side_metadata::{try_map_metadata_space, SideMetadataSpec},
Address,
};
use super::vm_layout_constants::BYTES_IN_CHUNK;
pub trait Mmapper {
/****************************************************************************
* Generic mmap and protection functionality
*/
/**
* Given an address array describing the regions of virtual memory to be used
* by MMTk, demand zero map all of them if they are not already mapped.
*
* @param spaceMap An address array containing a pairs of start and end
* addresses for each of the regions to be mappe3d
*/
fn eagerly_mmap_all_spaces(&self, space_map: &[Address]);
/**
* Mark a number of pages as mapped, without making any
* request to the operating system. Used to mark pages
* that the VM has already mapped.
* @param start Address of the first page to be mapped
* @param bytes Number of bytes to ensure mapped
*/
fn mark_as_mapped(&self, start: Address, bytes: usize);
/**
* Ensure that a range of pages is mmapped (or equivalent). If the
* pages are not yet mapped, demand-zero map them. Note that mapping
* occurs at chunk granularity, not page granularity.<p>
*
* NOTE: There is a monotonicity assumption so that only updates require lock
* acquisition.
* TODO: Fix the above to support unmapping.
*
* @param start The start of the range to be mapped.
* @param pages The size of the range to be mapped, in pages
*/
fn ensure_mapped(
&self,
start: Address,
pages: usize,
global_metadata_spec_vec: &[SideMetadataSpec],
local_metadata_spec_vec: &[SideMetadataSpec],
);
/// Map metadata memory for a given chunk
#[allow(clippy::result_unit_err)]
fn map_metadata(
&self,
chunk: Address,
global_metadata_spec_vec: &[SideMetadataSpec],
local_metadata_spec_vec: &[SideMetadataSpec],
) -> Result<(), ()> {
if try_map_metadata_space(
chunk,
BYTES_IN_CHUNK,
global_metadata_spec_vec,
local_metadata_spec_vec,
)
.is_err()
{
Err(())
} else {
Ok(())
}
}
/**
* Is the page pointed to by this address mapped ?
* @param addr Address in question
* @return {@code true} if the page at the given address is mapped.
*/
fn is_mapped_address(&self, addr: Address) -> bool;
/**
* Mark a number of pages as inaccessible.
* @param start Address of the first page to be protected
* @param pages Number of pages to be protected
*/
fn protect(&self, start: Address, pages: usize);
}