wasm_interp: fix memory instructions (immediate arg for memory index)

This commit is contained in:
Brian Carroll 2022-12-05 20:50:54 +00:00
parent b938e546b2
commit 6820278672
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
2 changed files with 6 additions and 0 deletions

View file

@ -749,10 +749,14 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
target.copy_from_slice(&unwrapped.to_le_bytes()[..4]);
}
CURRENTMEMORY => {
let memory_index = self.fetch_immediate_u32(module);
assert_eq!(memory_index, 0);
let size = self.memory.len() as i32 / MemorySection::PAGE_SIZE as i32;
self.value_stack.push(Value::I32(size));
}
GROWMEMORY => {
let memory_index = self.fetch_immediate_u32(module);
assert_eq!(memory_index, 0);
let old_bytes = self.memory.len() as u32;
let old_pages = old_bytes / MemorySection::PAGE_SIZE as u32;
let grow_pages = self.value_stack.pop_u32()?;