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

Method load_memory_length

winch/codegen/src/codegen/mod.rs:1509–1522  ·  view source on GitHub ↗

Retrieves the size of the memory, pushing the result to the value stack.

(&mut self, heap_data: &HeapData, size_reg: Reg)

Source from the content-addressed store, hash-verified

1507
1508 /// Retrieves the size of the memory, pushing the result to the value stack.
1509 fn load_memory_length(&mut self, heap_data: &HeapData, size_reg: Reg) -> Result<()> {
1510 self.masm.with_scratch::<IntScratch, _>(|masm, scratch| {
1511 let base = if let Some(offset) = heap_data.import_from {
1512 masm.load_ptr(masm.address_at_vmctx(offset)?, scratch.writable())?;
1513 scratch.inner()
1514 } else {
1515 vmctx!(M)
1516 };
1517
1518 let size_addr = masm.address_at_reg(base, heap_data.current_length_offset)?;
1519 masm.load_ptr(size_addr, writable!(size_reg))
1520 })?;
1521 Ok(())
1522 }
1523
1524 /// Retrieves the size of the memory, pushing the result to the value stack.
1525 pub fn emit_compute_memory_size(&mut self, heap_data: &HeapData) -> Result<()> {

Calls 6

OkFunction · 0.85
load_ptrMethod · 0.45
address_at_vmctxMethod · 0.45
writableMethod · 0.45
innerMethod · 0.45
address_at_regMethod · 0.45

Tested by

no test coverage detected