Skip to content

ZJIT: Parse a few more opt_*, CALL_SIMPLE_METHOD opcodes #13549

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 6 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
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
ZJIT: Parse opt_succ into HIR
  • Loading branch information
XrXr committed Jun 9, 2025
commit 15723230c93bb3f03d7bf5e289b56558c9cfbad2
7 changes: 7 additions & 0 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ def test(x) = x.empty?
RUBY
end

def test_opt_succ
assert_compiles('[0, "B"]', <<~RUBY, insns: [:opt_succ])
def test(obj) = obj.succ
return test(-1), test("A")
RUBY
end

def test_opt_ge
assert_compiles '[false, true, true]', %q{
def test(a, b) = a >= b
Expand Down
13 changes: 13 additions & 0 deletions zjit/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2376,6 +2376,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
YARVINSN_opt_size |
YARVINSN_opt_aref |
YARVINSN_opt_empty_p |
YARVINSN_opt_succ |
YARVINSN_opt_send_without_block => {
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
let call_info = unsafe { rb_get_call_data_ci(cd) };
Expand Down Expand Up @@ -3824,6 +3825,18 @@ mod tests {
"#]]);
}

#[test]
fn opt_succ() {
eval("
def test(x) = x.succ
");
assert_method_hir_with_opcode("test", YARVINSN_opt_succ, expect![[r#"
fn test:
bb0(v0:BasicObject, v1:BasicObject):
v4:BasicObject = SendWithoutBlock v1, :succ
Return v4
"#]]);
}
#[test]
fn test_branchnil() {
eval("
Expand Down