Skip to content

Commit 038087a

Browse files
committed
ZJIT: Parse opt_or into HIR
1 parent 1c43f7e commit 038087a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

test/ruby/test_zjit.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ def test(x, y) = x & y
226226
RUBY
227227
end
228228

229+
def test_opt_or
230+
assert_compiles('[11, [3, 2, 1]]', <<~RUBY, insns: [:opt_or])
231+
def test(x, y) = x | y
232+
return test(0b1000, 3), test([3, 2, 1], [1, 2, 3])
233+
RUBY
234+
end
235+
229236
def test_opt_ge
230237
assert_compiles '[false, true, true]', %q{
231238
def test(a, b) = a >= b

zjit/src/hir.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
23782378
YARVINSN_opt_empty_p |
23792379
YARVINSN_opt_succ |
23802380
YARVINSN_opt_and |
2381+
YARVINSN_opt_or |
23812382
YARVINSN_opt_send_without_block => {
23822383
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
23832384
let call_info = unsafe { rb_get_call_data_ci(cd) };
@@ -3851,6 +3852,19 @@ mod tests {
38513852
Return v5
38523853
"#]]);
38533854
}
3855+
3856+
#[test]
3857+
fn opt_or() {
3858+
eval("
3859+
def test(x, y) = x | y
3860+
");
3861+
assert_method_hir_with_opcode("test", YARVINSN_opt_or, expect![[r#"
3862+
fn test:
3863+
bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject):
3864+
v5:BasicObject = SendWithoutBlock v1, :|, v2
3865+
Return v5
3866+
"#]]);
3867+
}
38543868
#[test]
38553869
fn test_branchnil() {
38563870
eval("

0 commit comments

Comments
 (0)