Skip to content

Commit 4a2480e

Browse files
committed
ZJIT: Parse opt_succ into HIR
1 parent 9865aa9 commit 4a2480e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

test/ruby/test_zjit.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ def test(x) = x.empty?
212212
RUBY
213213
end
214214

215+
def test_opt_succ
216+
assert_compiles('[0, "B"]', <<~RUBY, insns: [:opt_succ])
217+
def test(obj) = obj.succ
218+
return test(-1), test("A")
219+
RUBY
220+
end
221+
215222
def test_opt_ge
216223
assert_compiles '[false, true, true]', %q{
217224
def test(a, b) = a >= b

zjit/src/hir.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
23762376
YARVINSN_opt_size |
23772377
YARVINSN_opt_aref |
23782378
YARVINSN_opt_empty_p |
2379+
YARVINSN_opt_succ |
23792380
YARVINSN_opt_send_without_block => {
23802381
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
23812382
let call_info = unsafe { rb_get_call_data_ci(cd) };
@@ -3824,6 +3825,18 @@ mod tests {
38243825
"#]]);
38253826
}
38263827

3828+
#[test]
3829+
fn opt_succ() {
3830+
eval("
3831+
def test(x) = x.succ
3832+
");
3833+
assert_method_hir_with_opcode("test", YARVINSN_opt_succ, expect![[r#"
3834+
fn test:
3835+
bb0(v0:BasicObject, v1:BasicObject):
3836+
v4:BasicObject = SendWithoutBlock v1, :succ
3837+
Return v4
3838+
"#]]);
3839+
}
38273840
#[test]
38283841
fn test_branchnil() {
38293842
eval("

0 commit comments

Comments
 (0)