Skip to content

Commit 0dcd21f

Browse files
committed
ZJIT: Remove PadPatchPoint instructions when lowering to LIR
Basic blocks in LIR should only ever end in control flow instructions such as jump or return. PadPatchPoint is not control flow, so we should not emit it at the end of blocks when lowering.
1 parent 994257a commit 0dcd21f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

zjit/src/codegen.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, version: IseqVersionRef, func
333333
};
334334

335335
gen_if_false(&mut asm, val_opnd, branch_edge, fall_through_edge);
336+
assert!(asm.current_block().insns.last().unwrap().is_terminator());
337+
336338
asm.set_current_block(fall_through_target);
337339

338340
let label = jit.get_label(&mut asm, fall_through_target, block_id);
@@ -356,6 +358,8 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, version: IseqVersionRef, func
356358
};
357359

358360
gen_if_true(&mut asm, val_opnd, branch_edge, fall_through_edge);
361+
assert!(asm.current_block().insns.last().unwrap().is_terminator());
362+
359363
asm.set_current_block(fall_through_target);
360364

361365
let label = jit.get_label(&mut asm, fall_through_target, block_id);
@@ -368,6 +372,8 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, version: IseqVersionRef, func
368372
args: target.args.iter().map(|insn_id| jit.get_opnd(*insn_id)).collect()
369373
};
370374
gen_jump(&mut asm, branch_edge);
375+
assert!(asm.current_block().insns.last().unwrap().is_terminator());
376+
371377
},
372378
_ => {
373379
if let Err(last_snapshot) = gen_insn(cb, &mut jit, &mut asm, function, insn_id, &insn) {
@@ -382,8 +388,8 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, version: IseqVersionRef, func
382388
}
383389
}
384390
}
385-
// Make sure the last patch point has enough space to insert a jump
386-
asm.pad_patch_point();
391+
// Blocks should always end with control flow
392+
assert!(asm.current_block().insns.last().unwrap().is_terminator());
387393
}
388394

389395
// Generate code if everything can be compiled

0 commit comments

Comments
 (0)