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
|
// Get memories in module
|
||||||
for memory in &module.info.memories {
|
for memory in &module.info.memories {
|
||||||
let memory = memory.entity;
|
let memory = memory.entity;
|
||||||
let v =
|
// If we use emscripten, we set a fixed initial and maximum
|
||||||
LinearMemory::new(memory.pages_count as u32, memory.maximum.map(|m| m as u32));
|
debug!("Instance - init memory ({}, {:?})", memory.pages_count, memory.maximum);
|
||||||
memories.push(v);
|
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 {
|
for init in &module.info.data_initializers {
|
||||||
|
@ -60,8 +60,8 @@ impl LinearMemory {
|
|||||||
unsafe {
|
unsafe {
|
||||||
mprotect(
|
mprotect(
|
||||||
base,
|
base,
|
||||||
// (initial * Self::PAGE_SIZE) as _,
|
initial as usize * Self::PAGE_SIZE as usize,
|
||||||
Self::DEFAULT_HEAP_SIZE,
|
// Self::DEFAULT_HEAP_SIZE,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -86,7 +86,7 @@ impl LinearMemory {
|
|||||||
|
|
||||||
/// Returns a number of allocated wasm pages.
|
/// Returns a number of allocated wasm pages.
|
||||||
pub fn current_size(&self) -> usize {
|
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 {
|
pub fn current_pages(&self) -> u32 {
|
||||||
@ -168,12 +168,12 @@ impl PartialEq for LinearMemory {
|
|||||||
impl Deref for LinearMemory {
|
impl Deref for LinearMemory {
|
||||||
type Target = [u8];
|
type Target = [u8];
|
||||||
fn deref(&self) -> &[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 {
|
impl DerefMut for LinearMemory {
|
||||||
fn deref_mut(&mut self) -> &mut [u8] {
|
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