Skip to content

Commit 1c43f7e

Browse files
committed
ZJIT: Parse opt_and into HIR
1 parent 4a2480e commit 1c43f7e

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
@@ -219,6 +219,13 @@ def test(obj) = obj.succ
219219
RUBY
220220
end
221221

222+
def test_opt_and
223+
assert_compiles('[1, [3, 2, 1]]', <<~RUBY, insns: [:opt_and])
224+
def test(x, y) = x & y
225+
return test(0b1101, 3), test([3, 2, 1, 4], [8, 1, 2, 3])
226+
RUBY
227+
end
228+
222229
def test_opt_ge
223230
assert_compiles '[false, true, true]', %q{
224231
def test(a, b) = a >= b

zjit/src/hir.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
23772377
YARVINSN_opt_aref |
23782378
YARVINSN_opt_empty_p |
23792379
YARVINSN_opt_succ |
2380+
YARVINSN_opt_and |
23802381
YARVINSN_opt_send_without_block => {
23812382
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
23822383
let call_info = unsafe { rb_get_call_data_ci(cd) };
@@ -3837,6 +3838,19 @@ mod tests {
38373838
Return v4
38383839
"#]]);
38393840
}
3841+
3842+
#[test]
3843+
fn opt_and() {
3844+
eval("
3845+
def test(x, y) = x & y
3846+
");
3847+
assert_method_hir_with_opcode("test", YARVINSN_opt_and, expect![[r#"
3848+
fn test:
3849+
bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject):
3850+
v5:BasicObject = SendWithoutBlock v1, :&, v2
3851+
Return v5
3852+
"#]]);
3853+
}
38403854
#[test]
38413855
fn test_branchnil() {
38423856
eval("

0 commit comments

Comments
 (0)