Skip to content

Commit 64534bf

Browse files
committed
ZJIT: Load Ruby params in bb0 instead of entry point
Previously, we stored the params at the wrong spots on the stack because after gen_entry_params() we touched the SP in gen_function() for bb0 in asm.frame_setup() and in the explicit stack pointer bump. Later, when we read off of SP using the same offset we don't load what we stored because SP has moved. (This is like the _iterator invalidation problem_.) Load the params in bb0 after all the SP movements.
1 parent 8b965a1 commit 64534bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

zjit/src/codegen.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn gen_iseq_entry_point(iseq: IseqPtr) -> *const u8 {
113113
payload.start_ptr = Some(start_ptr);
114114

115115
// Compile an entry point to the JIT code
116-
(gen_entry(cb, iseq, &function, start_ptr), branch_iseqs)
116+
(gen_entry(cb, iseq, start_ptr), branch_iseqs)
117117
},
118118
None => (None, vec![]),
119119
};
@@ -144,11 +144,10 @@ fn gen_iseq_entry_point(iseq: IseqPtr) -> *const u8 {
144144
}
145145

146146
/// Compile a JIT entry
147-
fn gen_entry(cb: &mut CodeBlock, iseq: IseqPtr, function: &Function, function_ptr: CodePtr) -> Option<CodePtr> {
147+
fn gen_entry(cb: &mut CodeBlock, iseq: IseqPtr, function_ptr: CodePtr) -> Option<CodePtr> {
148148
// Set up registers for CFP, EC, SP, and basic block arguments
149149
let mut asm = Assembler::new();
150150
gen_entry_prologue(&mut asm, iseq);
151-
gen_entry_params(&mut asm, iseq, function.block(BlockId(0)));
152151

153152
// Jump to the first block using a call instruction
154153
asm.ccall(function_ptr.raw_ptr(cb) as *const u8, vec![]);
@@ -216,6 +215,8 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, function: &Function) -> Optio
216215
let new_sp = asm.sub(NATIVE_STACK_PTR, jit.c_stack_bytes.into());
217216
asm.mov(NATIVE_STACK_PTR, new_sp);
218217
}
218+
219+
gen_entry_params(&mut asm, iseq, function.block(BlockId(0)));
219220
}
220221

221222
// Compile all parameters

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy