Skip to content

Methods that do not bind directly with invokedynamic #5246

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

Open
2 of 6 tasks
headius opened this issue Jul 12, 2018 · 2 comments
Open
2 of 6 tasks

Methods that do not bind directly with invokedynamic #5246

headius opened this issue Jul 12, 2018 · 2 comments

Comments

@headius
Copy link
Member

headius commented Jul 12, 2018

With the reboot of the JRuby runtime in 9k, we lost some of the invokedynamic logic to bind directly through to method bodies. These cases reverted to "indirect" binding via the DynamicMethod.call path, since their unique call logic did not have an equivalent in the new JIT.

I have been fixing some of these, like Ruby to Java calls and aliased methods, but several remain. I list them here.

I also committed a change adding indirect binding warnings to the debug output from invokedynamic bindings.

  • define_method methods, both those that have been converted into "simple" methods and those that remain a proc.call (affects class attributes and some delegating logic in Rails)
  • Java method arities after the lowest one, varargs logic, and all Java calls that pass a block for closure conversion
  • Variable-arity native methods in core classes, for arities beyond the first defined (affects at least send calls in Rails)
  • Dynamic dispatch methods like send do not create a double call site and will never inline, even for a single target. (affects send calls in Rails, obviously)
  • Struct accessors (affects a number of data objects in Rails)
  • Methods that receive keyword args, due to the need to frobnicate
headius added a commit that referenced this issue Jul 12, 2018

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
Ideally we need to slim down or eliminate the frobnicate logic,
since it's over complex and likely will limit the inlining
potential of these call sites.

See #5246.
headius added a commit that referenced this issue Jul 12, 2018

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
* Match wording for directly bound jitted methods
* Use method location for printing out method's impl class
* Log when a native method failed to bind directly due to arity

See related work in #5246.
@headius
Copy link
Member Author

headius commented Jul 12, 2018

Kwargs methods now bind directly (0a7419a) by folding in the frobnicated args list. This is a fairly complex set of method handles on top of the already complex frobnication process, but it does appear to help performance of a def foo(a:1) method dispatch by roughly 18% (hot loop on graal went from 0.37s to 0.32s).

headius added a commit that referenced this issue Jul 12, 2018

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
Only the "natural" arities for getters and setters are supported.
@headius
Copy link
Member Author

headius commented Jul 12, 2018

Struct accessors and mutators now bind directly to the RubyStruct methods (8555df3). RubyStruct still needs specialization work, likely based on how we are specializing Object subclasses for instance variables.

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

No branches or pull requests

1 participant