Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JRuby 9k JIT breaks defined? #2090

Closed
nirvdrum opened this issue Nov 4, 2014 · 3 comments
Closed

JRuby 9k JIT breaks defined? #2090

nirvdrum opened this issue Nov 4, 2014 · 3 comments
Assignees
Labels

Comments

@nirvdrum
Copy link
Contributor

nirvdrum commented Nov 4, 2014

I ran into an issue where defined? stops working properly with JIT enabled in JRuby 9k. The following simple script is enough to illustrate the problem:

X = true

1000.times do
  raise 'X undefined' unless defined?(::X)
end

puts 'Success'

With JIT disabled, "Succes" will be printed to the screen. With it enabled, I see the following:

RuntimeError: X undefined
  jit_defined_bug.rb_CLOSURE_1__jit_defined_bug.rb_0 at jit_defined_bug.rb:4
                                               times at org/jruby/RubyFixnum.java:296
                                          __script__ at jit_defined_bug.rb:3

Ruby version:

$ ruby -v
jruby 9000.dev-SNAPSHOT (2.1.2p142) 2014-11-04 dc55205 Java HotSpot(TM) 64-Bit Server VM 25.25-b02 on 1.8.0_25-b17 +jit [linux-amd64]
@nirvdrum
Copy link
Contributor Author

nirvdrum commented Nov 4, 2014

It appears defined?(X) (rather than defined?(::X)) is not susceptible to the problem.

headius added a commit that referenced this issue Nov 4, 2014
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.
@headius headius added the jit label Nov 4, 2014
@headius headius added this to the JRuby 9000 milestone Nov 4, 2014
@headius headius self-assigned this Nov 4, 2014
@headius
Copy link
Member

headius commented Nov 4, 2014

There's a fix in for the failure in JIT, but additional work is needed on the IR.

@headius headius added ir and removed jit labels Nov 6, 2014
@headius
Copy link
Member

headius commented Jan 15, 2015

We can't remember or determine what's actually needed to "finish" this, so we're going to close it. The fix in place is simple and works, and if any defined? bugs remain they'd need to be fixed in IR first anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants