mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Make tests happy again
This commit is contained in:
parent
55b0509654
commit
948f519a04
@ -463,9 +463,17 @@ impl Instance {
|
||||
// Get memories in module
|
||||
for memory in &module.info.memories {
|
||||
let memory = memory.entity;
|
||||
let v =
|
||||
LinearMemory::new(memory.pages_count as u32, memory.maximum.map(|m| m as u32));
|
||||
memories.push(v);
|
||||
// If we use emscripten, we set a fixed initial and maximum
|
||||
debug!("Instance - init memory ({}, {:?})", memory.pages_count, memory.maximum);
|
||||
let memory = if options.use_emscripten {
|
||||
// We use MAX_PAGES, so at the end the result is:
|
||||
// (initial * LinearMemory::PAGE_SIZE) == LinearMemory::DEFAULT_HEAP_SIZE
|
||||
LinearMemory::new(LinearMemory::MAX_PAGES as u32, None)
|
||||
}
|
||||
else {
|
||||
LinearMemory::new(memory.pages_count as u32, memory.maximum.map(|m| m as u32))
|
||||
};
|
||||
memories.push(memory);
|
||||
}
|
||||
|
||||
for init in &module.info.data_initializers {
|
||||
|
@ -60,8 +60,8 @@ impl LinearMemory {
|
||||
unsafe {
|
||||
mprotect(
|
||||
base,
|
||||
// (initial * Self::PAGE_SIZE) as _,
|
||||
Self::DEFAULT_HEAP_SIZE,
|
||||
initial as usize * Self::PAGE_SIZE as usize,
|
||||
// Self::DEFAULT_HEAP_SIZE,
|
||||
PROT_READ | PROT_WRITE,
|
||||
)
|
||||
},
|
||||
@ -86,7 +86,7 @@ impl LinearMemory {
|
||||
|
||||
/// Returns a number of allocated wasm pages.
|
||||
pub fn current_size(&self) -> usize {
|
||||
(self.current * Self::PAGE_SIZE) as _
|
||||
self.current as usize * Self::PAGE_SIZE as usize
|
||||
}
|
||||
|
||||
pub fn current_pages(&self) -> u32 {
|
||||
@ -168,12 +168,12 @@ impl PartialEq for LinearMemory {
|
||||
impl Deref for LinearMemory {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe { slice::from_raw_parts(self.base as _, (self.current * Self::PAGE_SIZE) as _) }
|
||||
unsafe { slice::from_raw_parts(self.base as _, self.current as usize * Self::PAGE_SIZE as usize) }
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for LinearMemory {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe { slice::from_raw_parts_mut(self.base as _, (self.current * Self::PAGE_SIZE) as _) }
|
||||
unsafe { slice::from_raw_parts_mut(self.base as _, self.current as usize * Self::PAGE_SIZE as usize) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user