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