MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / stack_address

Method stack_address

cranelift/interpreter/src/interpreter.rs:293–319  ·  view source on GitHub ↗
(
        &self,
        size: AddressSize,
        slot: StackSlot,
        offset: u64,
    )

Source from the content-addressed store, hash-verified

291 }
292
293 fn stack_address(
294 &self,
295 size: AddressSize,
296 slot: StackSlot,
297 offset: u64,
298 ) -> Result<Address, MemoryError> {
299 let stack_slots = &self.get_current_function().sized_stack_slots;
300 let stack_slot = &stack_slots[slot];
301
302 // offset must be `0 <= Offset < sizeof(SS)`
303 if offset >= stack_slot.size as u64 {
304 return Err(MemoryError::InvalidOffset {
305 offset,
306 max: stack_slot.size as u64,
307 });
308 }
309
310 // Calculate the offset from the current frame to the requested stack slot
311 let slot_offset: u64 = stack_slots
312 .keys()
313 .filter(|k| k < &slot)
314 .map(|k| stack_slots[k].size as u64)
315 .sum();
316
317 let final_offset = self.frame_offset as u64 + slot_offset + offset;
318 Address::from_parts(size, AddressRegion::Stack, 0, final_offset)
319 }
320
321 fn checked_load(
322 &self,

Callers 1

stepFunction · 0.80

Calls 4

get_current_functionMethod · 0.80
sumMethod · 0.80
mapMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected