[Painless] Generate Bridge Methods#36097
Merged
jdconrad merged 12 commits intoelastic:masterfrom Dec 7, 2018
Merged
Conversation
Collaborator
|
Pinging @elastic/es-core-infra |
rjernst
approved these changes
Dec 5, 2018
| } | ||
| } | ||
|
|
||
| private void generateRuntimeMethods() { |
Member
There was a problem hiding this comment.
can we use a more descriptive name for these methods? "runtime" is very generic. eg maybe "casting bridge methods" or something like that?
Contributor
Author
There was a problem hiding this comment.
So this is actually runtime methods. I added a fairly in-depth description as a Javadoc for what this method is creating and what happens with the result.
Contributor
Author
|
@rjernst Thanks for the review! Will commit as soon as CI is complete. |
jdconrad
added a commit
that referenced
this pull request
Dec 7, 2018
We use MethodHandles.asType to cast argument types into the appropriate parameter types for method calls when the target of the call is a def type at runtime. Currently, certain implicit casts using the def type are asymmetric. It is possible to cast Integer -> float as an argument to parameter, but not from int -> Float (boxed to primitive with upcasting is okay, but primitive to boxed with upcasting is not). This PR introduces a solution to the issue by generating bridge methods for all whitelisted methods that have at least a single boxed type as an argument. The bridge method will conduct appropriate casts and then call the original method. This adds a bit of overhead for correctness. It should not be used often as Painless avoids boxed types as much as possible. Note that a large portion of this change is adding methods to do the appropriate def to boxed type casts and a few mechanical changes as well. The most important method for review is generateBridgeMethod in PainlessLookupBuilder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We use MethodHandles.asType to cast argument types into the appropriate parameter types for method calls when the target of the call is a
deftype at runtime. Currently, certain implicit casts using thedeftype are asymmetric. It is possible to castInteger->floatas an argument to parameter, but not fromint->Float(boxed to primitive with upcasting is okay, but primitive to boxed with upcasting is not).This PR introduces a solution to the issue by generating bridge methods for all whitelisted methods that have at least a single boxed type as an argument. The bridge method will conduct appropriate casts and then call the original method. This adds a bit of overhead for correctness. It should not be used often as Painless avoids boxed types as much as possible.
Note that a large portion of this change is adding methods to do the appropriate def to boxed type casts and a few mechanical changes as well. The most important method for review is generateBridgeMethod in PainlessLookupBuilder.