Skip to content
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

8261812: C2 compilation fails with assert(!had_error) failed: bad dominance #2774

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Mar 1, 2021

In the testByte() test case, byteField is assigned int values that
don't fit in a byte.

obj.byteField = (byte)(1 << i);

At parse time, c2 expands this to (in pseudo code):

int v = (1 << i);
obj.byteField = (v << 24) >> 24;

next:

StoreBNode::Ideal() runs and StoreNode::Ideal_sign_extended_input()
causes this to become:

obj.byteField = (1 << i);

i is then constant folded to 9:

obj.byteField = 512;

obj doesn't escape and is scalarized. The value of the byteField needs
to be recorded in the debug info. Because there are 2 such a store, a
Phi is created:

(Phi 512 1024)

The Phi is created with type TypeInt::BYTE. Because that doesn't
overlap with the input values, the Phi is transformed to top. The test
case then triggers a deoptimization and a crash occurs in the
deoptimization code.

The failure of the bug report is not a crash during deoptimization but
a c2 crash. The root cause is the same but in that case a chain of Phi
is involved and when one becomes top, it causes an uncommon trap to
have an input that doesn't dominate the uncommon trap.

I noticed LoadBNode::Ideal() re-inserts the 2 shifts when it returns a
value from a Store. I propose the same fix here in the allocation
elimination code.

Same problem applies to short and char. They are covered by the fix. I
also included boolean even though I don't see how to trigger the
failure with it.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8261812: C2 compilation fails with assert(!had_error) failed: bad dominance

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2774/head:pull/2774
$ git checkout pull/2774

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 1, 2021

👋 Welcome back roland! 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 openjdk bot added the rfr label Mar 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 1, 2021

@rwestrel 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 label Mar 1, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 1, 2021

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Otherwise looks good.

@@ -450,6 +450,9 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type *
Node* n = val->in(MemNode::ValueIn);
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
n = bs->step_over_gc_barrier(n);
if (ft == T_SHORT || ft == T_BYTE || ft == T_CHAR || ft == T_BOOLEAN) {
Copy link
Contributor

@vnkozlov vnkozlov Mar 1, 2021

Choose a reason for hiding this comment

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

Use is_subword_type(bt) defined in globalDefinitions.hpp

Copy link
Contributor Author

@rwestrel rwestrel Mar 2, 2021

Choose a reason for hiding this comment

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

Thanks for the review. I pushed a commit with your suggestion.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Good.

@openjdk
Copy link

@openjdk openjdk bot commented Mar 2, 2021

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

8261812: C2 compilation fails with assert(!had_error) failed: bad dominance

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 151 new commits pushed to the master branch:

  • d91550e: 8262998: Vector API intrinsincs should not modify IR when bailing out
  • 80182f9: 8260925: HttpsURLConnection does not work with other JSSE provider.
  • dbef0ec: 6323374: (coll) Optimize Collections.unmodifiable* and synchronized*
  • ee09bad: 8262300: jpackage app-launcher fails on linux when using JDK11 based runtime
  • 351889f: 8262508: Vector API's ergonomics is incorrect
  • 718d4d4: 8262989: Vectorize VectorShuffle checkIndexes, wrapIndexes and laneIsValid methods
  • c8b23e2: 8262064: Make compiler/ciReplay tests ignore lambdas in compilation replay
  • 02fbcb5: 8261532: Archived superinterface class cannot be accessed
  • 109af7b: 8261518: jpackage looks for main module in current dir when there is no module-path
  • e61a3ba: 8239386: handle ContendedPaddingWidth in vm_version_aarch64
  • ... and 141 more: https://git.openjdk.java.net/jdk/compare/a6a7e4398aae9568e39650341aa3255ab23f9961...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 label Mar 2, 2021
Copy link
Member

@TobiHartmann TobiHartmann left a comment

Looks good to me.

result = new AndINode(value,phase->intcon(0xFFFF));
} else {
assert(bt == T_SHORT, "unexpected narrow type");
result = phase->transform( new LShiftINode(value, phase->intcon(16)) );
Copy link
Member

@TobiHartmann TobiHartmann Mar 3, 2021

Choose a reason for hiding this comment

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

There's some excess whitespacing.

Copy link
Contributor Author

@rwestrel rwestrel Mar 5, 2021

Choose a reason for hiding this comment

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

fixed. Thanks for the review.

@rwestrel
Copy link
Contributor Author

@rwestrel rwestrel commented Mar 5, 2021

/integrate

@openjdk openjdk bot closed this Mar 5, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Mar 5, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 5, 2021

@rwestrel Since your change was applied there have been 156 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit 2c0507e.

💡 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 integrated
3 participants