mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Fixed memory issues
This commit is contained in:
parent
6fce21e4d5
commit
5c5fbd309d
@ -392,12 +392,20 @@ impl Instance {
|
||||
// Instantiate memories
|
||||
{
|
||||
// Allocate the underlying memory and initialize it to all zeros.
|
||||
memories.reserve_exact(module.info.memories.len());
|
||||
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);
|
||||
let total_memories = module.info.memories.len();
|
||||
if total_memories > 0 {
|
||||
memories.reserve_exact(total_memories);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
memories.reserve_exact(1);
|
||||
memories.push(LinearMemory::new(0, None));
|
||||
}
|
||||
for init in &module.info.data_initializers {
|
||||
debug_assert!(init.base.is_none(), "globalvar base not supported yet");
|
||||
|
@ -40,7 +40,7 @@ impl LinearMemory {
|
||||
Some(val) => val 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();
|
||||
debug!("LinearMemory instantiated");
|
||||
|
Loading…
Reference in New Issue
Block a user