diff --git a/lib/compiler-singlepass/src/codegen.rs b/lib/compiler-singlepass/src/codegen.rs index 81ba5ecb9de..afec6f37cc3 100644 --- a/lib/compiler-singlepass/src/codegen.rs +++ b/lib/compiler-singlepass/src/codegen.rs @@ -510,6 +510,18 @@ impl<'a, M: Machine> FuncGen<'a, M> { // Allocate save area, without actually writing to it. static_area_size = self.machine.round_stack_adjust(static_area_size); + + // Stack probe. + // + // `rep stosq` writes data from low address to high address and may skip the stack guard page. + // so here we probe it explicitly when needed. + for i in (sig.params().len()..n) + .step_by(NATIVE_PAGE_SIZE / 8) + .skip(0) + { + self.machine.zero_location(Size::S64, locations[i]); + } + self.machine.adjust_stack(static_area_size as _); // Save callee-saved registers. @@ -586,17 +598,6 @@ impl<'a, M: Machine> FuncGen<'a, M> { Location::GPR(self.machine.get_vmctx_reg()), ); - // Stack probe. - // - // `rep stosq` writes data from low address to high address and may skip the stack guard page. - // so here we probe it explicitly when needed. - for i in (sig.params().len()..n) - .step_by(NATIVE_PAGE_SIZE / 8) - .skip(1) - { - self.machine.zero_location(Size::S64, locations[i]); - } - // Initialize all normal locals to zero. let mut init_stack_loc_cnt = 0; let mut last_stack_loc = Location::Memory(self.machine.local_pointer(), i32::MAX);