Skip to content

Indy call sites are not setting up frame for core methods #3842

@headius

Description

@headius

Environment

JRuby 9k, all versions up through 9.1.

Expected Behavior

Methods like Range#include? do a Ruby super under some circumstances to delegate to a parent class. This is done from Java, which requires that calls to these methods set up a frame (indicated by frame = true in the JRubyMethod annotation).

Actual Behavior

It seems that indy call sites are not setting up frames for methods that require it. We attempt to bind directly to the Java method for native core methods, which means bypassing the logic in the DynamicMethod that would push and pop a frame. In JRuby 1.7, we would see the target needed a frame and wrap it with framing logic. In 9k, this logic seems to have been missed, probably because all our jitted Ruby methods set up their own frames now (or this would have shown up much sooner).

The benchmark provided in #3841 is enough to trigger the error. Here is is for reference. I have not come up with a smaller reproduction.

$ jruby -Xcompile.invokedynamic blah.rb
Warming up --------------------------------------
        range#cover?    60.892k i/100ms
      range#include?NoMethodError: super called outside of method
             include? at org/jruby/RubyRange.java:630
     block in blah.rb at blah.rb:10
           call_times at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/benchmark-ips-2.6.1/lib/benchmark/ips/job/entry.rb:53
  block in run_warmup at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/benchmark-ips-2.6.1/lib/benchmark/ips/job.rb:205
                 each at org/jruby/RubyArray.java:1593
           run_warmup at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/benchmark-ips-2.6.1/lib/benchmark/ips/job.rb:191
         block in run at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/benchmark-ips-2.6.1/lib/benchmark/ips/job.rb:172
                times at org/jruby/RubyFixnum.java:291
                  run at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/benchmark-ips-2.6.1/lib/benchmark/ips/job.rb:171
                  ips at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/benchmark-ips-2.6.1/lib/benchmark/ips.rb:57
                <top> at blah.rb:8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions