-
Notifications
You must be signed in to change notification settings - Fork 767
Pop extra args on BootstrapMethodError for invokedynamic #21720
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
Pop extra args on BootstrapMethodError for invokedynamic #21720
Conversation
390d85c
to
2cd5462
Compare
2cd5462
to
3ecd2b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some typos at end of the commit message:
all the
arguemnts→ arguments and popsthen→ themaccordinly→ accordingly.
I see that you've already corrected them in the PR description
dda7f01
to
da57af0
Compare
Thanks @jdmpapin , I've made the requested changes. Can I get another review please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it works properly now. Just a couple of formatting comments, and the "arguemnts" typo is still there in the commit message
da57af0
to
e8af1a6
Compare
When an error is caught during resolveInvokeDynamic (MethodHandleResolver.java), a MethodHandle that throws a BootstrapMethodError is returned, which has no arguments. This can cause an issue for OSR where we run out of pending push temp slots since we are not popping all the args off the operand stack. This commit recognizes when we have not popped all the arguments and pops them accordingly. Fixes: eclipse-openj9#21419 Signed-off-by: Matthew Hall <[email protected]>
e8af1a6
to
743a0ce
Compare
@hzongaro, could you please review as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the changes look good. I had some cosmetic comments, but I don't want them to hold up the fix; I will approve this change and ask you to address them when you have the opportunity.
@@ -149,14 +149,15 @@ class TR_J9ByteCodeIlGenerator : public TR_IlGenerator, public TR_J9ByteCodeIter | |||
|
|||
bool runMacro(TR::SymbolReference *); | |||
bool runFEMacro(TR::SymbolReference *); | |||
TR::Node * genInvoke(TR::SymbolReference *, TR::Node *indirectCallFirstChild, TR::Node *invokedynamicReceiver = NULL); | |||
TR::Node * genInvoke(TR::SymbolReference *, TR::Node *indirectCallFirstChild, TR::Node *invokedynamicReceiver = NULL, int32_t numExpectedArgs = -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to add Doxygen comments for this method? I know it's not a new method, but hopefully over time we can get broader coverage.
|
||
TR::Node * genInvokeDirect(TR::SymbolReference *symRef){ return genInvoke(symRef, NULL); } | ||
TR::Node * genInvokeDirect(TR::SymbolReference *symRef, int32_t numExpectedArgs = -1){ return genInvoke(symRef, NULL, NULL, numExpectedArgs); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, may I ask you to add Doxygen comments for this method?
@@ -3200,6 +3200,29 @@ static char *suffixedName(char *baseName, char typeSuffix, char *buf, int32_t bu | |||
return methodName; | |||
} | |||
|
|||
static int32_t countParams(unsigned char *sig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to add Doxygen comments for this method?
/* We need to get the expected number of parameters from the signature. There is a case where findOrCreateDynamicMethodSymbol() | ||
* returns an error-throwing MethodHandle that takes 0 arguments (occurs when an error is caught during resolveInvokeDynamic()). We cannot use | ||
* TR::Method::numberOfExplicitParameters() since that fetches the number of parameters of targetMethodSymRefs (the MH actually returned) | ||
* instead of whats expected the invokedynamic call. This can be a problem since the expcected of args are already on the stack and won't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos:
- "whats expected the invokedynamic" -> "what's expected for the invokedynamic"
- "expcected" -> "expected"
if (numPopped < numExpectedArgs) | ||
{ | ||
if (comp()->getOption(TR_TraceILGen)) | ||
traceMsg(comp(), "InvokeDynamic recieved error throwing MethodHandle. Popping extra args.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "recieved" -> "received"
Jenkins test sanity.functional,sanity.openjdk all jdk17,jdk21 |
Testing completed successful and reviews approved. Merging. |
This seems to be causing crashes on jdk8, reverting it via #21902 |
@matthewhall2, I'm guessing the extra popping was kicking in when it shouldn't. If that's the case, it should be possible to fix it by only doing extra pops when
and then later on we can restrict the condition for popping:
|
When an error is caught during resolveInvokeDynamic (MethodHandleResolver.java), a MethodHandle that throws a BootstrapMethodError is returned, which has no arguments. This can cause an issue for OSR where we run out of pending push temp slots during OSR BookKeeping since we are not popping all the args off the operand stack.
This change recognizes when we have not popped all the arguments and pops them accordingly
Fixes: #21419