RFR: JDK-8316991: Reduce nullable allocation merges [v2]
Tobias Hartmann
thartmann at openjdk.org
Tue Oct 3 08:46:14 UTC 2023
On Wed, 27 Sep 2023 23:34:10 GMT, Cesar Soares Lucas <cslucas at openjdk.org> wrote:
>> ### Description
>>
>> Many, if not most, allocation merges (Phis) are nullable because they join object allocations with "NULL", or objects returned from method calls, etc. Please review this Pull Request that improves Reduce Allocation Merge implementation so that it can reduce at least some of these allocation merges.
>>
>> Overall, the improvements are related to 1) making rematerialization of merges able to represent "NULL" objects, and 2) being able to reduce merges used by CmpP/N and CastPP.
>>
>> The approach to reducing CmpP/N and CastPP is pretty similar to that used in the `MemNode::split_through_phi` method: a clone of the node being split is added on each input of the Phi. I make use of `optimize_ptr_compare` and some type information to remove redundant CmpP and CastPP nodes. I added a bunch of ASCII diagrams illustrating what some of the more important methods are doing.
>>
>> ### Benchmarking
>>
>> **Note:** In some of these tests no reduction happens. I left them in to validate that no perf. regression happens in that case.
>> **Note 2:** Marging of error was negligible.
>>
>> | Benchmark | No RAM (ms/op) | Yes RAM (ms/op) |
>> |--------------------------------------|------------------|-------------------|
>> | TestTrapAfterMerge | 19.515 | 13.386 |
>> | TestArgEscape | 33.165 | 33.254 |
>> | TestCallTwoSide | 70.547 | 69.427 |
>> | TestCmpAfterMerge | 16.400 | 2.984 |
>> | TestCmpMergeWithNull_Second | 27.204 | 27.293 |
>> | TestCmpMergeWithNull | 8.248 | 4.920 |
>> | TestCondAfterMergeWithAllocate | 12.890 | 5.252 |
>> | TestCondAfterMergeWithNull | 6.265 | 5.078 |
>> | TestCondLoadAfterMerge | 12.713 | 5.163 |
>> | TestConsecutiveSimpleMerge | 30.863 | 4.068 |
>> | TestDoubleIfElseMerge | 16.069 | 2.444 |
>> | TestEscapeInCallAfterMerge | 23.111 | 22.924 |
>> | TestGlobalEscape | 14.459 | 14.425 |
>> | TestIfElseInLoop | 246.061 | 42.786 |
>> | TestLoadAfterLoopAlias | 45.808 | 45.812 |
>> ...
>
> Cesar Soares Lucas has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix typo in test.
I didn't look at this in detail yet but submitted testing. I see the following failures.
`compiler/eliminateAutobox/TestByteBoxing.java` with `-ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation`:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/workspace/open/src/hotspot/share/opto/loopnode.cpp:2178), pid=951972, tid=951999
# assert(inner->is_valid_counted_loop(T_INT) && inner->is_strip_mined()) failed: OuterStripMinedLoop should have been removed
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-10-03-0709344.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-10-03-0709344.tobias.hartmann.jdk2, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x128082c] LoopNode::verify_strip_mined(int) const+0xcc
Current CompileTask:
C2: 1438 263 % b compiler.eliminateAutobox.TestByteBoxing::main @ 1358 (1805 bytes)
Stack: [0x00007f0efc9cb000,0x00007f0efcacb000], sp=0x00007f0efcac57a0, free space=1001k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x128082c] LoopNode::verify_strip_mined(int) const+0xcc (loopnode.cpp:2178)
V [libjvm.so+0x1256ead] PathFrequency::to(Node*)+0x70d (loopPredicate.cpp:988)
V [libjvm.so+0x1258b49] PhaseIdealLoop::loop_predication_impl(IdealLoopTree*)+0x8e9 (loopPredicate.cpp:1462)
V [libjvm.so+0x125989a] IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x9a (loopPredicate.cpp:1536)
V [libjvm.so+0x12a28d7] PhaseIdealLoop::build_and_optimize()+0xf57 (loopnode.cpp:4582)
V [libjvm.so+0x9ee7fb] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x3ab (loopnode.hpp:1114)
V [libjvm.so+0x9e9db6] Compile::Optimize()+0xdf6 (compile.cpp:2362)
`compiler/eliminateAutobox/TestByteBoxing.java` with `-XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -XX:+StressArrayCopyMacroNode -XX:+StressLCM -XX:+StressGCM -XX:+StressIGVN -XX:+StressCCP -XX:+StressMethodHandleLinkerInlining -XX:+StressCompiledExceptionHandlers`:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (workspace/open/src/hotspot/share/opto/loopnode.cpp:6035), pid=1353611, tid=1353627
# Error: ShouldNotReachHere()
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-10-03-0709344.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-10-03-0709344.tobias.hartmann.jdk2, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x129062c] PhaseIdealLoop::verify_strip_mined_scheduling(Node*, Node*)+0x26c
Current CompileTask:
C2: 547 68 b compiler.eliminateAutobox.TestDoubleBoxing::sump (48 bytes)
Stack: [0x00007f1814966000,0x00007f1814a66000], sp=0x00007f1814a60c20, free space=1003k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x129062c] PhaseIdealLoop::verify_strip_mined_scheduling(Node*, Node*)+0x26c (loopnode.cpp:6035)
V [libjvm.so+0x12a0fb0] PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x420 (loopnode.cpp:6222)
V [libjvm.so+0x12a166d] PhaseIdealLoop::build_loop_late(VectorSet&, Node_List&, Node_Stack&)+0xbd (loopnode.cpp:6045)
V [libjvm.so+0x12a1f9d] PhaseIdealLoop::build_and_optimize()+0x61d (loopnode.cpp:4461)
V [libjvm.so+0x9ee7fb] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x3ab (loopnode.hpp:1114)
V [libjvm.so+0x9e9498] Compile::Optimize()+0x4d8 (compile.cpp:2354)
Same failures with other tests in `compiler/eliminateAutobox/`
`compiler/intrinsics/unsafe/AllocateUninitializedArray.java` with `-XX:-TieredCompilation -XX:+AlwaysIncrementalInline`:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/workspace/open/src/hotspot/share/opto/narrowptrnode.cpp:84), pid=2114638, tid=2114665
# assert(t != TypeNarrowKlass::NULL_PTR) failed: null klass?
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-10-03-0709344.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-10-03-0709344.tobias.hartmann.jdk2, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x140c554] DecodeNKlassNode::Value(PhaseGVN*) const+0x1b4
Current CompileTask:
C2: 5582 123 compiler.intrinsics.unsafe.AllocateUninitializedArray::testOK (110 bytes)
Stack: [0x00007fbb8b172000,0x00007fbb8b272000], sp=0x00007fbb8b26cce0, free space=1003k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x140c554] DecodeNKlassNode::Value(PhaseGVN*) const+0x1b4 (narrowptrnode.cpp:84)
V [libjvm.so+0x12a659a] PhaseIdealLoop::split_thru_phi(Node*, Node*, int)+0x30a (loopopts.cpp:103)
V [libjvm.so+0x12aa620] PhaseIdealLoop::split_if_with_blocks_pre(Node*)+0x270 (loopopts.cpp:1165)
V [libjvm.so+0x12af47f] PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x15f (loopopts.cpp:1877)
V [libjvm.so+0x12a291f] PhaseIdealLoop::build_and_optimize()+0xf9f (loopnode.cpp:4572)
V [libjvm.so+0x9ee7fb] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x3ab (loopnode.hpp:1114)
V [libjvm.so+0x9e9d51] Compile::Optimize()+0xd91 (compile.cpp:2171)
-------------
Changes requested by thartmann (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15825#pullrequestreview-1654667506
More information about the hotspot-dev
mailing list