RFR: 8319932: [JVMCI] class unloading related tests can fail on libgraal [v3]
Doug Simon
dnsimon at openjdk.org
Tue Mar 5 22:14:00 UTC 2024
> This PR addresses a race in `runtime/ClassInitErrors/InitExceptionUnloadTest.java` that is exposed by libgraal which sets the [default value for `TypeProfileWidth` to 8](https://github.com/openjdk/jdk/blob/eb4b6fa6212380c9b6d3c94f5aa3384f12a0c125/src/hotspot/share/compiler/compilerDefinitions.cpp#L429).
>
> The problem is that `InitExceptionUnloadTest$SpecialException` is loaded by a [custom class loader](https://github.com/openjdk/jdk/blob/eb4b6fa6212380c9b6d3c94f5aa3384f12a0c125/test/hotspot/jtreg/runtime/ClassInitErrors/InitExceptionUnloadTest.java#L106) and appears in the profile of `String.valueOf` as shown by `-XX:+PrintMethodData`:
>
> static java.lang.String::valueOf(Ljava/lang/Object;)Ljava/lang/String;
> interpreter_invocation_count: 957
> invocation_counter: 957
> backedge_counter: 0
> decompile_count: 0
> mdo size: 496 bytes
>
> 0 nofast_aload_0
> 1 ifnonnull 10
> 0 bci: 1 BranchData taken(698) displacement(56)
> not taken(0)
> 4 fast_aldc_w "null"
> 7 goto 14
> 32 bci: 7 JumpData taken(0) displacement(168)
> 10 nofast_aload_0
> 11 invokevirtual 1023 <java/lang/Object.toString()Ljava/lang/String;>
> 56 bci: 11 VirtualCallData count(2) entries(8)
> 'java/lang/String'(470 0.67)
> 'java/lang/StackTraceElement'(204 0.29)
> 'java/lang/Error'(1 0.00)
> 'java/lang/NoClassDefFoundError'(6 0.01)
> 'java/lang/ExceptionInInitializerError'(8 0.01)
> 'InitExceptionUnloadTest$SpecialException'(2 0.00) <===== unloadable type in profile
> 'java/lang/OutOfMemoryError'(2 0.00)
>
>
> When this method is being compiled at tier 3, C1 makes a strong GC root for each type in the profile. Only once the compilation completes, are these strong roots released.
>
> The test currently triggers class unloading via a [whitebox full GC](https://github.com/openjdk/jdk/blob/eb4b6fa6212380c9b6d3c94f5aa3384f12a0c125/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java#L67) and then immediately expects the classes to be unloaded. If the above C1 compilation is still in progress, the classes may not yet be unloaded.
>
> This PR modifies the test to add a retry loop around the unloading trigger and the check for unloaded classes.
Doug Simon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Merge remote-tracking branch 'openjdk-jdk/master' into JDK-8319932_v2
- improved javadoc as requested
- move retry loop for class unloading to lib code
- allow more time for class unloading in InitExceptionUnloadTest
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/18044/files
- new: https://git.openjdk.org/jdk/pull/18044/files/3ebec867..e231f627
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=18044&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=18044&range=01-02
Stats: 74492 lines in 1542 files changed: 3371 ins; 68046 del; 3075 mod
Patch: https://git.openjdk.org/jdk/pull/18044.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18044/head:pull/18044
PR: https://git.openjdk.org/jdk/pull/18044
More information about the hotspot-runtime-dev
mailing list