Commit 4e03378e authored by qinsoon's avatar qinsoon

make changes due to memmap crate API change

parent 16f103b2
......@@ -38,21 +38,19 @@ pub struct FreeListSpace {
pub trace_map: Arc<AddressMap<u8>>,
#[allow(dead_code)]
mmap: memmap::Mmap,
mmap: memmap::MmapMut,
treadmill: Mutex<Treadmill>
}
impl FreeListSpace {
pub fn new(space_size: usize) -> FreeListSpace {
let anon_mmap: memmap::Mmap = match memmap::Mmap::anonymous(
space_size + SPACE_ALIGN,
memmap::Protection::ReadWrite
) {
Ok(m) => m,
Err(_) => panic!("failed to call mmap")
};
let start: Address = Address::from_ptr::<u8>(anon_mmap.ptr()).align_up(SPACE_ALIGN);
let mut anon_mmap: memmap::MmapMut =
match memmap::MmapMut::map_anon(space_size + SPACE_ALIGN) {
Ok(m) => m,
Err(_) => panic!("failed to call mmap")
};
let start: Address = Address::from_ptr::<u8>(anon_mmap.as_mut_ptr()).align_up(SPACE_ALIGN);
let end: Address = start + space_size;
let trace_map = AddressMap::new(start, end);
......
......@@ -161,7 +161,7 @@ pub struct ImmixSpace {
total_blocks: usize, // for debug use
#[allow(dead_code)]
mmap: memmap::Mmap,
mmap: memmap::MmapMut,
usable_blocks: Mutex<LinkedList<Box<ImmixBlock>>>,
used_blocks: Mutex<LinkedList<Box<ImmixBlock>>>
}
......@@ -180,14 +180,12 @@ const SPACE_ALIGN: usize = 1 << 19;
impl ImmixSpace {
pub fn new(space_size: usize) -> ImmixSpace {
// acquire memory through mmap
let anon_mmap: memmap::Mmap = match memmap::Mmap::anonymous(
space_size + SPACE_ALIGN,
memmap::Protection::ReadWrite
) {
Ok(m) => m,
Err(_) => panic!("failed to call mmap")
};
let start: Address = Address::from_ptr::<u8>(anon_mmap.ptr()).align_up(SPACE_ALIGN);
let mut anon_mmap: memmap::MmapMut =
match memmap::MmapMut::map_anon(space_size + SPACE_ALIGN) {
Ok(m) => m,
Err(_) => panic!("failed to call mmap")
};
let start: Address = Address::from_ptr::<u8>(anon_mmap.as_mut_ptr()).align_up(SPACE_ALIGN);
let end: Address = start + space_size;
let line_mark_table = LineMarkTable::new(start, end);
......
......@@ -99,7 +99,7 @@ pub struct MuStack {
/// the Mmap that keeps this memory alive
#[allow(dead_code)]
mmap: Option<memmap::Mmap>
mmap: Option<memmap::MmapMut>
}
lazy_static!{
pub static ref MUSTACK_SP_OFFSET : usize =
......@@ -109,16 +109,16 @@ impl MuStack {
/// creates a new MuStack for given entry function and function address
pub fn new(id: MuID, func_addr: Address, stack_arg_size: usize) -> MuStack {
// allocate memory for the stack
let anon_mmap = {
let mut anon_mmap = {
// reserve two guard pages more than we need for the stack
let total_size = PAGE_SIZE * 2 + STACK_SIZE;
match memmap::Mmap::anonymous(total_size, memmap::Protection::ReadWrite) {
match memmap::MmapMut::map_anon(total_size) {
Ok(m) => m,
Err(_) => panic!("failed to mmap for a stack")
}
};
let mmap_start = Address::from_ptr(anon_mmap.ptr());
let mmap_start = Address::from_ptr(anon_mmap.as_mut_ptr());
debug_assert!(mmap_start.is_aligned_to(PAGE_SIZE));
// calculate the addresses
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment