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

Method check_stack

winch/codegen/src/isa/x64/masm.rs:127–162  ·  view source on GitHub ↗
(&mut self, vmctx: Reg)

Source from the content-addressed store, hash-verified

125 }
126
127 fn check_stack(&mut self, vmctx: Reg) -> Result<()> {
128 let ptr_size: u8 = self.ptr_size.bytes().try_into().unwrap();
129
130 self.with_scratch::<IntScratch, _>(|masm, scratch| {
131 masm.load_ptr(
132 masm.address_at_reg(vmctx, ptr_size.vmcontext_store_context().into())?,
133 scratch.writable(),
134 )?;
135
136 masm.load_ptr(
137 Address::offset(
138 scratch.inner(),
139 ptr_size.vmstore_context_stack_limit().into(),
140 ),
141 scratch.writable(),
142 )?;
143
144 masm.add_stack_max(scratch.inner());
145
146 masm.asm.cmp_rr(scratch.inner(), regs::rsp(), masm.ptr_size);
147 masm.asm.trapif(IntCmpKind::GtU, TrapCode::STACK_OVERFLOW);
148 wasmtime_environ::error::Ok(())
149 })?;
150
151 // Emit unwind info.
152 if self.shared_flags.unwind_info() {
153 self.asm.unwind_inst(UnwindInst::DefineNewFrame {
154 offset_upward_to_caller_sp: Self::ABI::arg_base_offset().into(),
155
156 // The Winch calling convention has no callee-save registers, so nothing will be
157 // clobbered.
158 offset_downward_to_clobbers: 0,
159 })
160 }
161 Ok(())
162 }
163
164 fn push(&mut self, reg: Reg, size: OperandSize) -> Result<StackSlot> {
165 let bytes = match (reg.class(), size) {

Callers 1

prologueMethod · 0.45

Calls 15

OkFunction · 0.85
cmp_rrMethod · 0.80
unwind_instMethod · 0.80
rspFunction · 0.70
unwrapMethod · 0.45
try_intoMethod · 0.45
bytesMethod · 0.45
load_ptrMethod · 0.45
address_at_regMethod · 0.45
writableMethod · 0.45

Tested by

no test coverage detected