MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / deallocate_indirect

Method deallocate_indirect

crates/core/src/abi.rs:2491–2621  ·  view source on GitHub ↗
(
        &mut self,
        ty: &Type,
        addr: B::Operand,
        offset: ArchitectureSize,
        what: Deallocate,
    )

Source from the content-addressed store, hash-verified

2489 }
2490
2491 fn deallocate_indirect(
2492 &mut self,
2493 ty: &Type,
2494 addr: B::Operand,
2495 offset: ArchitectureSize,
2496 what: Deallocate,
2497 ) {
2498 use Instruction::*;
2499
2500 // No need to execute any instructions if this type itself doesn't
2501 // require any form of post-return.
2502 if !needs_deallocate(self.resolve, ty, what) {
2503 return;
2504 }
2505
2506 match *ty {
2507 Type::String => {
2508 self.stack.push(addr.clone());
2509 self.emit(&Instruction::PointerLoad { offset });
2510 self.stack.push(addr);
2511 self.emit(&Instruction::LengthLoad {
2512 offset: offset + self.bindgen.sizes().align(ty).into(),
2513 });
2514 self.deallocate(ty, what);
2515 }
2516
2517 Type::Bool
2518 | Type::U8
2519 | Type::S8
2520 | Type::U16
2521 | Type::S16
2522 | Type::U32
2523 | Type::S32
2524 | Type::Char
2525 | Type::U64
2526 | Type::S64
2527 | Type::F32
2528 | Type::F64
2529 | Type::ErrorContext => {}
2530
2531 Type::Id(id) => match &self.resolve.types[id].kind {
2532 TypeDefKind::Type(t) => self.deallocate_indirect(t, addr, offset, what),
2533
2534 TypeDefKind::List(_) => {
2535 self.stack.push(addr.clone());
2536 self.emit(&Instruction::PointerLoad { offset });
2537 self.stack.push(addr);
2538 self.emit(&Instruction::LengthLoad {
2539 offset: offset + self.bindgen.sizes().align(ty).into(),
2540 });
2541
2542 self.deallocate(ty, what);
2543 }
2544
2545 TypeDefKind::Map(_, _) => {
2546 self.stack.push(addr.clone());
2547 self.emit(&Instruction::PointerLoad { offset });
2548 self.stack.push(addr);

Callers 4

deallocate_in_typesMethod · 0.80
deallocateMethod · 0.80

Calls 11

needs_deallocateFunction · 0.85
deallocateMethod · 0.80
handlesMethod · 0.80
read_from_memoryMethod · 0.80
mapMethod · 0.80
pushMethod · 0.45
emitMethod · 0.45
sizesMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected