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

Method checked_store

cranelift/interpreter/src/interpreter.rs:357–391  ·  view source on GitHub ↗
(
        &mut self,
        addr: Address,
        v: DataValue,
        mem_flags: MemFlagsData,
    )

Source from the content-addressed store, hash-verified

355 }
356
357 fn checked_store(
358 &mut self,
359 addr: Address,
360 v: DataValue,
361 mem_flags: MemFlagsData,
362 ) -> Result<(), MemoryError> {
363 let store_size = v.ty().bytes() as usize;
364 let addr_start = addr.offset as usize;
365 let addr_end = addr_start + store_size;
366
367 let dst = match addr.region {
368 AddressRegion::Stack => {
369 if addr_end > self.stack.len() {
370 return Err(MemoryError::OutOfBoundsStore {
371 addr,
372 store_size,
373 mem_flags,
374 });
375 }
376
377 &mut self.stack[addr_start..addr_end]
378 }
379 _ => unimplemented!(),
380 };
381
382 // Aligned flag is set and address is not aligned for the given type
383 if mem_flags.aligned() && addr_start % store_size != 0 {
384 return Err(MemoryError::MisalignedStore { addr, store_size });
385 }
386
387 Ok(match mem_flags.endianness(self.native_endianness) {
388 Endianness::Big => v.write_to_slice_be(dst),
389 Endianness::Little => v.write_to_slice_le(dst),
390 })
391 }
392
393 fn function_address(
394 &self,

Callers 1

stepFunction · 0.80

Calls 8

OkFunction · 0.85
write_to_slice_beMethod · 0.80
write_to_slice_leMethod · 0.80
bytesMethod · 0.45
tyMethod · 0.45
lenMethod · 0.45
alignedMethod · 0.45
endiannessMethod · 0.45

Tested by

no test coverage detected