jdk icon indicating copy to clipboard operation
jdk copied to clipboard

JDK-8330795 : C2: assert((uint)type <= T_CONFLICT && _zero_type[type] != nullptr) failed: bad type with -XX:-UseCompressedClassPointers

Open JohnTortugo opened this issue 1 year ago • 13 comments

The assert((uint)type <= T_CONFLICT && _zero_type[type] != nullptr) failed: bad type failure was caused by the fact that we didn't have a "zero value" for the type T_METADATA. The RAM patch uses that data when it creates a Phi node merging Klass loads and UseCompressedClassPointers is disabled.

Tested with JTREG tier1-4 on Linux x86_64 & ARM64.


Progress

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

Issue

  • JDK-8330795: C2: assert((uint)type <= T_CONFLICT && _zero_type[type] != nullptr) failed: bad type with -XX:-UseCompressedClassPointers (Bug - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19148

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

Using diff file

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

Webrev

Link to Webrev Comment

JohnTortugo avatar May 08 '24 23:05 JohnTortugo

:wave: Welcome back cslucas! 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.

bridgekeeper[bot] avatar May 08 '24 23:05 bridgekeeper[bot]

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

8330795: C2: assert((uint)type <= T_CONFLICT && _zero_type[type] != nullptr) failed: bad type with -XX:-UseCompressedClassPointers

Reviewed-by: kvn

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

  • 95a601316de06b4b0fbf6e3c7777be5d2a1ca978: 8332042: Move MEMFLAGS to its own include file
  • 5a4415a6bddb25cbd5b87ff8ad1a06179c2e452e: 8331858: [nmt] VM.native_memory statistics should work in summary mode
  • 4ba74475d44831c1fe49359458163cd1567e9619: 8326957: Implement JEP 474: ZGC: Generational Mode by Default
  • 7ce4a13c0a891e606480e138f4025ffa328a18b3: 8332130: RISC-V: remove wrong instructions of Vector Crypto Extension
  • ea5eb74a65f20ce28fa0a94ea851915d4a6f83da: 8326404: Assertion error when trying to compile switch with fallthrough with pattern
  • beea5305b071820e2b128a55c5ca384caf470fdd: 8331907: BigInteger and BigDecimal should use optimized division
  • 440782e0160f867f08afbec0abf48d557a522c72: 8331466: Problemlist serviceability/dcmd/gc/RunFinalizationTest.java on generic-all
  • 5ded8da676d62158d0011086d7f80ff2c9096e13: 8332085: Remove 10 year old transition check in GenerateCurrencyData tool
  • 7c2c24fc0511b36132952c96be46eea5904a53c5: 8261433: Better pkcs11 performance for libpkcs11:C_EncryptInit/libpkcs11:C_DecryptInit
  • ff4bf1cf9f18547cff8f484433c3c55b4c288aaa: 8332102: Add @since to package-info of jdk.security.jarsigner
  • ... and 51 more: https://git.openjdk.org/jdk/compare/ad78b7fa67ba30cab2e8f496e4c765be15deeca6...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

openjdk[bot] avatar May 08 '24 23:05 openjdk[bot]

@JohnTortugo 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[bot] avatar May 08 '24 23:05 openjdk[bot]

Webrevs

mlbridge[bot] avatar May 08 '24 23:05 mlbridge[bot]

New test failed in GHA with 32-bit VM because:

Unrecognized VM option 'UseCompressedClassPointers'

You can add -XX:+IgnoreUnrecognizedVMOptions to run test on all platforms.

vnkozlov avatar May 09 '24 01:05 vnkozlov

@JohnTortugo, thank you for adding new test. But it would be nice also add additional run with -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedClassPointers to failed test test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java

Also why you require to run test only with compressed oops on?:

* @requires vm.debug == true & vm.bits == 64 & vm.compiler2.enabled & vm.opt.final.UseCompressedOops & vm.opt.final.EliminateAllocations

vnkozlov avatar May 09 '24 01:05 vnkozlov

@JohnTortugo, thank you for adding new test. But it would be nice also add additional run with -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedClassPointers to failed test test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java

Actually -XX:+IgnoreUnrecognizedVMOptions is not needed because you require vm.bits == 64 in the test.

vnkozlov avatar May 09 '24 01:05 vnkozlov

@JohnTortugo, thank you for adding new test. But it would be nice also add additional run with -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedClassPointers to failed test test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java

Thank you @vnkozlov , I'll work on that.

JohnTortugo avatar May 09 '24 03:05 JohnTortugo

@vnkozlov - I updated the patch by adding new tests with CompressedOops/CompressedClassPointers enabled and disabled.

JohnTortugo avatar May 13 '24 22:05 JohnTortugo

@JohnTortugo This looks reasonable. Can you explain more why having klass field load is bad for your code?

Is it because you need klass as constant for deoptimization?

Is it possible to handle such case (loading klass) as separate RFE later?

vnkozlov avatar May 13 '24 23:05 vnkozlov

Can you explain more why having klass field load is bad for your code?

The issue involves LoadNKlass, DecodeNKlass and NULL NKlass. It happens when splitting a LoadNKlass through a nullable Phi. In that process another "nullable" Phi of type TypeNarrowKlass may be created merging the "Klass'es" of the original Phi inputs. A NULL NarrowKlass seems to be something not quite well defined: for instance, there is no definition of "_zero_type" for T_METADATA which is the basic type of TypeNarrowKlass. The first commit in this PR was to add this definition.

However, I think a better approach - than the one from first commit - maybe to instead of creating a Phi of type NarrowKlass create a Phi of type TypePtr that merges DecodeNKlass. By doing so I won't need to create a Phi with a NULL NKlass so the original patch isn't necessary. However, in my opinion, doing that is better left for a separate RFE + PR.

Is it possible to handle such case (loading klass) as separate RFE later?

Yes, I think we can do it as a separate RFE. However, in my experiments klass field loading doesn't appear very often in the benchmarks and therefore may not be much worth the added complication.

JohnTortugo avatar May 14 '24 02:05 JohnTortugo

However, in my experiments klass field loading doesn't appear very often in the benchmarks and therefore may not be much worth the added complication.

It may be true for code with new allocations but in general case when an object is passed as argument or loaded from field klass loading is common case.

vnkozlov avatar May 14 '24 03:05 vnkozlov

Thank you for explaining issue you have with klass loading. I will run our testing with you current version.

vnkozlov avatar May 14 '24 03:05 vnkozlov

Thank you for reviewing and testing @vnkozlov !

JohnTortugo avatar May 14 '24 15:05 JohnTortugo

/integrate

JohnTortugo avatar May 14 '24 15:05 JohnTortugo

@JohnTortugo Your change (at version bb632c27f17d1377106c1788051ab0f7d96cd503) is now ready to be sponsored by a Committer.

openjdk[bot] avatar May 14 '24 15:05 openjdk[bot]

/sponsor

vnkozlov avatar May 15 '24 01:05 vnkozlov

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

  • 7b4ba7f90ab9ea5e1070c79534c587dad17d1bdd: 8325932: Replace ATTRIBUTE_NORETURN with direct [[noreturn]]
  • 0bb5ae645165b97527ecccf02308df6072c363d8: 8332248: (fc) java/nio/channels/FileChannel/BlockDeviceSize.java failed with RuntimeException
  • 4d32c607a4b496bf2bb09e54167ecbbab5569a0c: 8322008: Exclude some CDS tests from running with -Xshare:off
  • e91492ab4333c61f39b50eb428fa932131a5b908: 8313674: (fc) java/nio/channels/FileChannel/BlockDeviceSize.java should test for more block devices
  • 95a601316de06b4b0fbf6e3c7777be5d2a1ca978: 8332042: Move MEMFLAGS to its own include file
  • 5a4415a6bddb25cbd5b87ff8ad1a06179c2e452e: 8331858: [nmt] VM.native_memory statistics should work in summary mode
  • 4ba74475d44831c1fe49359458163cd1567e9619: 8326957: Implement JEP 474: ZGC: Generational Mode by Default
  • 7ce4a13c0a891e606480e138f4025ffa328a18b3: 8332130: RISC-V: remove wrong instructions of Vector Crypto Extension
  • ea5eb74a65f20ce28fa0a94ea851915d4a6f83da: 8326404: Assertion error when trying to compile switch with fallthrough with pattern
  • beea5305b071820e2b128a55c5ca384caf470fdd: 8331907: BigInteger and BigDecimal should use optimized division
  • ... and 55 more: https://git.openjdk.org/jdk/compare/ad78b7fa67ba30cab2e8f496e4c765be15deeca6...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar May 15 '24 01:05 openjdk[bot]

@vnkozlov @JohnTortugo Pushed as commit 4e77cf881d031e5b0320915b3eabd7702e560291.

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

openjdk[bot] avatar May 15 '24 01:05 openjdk[bot]