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

Wang Huang whuang at openjdk.java.net
Fri Feb 5 07:29:00 UTC 2021


> 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:

  refactor codes

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2401/files
  - new: https://git.openjdk.java.net/jdk/pull/2401/files/73be94ce..4dfee52a

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2401&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2401&range=00-01

  Stats: 91 lines in 1 file changed: 47 ins; 43 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2401.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2401/head:pull/2401

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


More information about the hotspot-compiler-dev mailing list