This commit is contained in:
Max Bernstein 2025-08-15 11:07:28 +09:00 committed by GitHub
commit d7f0d6ac2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -276,11 +276,22 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, function: &Function) -> Optio
}
// Compile all instructions
let mut last_snapshot = None;
for &insn_id in block.insns() {
let insn = function.find(insn_id);
if let Insn::Snapshot { .. } = &insn {
last_snapshot = Some(insn_id);
}
if gen_insn(cb, &mut jit, &mut asm, function, insn_id, &insn).is_none() {
debug!("Failed to compile insn: {insn_id} {insn}");
return None;
let Some(last_snapshot) = last_snapshot else {
debug!("ZJIT: gen_function: No snapshot found for side-exit. Aborting compilation.");
return None;
};
debug!("ZJIT: gen_function: Failed to compile insn: {insn_id} {insn}. Generating side-exit.");
gen_side_exit(&mut jit, &mut asm, &SideExitReason::UnhandledInstruction(insn_id), &function.frame_state(last_snapshot))?;
// Don't bother generating code after a side-exit. We won't run it.
// TODO(max): Generate ud2 or equivalent.
break;
}
}
// Make sure the last patch point has enough space to insert a jump
@ -394,7 +405,6 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
| Insn::ToNewArray { .. }
| Insn::Const { .. }
=> {
debug!("ZJIT: gen_function: unexpected insn {insn}");
return None;
}
};

View file

@ -407,6 +407,7 @@ pub enum SideExitReason {
UnknownNewarraySend(vm_opt_newarray_send_type),
UnknownCallType,
UnknownOpcode(u32),
UnhandledInstruction(InsnId),
FixnumAddOverflow,
FixnumSubOverflow,
FixnumMultOverflow,