mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 16:41:33 +00:00
Fixed memory issues
This commit is contained in:
@ -392,12 +392,20 @@ impl Instance {
|
|||||||
// Instantiate memories
|
// Instantiate memories
|
||||||
{
|
{
|
||||||
// Allocate the underlying memory and initialize it to all zeros.
|
// Allocate the underlying memory and initialize it to all zeros.
|
||||||
memories.reserve_exact(module.info.memories.len());
|
let total_memories = module.info.memories.len();
|
||||||
for memory in &module.info.memories {
|
if total_memories > 0 {
|
||||||
let memory = memory.entity;
|
memories.reserve_exact(total_memories);
|
||||||
let v =
|
for memory in &module.info.memories {
|
||||||
LinearMemory::new(memory.pages_count as u32, memory.maximum.map(|m| m as u32));
|
let memory = memory.entity;
|
||||||
memories.push(v);
|
let v = LinearMemory::new(
|
||||||
|
memory.pages_count as u32,
|
||||||
|
memory.maximum.map(|m| m as u32),
|
||||||
|
);
|
||||||
|
memories.push(v);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
memories.reserve_exact(1);
|
||||||
|
memories.push(LinearMemory::new(0, None));
|
||||||
}
|
}
|
||||||
for init in &module.info.data_initializers {
|
for init in &module.info.data_initializers {
|
||||||
debug_assert!(init.base.is_none(), "globalvar base not supported yet");
|
debug_assert!(init.base.is_none(), "globalvar base not supported yet");
|
||||||
|
@ -40,7 +40,7 @@ impl LinearMemory {
|
|||||||
Some(val) => val as u64,
|
Some(val) => val as u64,
|
||||||
None => initial as u64,
|
None => initial as u64,
|
||||||
};
|
};
|
||||||
let len = if len == 0 { 1 } else { len };
|
let len = if len == 0 { PAGE_SIZE as u64 } else { len };
|
||||||
|
|
||||||
let mmap = MmapMut::map_anon(len as usize).unwrap();
|
let mmap = MmapMut::map_anon(len as usize).unwrap();
|
||||||
debug!("LinearMemory instantiated");
|
debug!("LinearMemory instantiated");
|
||||||
|
Reference in New Issue
Block a user