Skip to content

Handle varargs frame on arity error in jitted code#6771

Merged
headius merged 1 commit intojruby:jruby-9.2from
headius:fix_jit_argumenterror_trace
Aug 5, 2021
Merged

Handle varargs frame on arity error in jitted code#6771
headius merged 1 commit intojruby:jruby-9.2from
headius:fix_jit_argumenterror_trace

Conversation

@headius
Copy link
Member

@headius headius commented Aug 5, 2021

This PR contains fixes for ArgumentError backtrace when crossing into jitted methods.

Fixes #6335.

May improve #5103.

Jitted code handles arity-checking differently than in the
interpreter. Where the interpreter always pushed a backtrace
element before the arity check, the JVM does the arity-check in a
separately-generated varargs wrapper (if the method is specific-
arity) or before setting a line number (if the method is variable-
arity). This has the effect of either omitting the error frame
altogether (specific) or having the line number be -1 (variable).

This commit makes the following modifications to allow the arity
error line to be shown in jitted code:

* Set the current line number immediately upon creating the method
  so that it is set in the JVM before the arity check.
* Process jitted method names with the varargs marker if they were
  not preceded by the actual method body. The varargs-marked
  method can only appear on its own or immediately after the real
  jitted method body.

This fixes all known cases where the argument error line is
omitted or not set properly in the JVM trace.

In addition, this patch moves the management of the current line
number into the IRBytecodeAdapter, rather than maintaining it in
the JVMVisitor instance.

Fixes jruby#6335.

This may also improve the case described in jruby#5103, since all JVM
frames will have proper line numbers at the point of error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArgumentError is reported at wrong level for some jitted methods

1 participant