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

Method exec_mem_load

crates/tinywasm/src/interpreter/executor.rs:1402–1424  ·  view source on GitHub ↗
(
        &mut self,
        mem_addr: tinywasm_types::MemAddr,
        offset: u64,
        cast: impl Fn(LOAD) -> TARGET,
    )

Source from the content-addressed store, hash-verified

1400
1401 #[inline(always)]
1402 fn exec_mem_load<LOAD: MemValue<LOAD_SIZE>, const LOAD_SIZE: usize, TARGET: InternalValue>(
1403 &mut self,
1404 mem_addr: tinywasm_types::MemAddr,
1405 offset: u64,
1406 cast: impl Fn(LOAD) -> TARGET,
1407 ) -> Result<(), Trap> {
1408 let mem = self.store.state.get_mem(self.module.resolve_mem_addr(mem_addr));
1409 let base = match mem.is_64bit() {
1410 true => <i64>::stack_pop(&mut self.store.value_stack) as u64,
1411 false => <i32>::stack_pop(&mut self.store.value_stack) as u32 as u64,
1412 };
1413
1414 match LOAD::load(&*mem.inner, base, offset) {
1415 Ok(val) => {
1416 self.store.value_stack.push(cast(val))?;
1417 Ok(())
1418 }
1419 Err(e) => {
1420 cold_path();
1421 Err(e)
1422 }
1423 }
1424 }
1425
1426 fn exec_mem_store_lane<U: MemValue<N> + Copy, const N: usize>(
1427 &mut self,

Callers

nothing calls this directly

Calls 4

get_memMethod · 0.80
resolve_mem_addrMethod · 0.80
is_64bitMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected