diff options
author | Max Bernstein <[email protected]> | 2025-05-23 15:05:19 -0400 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2025-05-23 16:31:28 -0700 |
commit | fa474a41e809822579bf8db6bbcb036a07c03774 (patch) | |
tree | 522d81528dc1cd370ef0325bcc4ffa8c057ecf41 /zjit/src | |
parent | 5905f71a3406dc60ccc3a3c9bf6159d9113808ee (diff) |
ZJIT: Parse opt_aref into HIR
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13432
Diffstat (limited to 'zjit/src')
-rw-r--r-- | zjit/src/hir.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index b54c068166..91ddb3a022 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -2191,6 +2191,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> { YARVINSN_opt_aset | YARVINSN_opt_length | YARVINSN_opt_size | + YARVINSN_opt_aref | 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) }; @@ -3479,6 +3480,34 @@ mod tests { Return v3 "#]]); } + + #[test] + fn test_aset() { + eval(" + def test(a, b) = a[b] = 1 + "); + assert_method_hir("test", expect![[r#" + fn test: + bb0(v0:BasicObject, v1:BasicObject): + v3:NilClassExact = Const Value(nil) + v4:Fixnum[1] = Const Value(1) + v6:BasicObject = SendWithoutBlock v0, :[]=, v1, v4 + Return v4 + "#]]); + } + + #[test] + fn test_aref() { + eval(" + def test(a, b) = a[b] + "); + assert_method_hir("test", expect![[r#" + fn test: + bb0(v0:BasicObject, v1:BasicObject): + v4:BasicObject = SendWithoutBlock v0, :[], v1 + Return v4 + "#]]); + } } #[cfg(test)] |