RFR: 8289943: Simplify some object allocation merges

Xin Liu xliu at openjdk.org
Thu Jul 14 23:36:05 UTC 2022


On Tue, 7 Jun 2022 23:24:02 GMT, Cesar Soares <duke at openjdk.org> wrote:

> Hi there, can I please get some feedback on this approach to simplify object allocation merges in order to promote Scalar Replacement of the objects involved in the merge?
> 
> The basic idea for this [approach was discussed in this thread](https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2022-April/055189.html) and it consists of: 
> 1) Identify Phi nodes that merge object allocations and replace them with a new IR node called ReducedAllocationMergeNode (RAM node).
> 2) Scalar Replace the incoming allocations to the RAM node.
> 3) Scalar Replace the RAM node itself.
> 
> There are a few conditions for doing the replacement of the Phi by a RAM node though - Although I plan to work on removing them in subsequent PRs:
> 
> - ~~The original Phi node should be merging Allocate nodes in all inputs.~~
> - The only supported users of the original Phi are AddP->Load, SafePoints/Traps, DecodeN.
> 
> These are the critical parts of the implementation and I'd appreciate it very much if you could tell me if what I implemented isn't violating any C2 IR constraints:
> 
> - The way I identify/use the memory edges that will be used to find the last stored values to the merged object fields.
> - The way I check if there is an incoming Allocate node to the original Phi node.
> - The way I check if there is no store to the merged objects after they are merged.
> 
> Testing:
> - Linux. fastdebug -> hotspot_all, renaissance, dacapo

I run into an error 

$make test TEST=compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java  CONF=linux-x86_64-server-fastdebug


One or more @IR rules failed:

Failed IR Rules (1) of Methods (1)
----------------------------------
1) Method "int compiler.c2.irTests.scalarReplacement.AllocationMergesTests.testPollutedPolymorphic(boolean,int)" - [Failed IR rules: 1]:
   * @IR rule 1: "@compiler.lib.ir_framework.IR(applyIf={}, applyIfAnd={}, failOn={}, applyIfOr={}, counts={"(.*precise .*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java)", "2"}, applyIfNot={})"
     - counts: Graph contains wrong number of nodes:
       * Regex 1: (.*precise .*\R((.*(?i:mov|xorl|nop|spill).*|\s*|.*LGHI.*)\R)*.*(?i:call,static).*wrapper for: _new_instance_Java)
         - Failed comparison: [found] 0 = 2 [given]
         - No nodes matched!

>>> Check stdout for compilation output of the failed methods


  #############################################################
   - To only run the failed tests use -DTest, -DExclude,
     and/or -DScenarios.
   - To also get the standard output of the test VM run with
     -DReportStdout=true or for even more fine-grained logging
     use -DVerbose=true.
  #############################################################


compiler.lib.ir_framework.driver.irmatching.IRViolationException: There were one or multiple IR rule failures. Please check stderr for more information.
        at compiler.lib.ir_framework.driver.irmatching.IRMatcher.throwIfNoSafepointWhilePrinting(IRMatcher.java:91)
        at compiler.lib.ir_framework.driver.irmatching.IRMatcher.reportFailures(IRMatcher.java:82)
        at compiler.lib.ir_framework.driver.irmatching.IRMatcher.applyIRRules(IRMatcher.java:54)
        at compiler.lib.ir_framework.driver.irmatching.IRMatcher.<init>(IRMatcher.java:43)
        at compiler.lib.ir_framework.TestFramework.runTestVM(TestFramework.java:729)
        at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:698)
        at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:329)
        at compiler.lib.ir_framework.TestFramework.runWithFlags(TestFramework.java:237)
        at compiler.c2.irTests.scalarReplacement.AllocationMergesTests.main(AllocationMergesTests.java:37)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
        at java.base/java.lang.Thread.run(Thread.java:1596)


2 objects do get scalarized in `testPollutedPolymorphic`.

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

PR: https://git.openjdk.org/jdk/pull/9073


More information about the hotspot-compiler-dev mailing list