8000 ZJIT: Pass self through basic block params by k0kubun · Pull Request #13529 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

ZJIT: Pass self through basic block params #13529

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use self_param for ivar
  • Loading branch information
k0kubun committed Jun 5, 2025
commit 2e3f4b2863de9f5cefd09e978a8eb9d99fe38543
26 changes: 12 additions & 14 deletions zjit/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2398,17 +2398,15 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
let id = ID(get_arg(pc, 0).as_u64());
// ic is in arg 1
let exit_id = fun.push_insn(block, Insn::Snapshot { state: exit_state });
let self_val = fun.push_insn(block, Insn::Param { idx: SELF_PARAM_IDX });
let result = fun.push_insn(block, Insn::GetIvar { self_val, id, state: exit_id });
let result = fun.push_insn(block, Insn::GetIvar { self_val: self_param, id, state: exit_id });
state.stack_push(result);
}
YARVINSN_setinstancevariable => {
let id = ID(get_arg(pc, 0).as_u64());
// ic is in arg 1
let exit_id = fun.push_insn(block, Insn::Snapshot { state: exit_state });
let self_val = fun.push_insn(block, Insn::Param { idx: SELF_PARAM_IDX });
let val = state.stack_pop()?;
fun.push_insn(block, Insn::SetIvar { self_val, id, val, state: exit_id });
fun.push_insn(block, Insn::SetIvar { self_val: self_param, id, val, state: exit_id });
}
YARVINSN_newrange => {
let flag = RangeType::from(get_arg(pc, 0).as_u32());
Expand Down Expand Up @@ -3619,9 +3617,9 @@ mod tests {
");
assert_method_hir_with_opcode("test", YARVINSN_getinstancevariable, expect![[r#"
fn test:
bb0(v0:BasicObject, v3):
v4:BasicObject = GetIvar v3, :@foo
Return v4
bb0(v0:BasicObject):
v3:BasicObject = GetIvar v0, :@foo
Return v3
"#]]);
}

Expand All @@ -3633,9 +3631,9 @@ mod tests {
");
assert_method_hir_with_opcode("test", YARVINSN_setinstancevariable, expect![[r#"
fn test:
bb0(v0:BasicObject, v4):
bb0(v0:BasicObject):
v2:Fixnum[1] = Const Value(1)
SetIvar v4, :@foo, v2
SetIvar v0, :@foo, v2
Return v2
"#]]);
}
Expand Down Expand Up @@ -5076,9 +5074,9 @@ mod opt_tests {
");
assert_optimized_method_hir("test", expect![[r#"
fn test:
bb0(v0:BasicObject, v3):
v4:BasicObject = GetIvar v3, :@foo
Return v4
bb0(v0:BasicObject):
v3:BasicObject = GetIvar v0, :@foo
Return v3
"#]]);
}

Expand All @@ -5089,9 +5087,9 @@ mod opt_tests {
");
assert_optimized_method_hir("test", expect![[r#"
fn test:
bb0(v0:BasicObject, v4):
bb0(v0:BasicObject):
v2:Fixnum[1] = Const Value(1)
SetIvar v4, :@foo, v2
SetIvar v0, :@foo, v2
Return v2
"#]]);
}
Expand Down
Loading
0