summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_zjit.rb23
-rw-r--r--zjit/src/hir.rs6
-rw-r--r--zjit/src/stats.rs2
3 files changed, 23 insertions, 8 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index c11f7bfa9a..98f747c4d0 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -1355,6 +1355,29 @@ class TestZJIT < Test::Unit::TestCase
}, insns: [:defined]
end
+ def test_defined_method_raise
+ assert_compiles '[nil, nil, nil]', %q{
+ class C
+ def assert_equal expected, actual
+ if expected != actual
+ raise "NO"
+ end
+ end
+
+ def test_defined_method
+ assert_equal(nil, defined?("x".reverse(1).reverse))
+ end
+ end
+
+ c = C.new
+ result = []
+ result << c.test_defined_method
+ result << c.test_defined_method
+ result << c.test_defined_method
+ result
+ }
+ end
+
def test_defined_yield
assert_compiles "nil", "defined?(yield)"
assert_compiles '[nil, nil, "yield"]', %q{
diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs
index 1628e049cc..fd19edaf04 100644
--- a/zjit/src/hir.rs
+++ b/zjit/src/hir.rs
@@ -431,7 +431,6 @@ pub enum SideExitReason {
UnknownNewarraySend(vm_opt_newarray_send_type),
UnknownCallType,
UnknownSpecialVariable(u64),
- UnhandledDefinedType(usize),
UnhandledHIRInsn(InsnId),
UnhandledYARVInsn(u32),
FixnumAddOverflow,
@@ -3049,11 +3048,6 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
let pushval = get_arg(pc, 2);
let v = state.stack_pop()?;
let exit_id = fun.push_insn(block, Insn::Snapshot { state: exit_state });
- if op_type == DEFINED_METHOD.try_into().unwrap() {
- // TODO(Shopify/ruby#703): Fix codegen for defined?(method call expr)
- fun.push_insn(block, Insn::SideExit { state: exit_id, reason: SideExitReason::UnhandledDefinedType(op_type)});
- break; // End the block
- }
state.stack_push(fun.push_insn(block, Insn::Defined { op_type, obj, pushval, v, state: exit_id }));
}
YARVINSN_definedivar => {
diff --git a/zjit/src/stats.rs b/zjit/src/stats.rs
index 03a4a037d4..64bef8ca6a 100644
--- a/zjit/src/stats.rs
+++ b/zjit/src/stats.rs
@@ -87,7 +87,6 @@ make_counters! {
exit_unknown_newarray_send,
exit_unknown_call_type,
exit_unknown_special_variable,
- exit_unhandled_defined_type,
exit_unhandled_hir_insn,
exit_unhandled_yarv_insn,
exit_fixnum_add_overflow,
@@ -145,7 +144,6 @@ pub fn exit_counter_ptr(reason: crate::hir::SideExitReason) -> *mut u64 {
UnknownNewarraySend(_) => exit_unknown_newarray_send,
UnknownCallType => exit_unknown_call_type,
UnknownSpecialVariable(_) => exit_unknown_special_variable,
- UnhandledDefinedType(_) => exit_unhandled_defined_type,
UnhandledHIRInsn(_) => exit_unhandled_hir_insn,
UnhandledYARVInsn(_) => exit_unhandled_yarv_insn,
FixnumAddOverflow => exit_fixnum_add_overflow,