RFR: 8261137: Optimization of Box nodes in uncommon_trap [v4]

Xin Liu xliu at openjdk.java.net
Wed Feb 10 21:58:43 UTC 2021


On Wed, 10 Feb 2021 06:58:57 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.
>
> Wang Huang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   delete useless line

src/hotspot/share/opto/callGenerator.cpp line 588:

> 586:         Node* sobj = new SafePointScalarObjectNode(gvn.type(res)->isa_oopptr(),
> 587: #ifdef ASSERT
> 588:                                                   (AllocateNode*)call,

You can use call->isa_Allocate();  It utilizes node's ad-hoc RTTI  to do type casting.

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

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


More information about the hotspot-compiler-dev mailing list