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

8316533: C2 compilation fails with assert(verify(phase)) failed: missing Value() optimization #16361

Closed
wants to merge 14 commits into from

Conversation

eme64
Copy link
Contributor

@eme64 eme64 commented Oct 25, 2023

Problem
We have a abstract class A with no subtype. Hence, a reference of type A must always be null (unless a subclass were to be loaded, which we guard against with a compile dependency).

But there are at least these two ways a A:NotNull can be created:

  • Null-Check: CastPP after null-check improves type from A to A:NotNull.
  • Forced compilation (eg CTW) of a member method of A. Then Parm0 has type A, which is improved to A:NotNull because the this/self pointer cannot be null.

This means we are now left with an impossible type A:NotNull, a path that uses this type will never be executed.

The question is now what should happen at a SubTypeCheck if we do:
SubTypeCheck( oop #A:NotNull , constant-classptr-A-exact )

The verification happens because we do these two different things:

  • SubTypeCheck: we first detect that we have a constant classptr of a class A, which is abstract and has no subtype. Hence, we conclude that any oop compared to it cannot be a subtype (there are no subtypes), and it cannot be of the same type (class is abstract). Hence, any oop must be a supertype (TypeInt::CC_GT).
  • The verification code computes the subtype check by computing the klass of the oop via LoadKlass (this constant folds to constant-classptr-A-exact, because the type of the oop is A:NotNull). The CmpP node compares the two klasses, and sees that they are identical, and returns an TypeInt::CC_EQ.

Alternatives

Both results are reasonable, but they are in fact both supersets of the true result. We should take the intersection of the two and get Type:TOP, since the input type is already impossible. In fact, it would be best if the impossible type was never created. We could do that by improving CmpP to detect the impossible type and constant fold towards the null path, removing the A:NotNull path. It is harder to deal with the forced-compilation of non-static methods of an abstract class with no subclasses - here we would basically have to forbid compilation or replace the compilation with a Halt.

Solution

Instead, I have now decided to change the logic in SubTypeCheckNode to return EQ in case the oop has the same klass and is NotNull.

Testing

Tier1-6 and stress testing. Running...


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-8316533: C2 compilation fails with assert(verify(phase)) failed: missing Value() optimization (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16361/head:pull/16361
$ git checkout pull/16361

Update a local copy of the PR:
$ git checkout pull/16361
$ git pull https://git.openjdk.org/jdk.git pull/16361/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16361

View PR using the GUI difftool:
$ git pr show -t 16361

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16361.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 25, 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 openjdk bot changed the title 8316533 8316533: C2 compilation fails with assert(verify(phase)) failed: missing Value() optimization Oct 25, 2023
@openjdk
Copy link

openjdk bot commented Oct 25, 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 Oct 25, 2023
@eme64 eme64 marked this pull request as ready for review November 2, 2023 09:14
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 2, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 2, 2023

Webrevs


package compiler.types;

public class TestSubTypeOfAsbtractClass {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo:

Suggested change
public class TestSubTypeOfAsbtractClass {
public class TestSubTypeOfAbstractClass {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had copied the mistake from the other test: TestSubTypeOfAsbtractClassWrongResult.java

* @bug 8316533
* @summary Oop of abstract class A is subtype checked after null-check
* @requires vm.compiler2.enabled
* @run main/othervm -XX:CompileCommand=printcompilation,*A::test
Copy link
Contributor

Choose a reason for hiding this comment

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

-XX:CompileCommand=printcompilation,*A::test is unnecessary.

Comment on lines 66 to 67


Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these extra line breaks.

Copy link
Contributor

@robcasloz robcasloz 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, I just have a few minor comments and style suggestions.

src/hotspot/share/opto/subtypenode.cpp Outdated Show resolved Hide resolved
src/hotspot/share/opto/subtypenode.cpp Outdated Show resolved Hide resolved
@openjdk
Copy link

openjdk bot commented Nov 2, 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:

8316533: C2 compilation fails with assert(verify(phase)) failed: missing Value() optimization

Reviewed-by: rcastanedalo, thartmann, roland

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

  • c146685: 8319165: hsdis binutils: warns on empty string as option string
  • 01c0d5d: 8319412: RISC-V: Simple fix of indent in c2_MacroAssembler_riscv.hpp
  • df599db: 8295159: DSO created with -ffast-math breaks Java floating-point arithmetic
  • c099cf5: 8318422: Allow poller threads be virtual threads
  • 29cf2c4: 8319053: Segment dump files remain after parallel heap dump on Windows
  • ea6a88a: 8318466: Improve spec of NumberFormat's methods with unsupported operations
  • de6667c: 8225377: type annotations are not visible to javac plugins across compilation boundaries
  • 008ca2a: 8317620: Build JDK tools with ModuleMainClass attribute

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Nov 2, 2023
@openjdk
Copy link

openjdk bot commented Nov 2, 2023

⚠️ @eme64 This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

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 to me. @rwestrel should take a look as well.

Copy link
Contributor

@rwestrel rwestrel left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me.

@eme64
Copy link
Contributor Author

eme64 commented Nov 6, 2023

Thanks @TobiHartmann @robcasloz @rwestrel for the reviews!
/integrate

@openjdk
Copy link

openjdk bot commented Nov 6, 2023

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

  • 377138c: 8318959: C2: define MachNode::fill_new_machnode() statically
  • c146685: 8319165: hsdis binutils: warns on empty string as option string
  • 01c0d5d: 8319412: RISC-V: Simple fix of indent in c2_MacroAssembler_riscv.hpp
  • df599db: 8295159: DSO created with -ffast-math breaks Java floating-point arithmetic
  • c099cf5: 8318422: Allow poller threads be virtual threads
  • 29cf2c4: 8319053: Segment dump files remain after parallel heap dump on Windows
  • ea6a88a: 8318466: Improve spec of NumberFormat's methods with unsupported operations
  • de6667c: 8225377: type annotations are not visible to javac plugins across compilation boundaries
  • 008ca2a: 8317620: Build JDK tools with ModuleMainClass attribute

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 6, 2023

@eme64 Pushed as commit b5c863b.

💡 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.

4 participants