RFR: 8286104: use aggressive liveness for unstable_if traps

Tobias Hartmann thartmann at openjdk.java.net
Fri May 6 06:54:06 UTC 2022


On Thu, 5 May 2022 05:30:06 GMT, Xin Liu <xliu at openjdk.org> wrote:

> I found that some phi nodes are useful because its uses are uncommon_trap nodes. In worse case, it would hinder boxing object eliminating and scalar replacement. Test.java of JDK-8286104 reveals this issue. This patch allows c2 parser to collect liveness based on next bci for unstable_if traps.  In most cases, next bci is closer to exits, so live locals are diminishing.  It helps to reduce the number of inputs of unstable_if traps. 
> 
> This is not a REDO of Optimization of Box nodes in uncommon_trap(JDK-8261137). Two patches are orthogonal.  I adapt test from [TestEliminateBoxInDebugInfo.java](https://github.com/openjdk/jdk/pull/2401/files#diff-49b2e38825aa4c28ca196bdc70c3cbecc2e835c2899f4f393527df4796b177ea), so part of credit goes to the original author.  I found that Scalar replacement can take care of the object `Integer ii = Integer.valueOf(value)` in original test even it can't be removed by later inliner.  I tweak the profiling data of Integer.valueOf() to hinder scalar replacement. 
> 
> This patch can cover the problem discovered by JDK-8261137. I ran the microbench and got 9x speedup on x86_64. It's almost same as JDK-8261137. 
> 
> Before:  
> 
> Benchmark               Mode  Cnt   Score   Error  Units
> MyBenchmark.testMethod  avgt   10  32.776 ± 0.075  us/op
> 
> After: 
> 
> Benchmark               Mode  Cnt   Score   Error  Units
> MyBenchmark.testMethod  avgt   10  3.656 ± 0.006  us/op
>  ```
> 
> Testing
> I ran tier1 test with and without `-XX:+DeoptimizeALot`. No regression has been found yet.

`TestAggressiveLivenessForUnstableIf.java` fails with `-ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation`:


PrintIdeal:
 41  ConI  ===  0  [[ 42 ]]  #int:999999
 42  CmpI  === _  10  41  [[ 43 ]]  !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:10 (line 51)
 40  ConI  ===  0  [[ 81 ]]  #int:0
 10  Parm  ===  3  [[ 81  42 ]] Parm0: int !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:-1 (line 48)
 43  Bool  === _  42  [[ 81 ]] [le] !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:10 (line 51)
 3  Start  ===  3  0  [[ 3  5  6  7  8  9  10 ]]  #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address, 5:int}
 81  CMoveI  === _  43  10  40  [[ 79 ]]  #int !orig=[78] !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:20 (line 55)
 9  Parm  ===  3  [[ 79 ]] ReturnAdr !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:-1 (line 48)
 8  Parm  ===  3  [[ 79 ]] FramePtr !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:-1 (line 48)
 7  Parm  ===  3  [[ 79 ]] Memory  Memory: @BotPTR *+bot, idx=Bot; !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:-1 (line 48)
 6  Parm  ===  3  [[ 79 ]] I_O !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:-1 (line 48)
 5  Parm  ===  3  [[ 79 ]] Control !jvms: TestAggressiveLivenessForUnstableIf::boxing_object @ bci:-1 (line 48)
 79  Return  ===  5  6  7  8  9 returns 81  [[ 0 ]] 
 0  Root  ===  0  79  [[ 0  1  3  40  41 ]] inner 

Failed IR Rules (1) of Methods (1)
----------------------------------
1) Method "public static int compiler.c2.irTests.TestAggressiveLivenessForUnstableIf.boxing_object(int)" - [Failed IR rules: 1]:
   * @IR rule 1: "@compiler.lib.ir_framework.IR(applyIf={}, applyIfAnd={}, failOn={}, applyIfOr={}, counts={"(\\\\d+(\\\\s){2}(CallStaticJava.*)+(\\\\s){2}===.*uncommon_trap.*unstable_if)", "1"}, applyIfNot={})"
     - counts: Graph contains wrong number of nodes:
       * Regex 1: (\\d+(\\s){2}(CallStaticJava.*)+(\\s){2}===.*uncommon_trap.*unstable_if)
         - Failed comparison: [found] 0 = 1 [given]
         - No nodes matched!

-------------

PR: https://git.openjdk.java.net/jdk/pull/8545


More information about the hotspot-compiler-dev mailing list