-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8299570: [JVMCI] Insufficient error handling when CodeBuffer is exhausted #11945
Changes from 1 commit
7f1d45a
0e4fb65
8e85e3d
9b1d1fb
d723563
92bcac5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -532,21 +532,20 @@ void NativeCallTrampolineStub::set_destination(address new_destination) { | |
void NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest, JVMCI_TRAPS) { | ||
MacroAssembler a(&cbuf); | ||
|
||
if (a.far_branches()) { | ||
if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { | ||
address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); | ||
if (stub == nullptr) { | ||
JVMCI_ERROR("could not emit trampoline stub - code cache is full"); | ||
} | ||
// The relocation is created while emitting the stub will ensure this | ||
// call instruction is subsequently patched to call the stub. | ||
} else { | ||
// Not sure how this can be happen but be defensive | ||
JVMCI_ERROR("single-use stub should not exist"); | ||
} | ||
} else { | ||
if (!a.far_branches()) { | ||
// If not using far branches, patch this call directly to dest. | ||
set_destination(dest); | ||
} else if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { | ||
// If we want far branches and there isn't a trampoline stub, emit one. | ||
address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); | ||
if (stub == nullptr) { | ||
JVMCI_ERROR("could not emit trampoline stub - code cache is full"); | ||
} | ||
// The relocation created while emitting the stub will ensure this | ||
// call instruction is subsequently patched to call the stub. | ||
} else { | ||
// Not sure how this can be happen but be defensive | ||
JVMCI_ERROR("single-use stub should not exist"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if (stub == null) test below should be the else branch of this if which I think makes it clearer. Why do we even bother returning the stub? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm suspecting this is indeed a dormant bug. I will investigate further. @theRealAph any chance you recall the intended logic here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've pushed 0e4fb65 which attempts to clear up the logic in this method. It would be great if some aarch64 experts could help review it (cc @adinn @theRealAph). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dougxc I'm not sure why the above code is written the way it is rather than the way you rewrote it. I cannot see any reason why there should already be a trampoline stub in place when trampoline_jump is called given how it is being called at present. I thought perhaps it might be something to do with the (newly introduced) shared trampoline code but that is not relevant here and, besides, this routine has been thew way it is since it was first introduced. I know the trampoline (and related far jump) code has been subject to change over the years so it may be something to do with how this routine was called in an earlier incarnation of the code. Andrew Haley will have a better idea than me as he was the original author. Anyway, if we may need far branches and the call to is_NativeCallTrampolineStub_at fails then it does not seem tome to make any sense to call set_destination (at least null is returned which is correct). So, I think your rewrite looks like it is doing the right thing. I think you probably need an ok from Andrew Haley here though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, thanks for your input. I'll wait for @theRealAph to review it as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theRealAph @adinn can I now merge this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dougxc Still ok with me. I just pinged Andrew Haley to see if he is ok with it. |
||
} | ||
#endif | ||
|
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 is all very complicated. Can't we just add
JVMCI_ERROR
s where we need them?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'm not following - isn't this exactly what the code is doing? Maybe you could demonstrate how you think it should look.
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.
Maybe it would be nicer to get the
! far_branches
code path out of the way first, and return immediately.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.
Something like this?
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.
Yes. Or maybe
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.
Done.