-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8303951: Add asserts before record_method_not_compilable where possible #13038
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
Conversation
👋 Welcome back epeter! A progress list of the required criteria for merging this PR into |
@eme64 this pull request can not be integrated into git checkout JDK-8303951
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
Webrevs
|
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.
General suggestion is to print more info on bailouts to help debugging.
@@ -2277,7 +2277,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) { | |||
DirectivesStack::release(directive); | |||
|
|||
if (!ci_env.failing() && !task->is_success()) { | |||
//assert(false, "compiler should always document failure"); | |||
assert(false, "compiler should always document failure"); |
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 suggest to add ci_env.failure_reason()
to assert message.
@@ -251,6 +251,7 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i | |||
|
|||
// Check for a legal reg name in the oopMap and bailout if it is not. | |||
if (!omap->legal_vm_reg_name(r)) { | |||
assert(false, "illegal oopMap register name"); |
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.
Added information about r
to assert message.
@@ -318,6 +319,7 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i | |||
assert( !OptoReg::is_valid(_callees[reg]), "oop can't be callee save" ); | |||
// Check for a legal reg name in the oopMap and bailout if it is not. | |||
if (!omap->legal_vm_reg_name(r)) { | |||
assert(false, "illegal oopMap register name"); |
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.
Same.
src/hotspot/share/opto/compile.cpp
Outdated
@@ -753,7 +753,11 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, | |||
} | |||
if (failing()) return; | |||
if (cg == nullptr) { | |||
record_method_not_compilable("cannot parse method"); | |||
const char* reason = InlineTree::check_can_parse(method()); | |||
assert(reason != nullptr, "cannot parse method: why?"); |
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.
Add reason
to assert's message.
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.
reason
is nullptr
when the asser fails. I now say expect reason for parse failure
.
src/hotspot/share/opto/compile.cpp
Outdated
@@ -762,7 +766,10 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, | |||
JVMState* jvms = build_start_state(start(), tf()); | |||
if ((jvms = cg->generate(jvms)) == nullptr) { | |||
if (!failure_reason_is(C2Compiler::retry_class_loading_during_parsing())) { | |||
record_method_not_compilable("method parse failed"); | |||
assert(failure_reason() != nullptr, "method parse failed: why?"); |
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.
same
@@ -3989,6 +3998,7 @@ bool Compile::final_graph_reshaping() { | |||
} | |||
// Recheck with a better notion of 'required_outcnt' | |||
if (n->outcnt() != required_outcnt) { | |||
assert(false, "malformed control flow"); |
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.
Print more info about n
@@ -4007,6 +4017,7 @@ bool Compile::final_graph_reshaping() { | |||
// must be infinite loops. | |||
for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) | |||
if (!frc._visited.test(n->fast_out(j)->_idx)) { | |||
assert(false, "infinite loop"); |
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.
Print more info about n
src/hotspot/share/opto/output.cpp
Outdated
@@ -2844,6 +2844,7 @@ void Scheduling::anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is | |||
pinch = new Node(1); // Pinch point to-be | |||
} | |||
if (pinch->_idx >= _regalloc->node_regs_max_index()) { | |||
assert(false, "too many D-U pinch points"); |
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.
More info about pinch
node.
Yes |
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.
Looks good.
@eme64 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 62 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
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.
Looks good overall, some comments below.
src/hotspot/share/opto/parse1.cpp
Outdated
C->record_method_not_compilable("OSR starts with non-empty stack"); | ||
return; | ||
} | ||
// Do not OSR inside finally clauses: | ||
if (osr_block->has_trap_at(osr_block->start())) { | ||
assert(false, "OSR starts with an immediate trap"); | ||
// Bailout. But we should probably kick into normal compilation? |
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.
"OSR inside finally clauses" sounds like it could easily happen.
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.
It sounds likely, but I never saw it happen, up to tier9. So I suggest we leave the assert in, and once it is triggered, we can decide to remove it again. But then we also have an example, and we can check it in as a test, to justify the bailout.
src/hotspot/share/opto/parse1.cpp
Outdated
@@ -208,11 +208,14 @@ void Parse::load_interpreter_state(Node* osr_buf) { | |||
// Check bailouts. We currently do not perform on stack replacement | |||
// of loops in catch blocks or loops which branch with a non-empty stack. | |||
if (sp() != 0) { | |||
// Bailout. But we should probably kick into normal compilation? |
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.
We shouldn't add a question which is equivalent to a ToDo (same below). The comment should explain how this could happen and if we think that making the method not compilable is too strong, we should file a follow-up issue to investigate/fix.
How common is this? We will still compile at C1, so normal compilation will kick in, right?
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.
Ok, I will remove he question. I think you are right, we should at least still have C1 compilation. In my experiments, it was extremely rare, this case.
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
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.
Thanks for making these changes, looks good to me.
@vnkozlov @TobiHartmann thanks for the help and reviews! |
Going to push as commit af4d560.
Your commit was automatically rebased without conflicts. |
I went through all
C2
bailouts, and checked if they are justified to bail out of compilation silently. I added asserts everywhere. Those that were hit, I inspected by hand.Some of them seem to be justified. There I added comments why they are justified. They are cases that we do not want to handle in
C2
, and that are rare enough so that it probably does not matter.For the following bailouts I did not add an assert, because it may have revealed a bug:
JDK-8304328 C2 Bailout "failed spill-split-recycle sanity check" reveals hidden issue with RA
Note:
JDK-8303466 C2: COMPILE SKIPPED: malformed control flow - only one IfProj
That bug bug was the reason for this RFE here. I added the assert for "malformed control flow". After this RFE here, that Bug will run into the assert on debug builds.
I ran
tier1-6
and stress testing. Now runningtier7-9
.Filed a follow-up RFE to do the same for
BAILOUT
inC1
: JDK-8304532.Note: the philosophy here is rather to have an assert too much that triggers in the future. Then we can re-evaluate and weaken or remove it - or maybe we find a bug that we can fix.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13038/head:pull/13038
$ git checkout pull/13038
Update a local copy of the PR:
$ git checkout pull/13038
$ git pull https://git.openjdk.org/jdk.git pull/13038/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13038
View PR using the GUI difftool:
$ git pr show -t 13038
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13038.diff