Skip to content

Commit ec1244c

Browse files
committed
ZJIT: Parse opt_not into HIR
1 parent 038087a commit ec1244c

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
@@ -233,6 +233,13 @@ def test(x, y) = x | y
233233
RUBY
234234
end
235235

236+
def test_opt_not
237+
assert_compiles('[true, true, false]', <<~RUBY, insns: [:opt_not])
238+
def test(obj) = !obj
239+
return test(nil), test(false), test(0)
240+
RUBY
241+
end
242+
236243
def test_opt_ge
237244
assert_compiles '[false, true, true]', %q{
238245
def test(a, b) = a >= b

zjit/src/hir.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
23792379
YARVINSN_opt_succ |
23802380
YARVINSN_opt_and |
23812381
YARVINSN_opt_or |
2382+
YARVINSN_opt_not |
23822383
YARVINSN_opt_send_without_block => {
23832384
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
23842385
let call_info = unsafe { rb_get_call_data_ci(cd) };
@@ -3865,6 +3866,19 @@ mod tests {
38653866
Return v5
38663867
"#]]);
38673868
}
3869+
3870+
#[test]
3871+
fn opt_not() {
3872+
eval("
3873+
def test(x) = !x
3874+
");
3875+
assert_method_hir_with_opcode("test", YARVINSN_opt_not, expect![[r#"
3876+
fn test:
3877+
bb0(v0:BasicObject, v1:BasicObject):
3878+
v4:BasicObject = SendWithoutBlock v1, :!
3879+
Return v4
3880+
"#]]);
3881+
}
38683882
#[test]
38693883
fn test_branchnil() {
38703884
eval("

0 commit comments

Comments
 (0)