Skip to content
Permalink
Browse files
Fix defined?(::Object) logic in JIT. Partial fix for #2090.
The current IR for this logic uses the runtime helper call
isDefinedConstantOrMethod, which can trigger exceptions on its own
(if e.g. the method lookup triggers an error?). Because of that
handler, this bug in the JIT was caught and swallowed, resulting
in the defined? returning nil. That is not correct behavior; only
the exceptions we would expect to be raised by these lookups
should be caught.

In addition, I don't believe the :: form can be used to call
methods (::foo doesn't parse), so the use of exception handling
and isDefinedConstOrMethod may be inappropriate here.
  • Loading branch information
headius committed Nov 4, 2014
1 parent 0e4c83c commit c3b80aa0f9f1572e5b5c76cf6dc585a9f90c1b02
Showing 2 changed files with 7 additions and 2 deletions.
@@ -1573,10 +1573,9 @@ public void RuntimeHelperCall(RuntimeHelperCall runtimehelpercall) {
break;
case IS_DEFINED_CONSTANT_OR_METHOD:
jvmMethod().loadContext();
jvmMethod().loadSelf();
visit(runtimehelpercall.getArgs()[0]);
jvmAdapter().ldc(((StringLiteral)runtimehelpercall.getArgs()[1]).getString());
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "isDefinedConstantOrMethod", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class));
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "isDefinedConstantOrMethod", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, String.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
case IS_DEFINED_NTH_REF:
@@ -866,4 +866,10 @@ class JRUBY4925
expect(x).to eq Object
end
end

it "retrieves toplevel constants with ::Const form" do
run '::Object' do |x|
expect(x).to eq Object
end
end
end

0 comments on commit c3b80aa

Please sign in to comment.