RFR: 8261137: Optimization of Box nodes in uncommon_trap
    Nils Eliasson 
    neliasso at openjdk.java.net
       
    Thu Feb  4 12:44:42 UTC 2021
    
    
  
On Thu, 4 Feb 2021 08:43:35 GMT, Wang Huang <whuang at openjdk.org> wrote:
> JDK-8075052 has  removed useless autobox. However, in some cases, the box is still saved. For instance:
> @Benchmark
> public void testMethod(Blackhole bh) {
>   int sum = 0;
>   for (int i = 0; i < data.length; i++) {
>       Integer ii = Integer.valueOf(data[i]);
>       if (i < data.length) {
>           sum += ii.intValue();
>       }
>   }
>   bh.consume(sum);
> }
> Although the variable ii is only used at ii.intValue(), it cannot be eliminated as a result of being used by a hidden uncommon_trap.
> The uncommon_trap is generated by the optimized "if", because its condition is always true.
> 
> We can postpone box in uncommon_trap in this situation. We treat box as a scalarized object by adding a SafePointScalarObjectNode in the uncommon_trap node,
> and deleting the use of box:
> 
> There is no additional fail/error(s) of jtreg after this patch.
src/hotspot/share/opto/callGenerator.cpp line 606:
> 604:   }
> 605: 
> 606:   if (callprojs.resproj != NULL && call->is_CallStaticJava() &&
Please extract the new code into a method with a descriptive name.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2401
    
    
More information about the hotspot-compiler-dev
mailing list