MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / exec_memory_copy

Method exec_memory_copy

crates/tinywasm/src/interpreter/executor.rs:1278–1295  ·  view source on GitHub ↗
(&mut self, dst_mem: u32, src_mem: u32)

Source from the content-addressed store, hash-verified

1276 }
1277
1278 fn exec_memory_copy(&mut self, dst_mem: u32, src_mem: u32) -> Result<(), Trap> {
1279 let size = i32::stack_pop(&mut self.store.value_stack);
1280 let src = i32::stack_pop(&mut self.store.value_stack);
1281 let dst = i32::stack_pop(&mut self.store.value_stack);
1282 let dst_mem_addr = self.module.resolve_mem_addr(dst_mem);
1283
1284 if dst_mem == src_mem {
1285 // copy within the same memory
1286 let mem = self.store.state.get_mem_mut(dst_mem_addr);
1287 mem.copy_within(dst as usize, src as usize, size as usize)?;
1288 } else {
1289 // copy between two memories
1290 let src_mem_addr = self.module.resolve_mem_addr(src_mem);
1291 let (dst_memory, src_memory) = self.store.state.get_mems_mut(dst_mem_addr, src_mem_addr);
1292 dst_memory.copy_from_memory(dst as usize, src_memory, src as usize, size as usize)?;
1293 }
1294 Ok(())
1295 }
1296
1297 fn exec_memory_fill(&mut self, addr: u32) -> Result<(), Trap> {
1298 let size = i32::stack_pop(&mut self.store.value_stack);

Callers 1

execMethod · 0.80

Calls 5

resolve_mem_addrMethod · 0.80
get_mem_mutMethod · 0.80
get_mems_mutMethod · 0.80
copy_from_memoryMethod · 0.80
copy_withinMethod · 0.45

Tested by

no test coverage detected