Skip to content

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

Closed
wants to merge 8 commits into from

Conversation

eme64
Copy link
Contributor

@eme64 eme64 commented Mar 15, 2023

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 running tier7-9.

Filed a follow-up RFE to do the same for BAILOUT in C1: 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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8303951: Add asserts before record_method_not_compilable where possible

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 15, 2023

👋 Welcome back epeter! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 15, 2023

@eme64 this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

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

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Mar 15, 2023
@openjdk
Copy link

openjdk bot commented Mar 15, 2023

@eme64 The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Mar 15, 2023
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Mar 15, 2023
@eme64 eme64 marked this pull request as ready for review March 17, 2023 08:30
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 17, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 17, 2023

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a 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");
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@@ -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?");
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -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?");
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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

@@ -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");
Copy link
Contributor

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.

@vnkozlov
Copy link
Contributor

Should we file a follow-up RFE to do the same for BAILOUT in C1?

Yes

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@openjdk
Copy link

openjdk bot commented Mar 20, 2023

@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:

8303951: Add asserts before record_method_not_compilable where possible

Reviewed-by: kvn, thartmann

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 master branch:

  • c433862: 6245410: javax.swing.text.html.CSS.Attribute: BACKGROUND_POSITION is not w3c spec compliant
  • 91f407d: 8029301: Confusing error message for array creation method reference
  • e73411a: 8304376: Rename t1/t2 classes in com/sun/jdi/CLETest.java to avoid class duplication error in IDE
  • a2d8f63: 8288730: Add type parameter to Lookup::accessClass and Lookup::ensureInitialized
  • 3777455: 8302191: Performance degradation for float/double modulo on Linux
  • 760c012: 8304683: Memory leak in WB_IsMethodCompatible
  • 75168ea: 8304134: jib bootstrapper fails to quote filename when checking download filetype
  • 4154a98: 8301498: Replace NULL with nullptr in cpu/x86
  • ddf1e34: 8304089: Convert TraceDependencies to UL
  • 358c61b: 8294972: Convert jdk.jlink internal plugins to use the Classfile API
  • ... and 52 more: https://git.openjdk.org/jdk/compare/ebac7eec8e5923c66a80cbd66e79c354f30a07a3...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 20, 2023
Copy link
Member

@TobiHartmann TobiHartmann left a 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.

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?
Copy link
Member

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.

Copy link
Contributor Author

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.

@@ -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?
Copy link
Member

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?

Copy link
Contributor Author

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.

eme64 and others added 2 commits March 22, 2023 13:52
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
@eme64 eme64 requested a review from TobiHartmann March 22, 2023 13:11
Copy link
Member

@TobiHartmann TobiHartmann left a 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.

@eme64
Copy link
Contributor Author

eme64 commented Mar 23, 2023

@vnkozlov @TobiHartmann thanks for the help and reviews!
/integrate

@openjdk
Copy link

openjdk bot commented Mar 23, 2023

Going to push as commit af4d560.
Since your change was applied there have been 62 commits pushed to the master branch:

  • c433862: 6245410: javax.swing.text.html.CSS.Attribute: BACKGROUND_POSITION is not w3c spec compliant
  • 91f407d: 8029301: Confusing error message for array creation method reference
  • e73411a: 8304376: Rename t1/t2 classes in com/sun/jdi/CLETest.java to avoid class duplication error in IDE
  • a2d8f63: 8288730: Add type parameter to Lookup::accessClass and Lookup::ensureInitialized
  • 3777455: 8302191: Performance degradation for float/double modulo on Linux
  • 760c012: 8304683: Memory leak in WB_IsMethodCompatible
  • 75168ea: 8304134: jib bootstrapper fails to quote filename when checking download filetype
  • 4154a98: 8301498: Replace NULL with nullptr in cpu/x86
  • ddf1e34: 8304089: Convert TraceDependencies to UL
  • 358c61b: 8294972: Convert jdk.jlink internal plugins to use the Classfile API
  • ... and 52 more: https://git.openjdk.org/jdk/compare/ebac7eec8e5923c66a80cbd66e79c354f30a07a3...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 23, 2023
@openjdk openjdk bot closed this Mar 23, 2023
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Mar 23, 2023
@openjdk openjdk bot removed the rfr Pull request is ready for review label Mar 23, 2023
@openjdk
Copy link

openjdk bot commented Mar 23, 2023

@eme64 Pushed as commit af4d560.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants