mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
ZJIT: Set PC before function_stub_hit_body
This commit is contained in:
parent
70b4b6fea0
commit
fc86dd713a
1 changed files with 6 additions and 9 deletions
|
@ -1396,13 +1396,12 @@ c_callable! {
|
||||||
/// instructions, so this should be used primarily for cb.has_dropped_bytes() situations.
|
/// instructions, so this should be used primarily for cb.has_dropped_bytes() situations.
|
||||||
fn function_stub_hit(iseq: IseqPtr, branch_ptr: *const c_void, ec: EcPtr, sp: *mut VALUE) -> *const u8 {
|
fn function_stub_hit(iseq: IseqPtr, branch_ptr: *const c_void, ec: EcPtr, sp: *mut VALUE) -> *const u8 {
|
||||||
with_vm_lock(src_loc!(), || {
|
with_vm_lock(src_loc!(), || {
|
||||||
/// gen_push_frame() doesn't set PC and SP, so we need to set them before exit
|
// gen_push_frame() doesn't set PC and SP, so we need to set them before exit.
|
||||||
fn set_pc_and_sp(iseq: IseqPtr, ec: EcPtr, sp: *mut VALUE) {
|
// function_stub_hit_body() may allocate and call gc_validate_pc(), so we always set PC.
|
||||||
let cfp = unsafe { get_ec_cfp(ec) };
|
let cfp = unsafe { get_ec_cfp(ec) };
|
||||||
let pc = unsafe { rb_iseq_pc_at_idx(iseq, 0) }; // TODO: handle opt_pc once supported
|
let pc = unsafe { rb_iseq_pc_at_idx(iseq, 0) }; // TODO: handle opt_pc once supported
|
||||||
unsafe { rb_set_cfp_pc(cfp, pc) };
|
unsafe { rb_set_cfp_pc(cfp, pc) };
|
||||||
unsafe { rb_set_cfp_sp(cfp, sp) };
|
unsafe { rb_set_cfp_sp(cfp, sp) };
|
||||||
}
|
|
||||||
|
|
||||||
// If we already know we can't compile the ISEQ, fail early without cb.mark_all_executable().
|
// If we already know we can't compile the ISEQ, fail early without cb.mark_all_executable().
|
||||||
// TODO: Alan thinks the payload status part of this check can happen without the VM lock, since the whole
|
// TODO: Alan thinks the payload status part of this check can happen without the VM lock, since the whole
|
||||||
|
@ -1411,7 +1410,6 @@ c_callable! {
|
||||||
let payload = get_or_create_iseq_payload(iseq);
|
let payload = get_or_create_iseq_payload(iseq);
|
||||||
if cb.has_dropped_bytes() || payload.status == IseqStatus::CantCompile {
|
if cb.has_dropped_bytes() || payload.status == IseqStatus::CantCompile {
|
||||||
// Exit to the interpreter
|
// Exit to the interpreter
|
||||||
set_pc_and_sp(iseq, ec, sp);
|
|
||||||
return ZJITState::get_exit_code().raw_ptr(cb);
|
return ZJITState::get_exit_code().raw_ptr(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,7 +1419,6 @@ c_callable! {
|
||||||
code_ptr
|
code_ptr
|
||||||
} else {
|
} else {
|
||||||
// Exit to the interpreter
|
// Exit to the interpreter
|
||||||
set_pc_and_sp(iseq, ec, sp);
|
|
||||||
ZJITState::get_exit_code()
|
ZJITState::get_exit_code()
|
||||||
};
|
};
|
||||||
cb.mark_all_executable();
|
cb.mark_all_executable();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue