RFR(S): 8207773: [lworld] C2 should not allocate when returning a value type as Object from an inlined method

Tobias Hartmann tobias.hartmann at oracle.com
Wed Jul 18 11:29:15 UTC 2018


please review the following patch:

When inlining a method that returns a value type as java.lang.Object, C2 will allocate the value
type in the scope of the inlined method (see TestLWorld::test83). If the caller casts the return
value back to a value type, the now unnecessary allocation might stay and affect performance.

We should not allocate the returned value type when inlining but only if we return from the root
method (this is handled in parse1.cpp:2339). If required, caller will take care of the allocation.

Thanks a lot to Remi Forax for reporting this issue and helping with reproducing!

Here are the results of Remi's benchmark with the patched JVM:

Benchmark                                                        Mode  Cnt    Score     Error  Units
ReifiedListBenchMark.arraylist_integer_get                       avgt    9    0.065 ±   0.010  ms/op
ReifiedListBenchMark.reifiedlist_intbox_get                      avgt    9  593.495 ± 106.121  ms/op
ReifiedListBenchMark.valuelist_intbox_get                        avgt    9    0.033 ±   0.007  ms/op
ReifiedListBenchMark.valuelist_intbox_inlined_reduce             avgt    9    0.030 ±   0.002  ms/op
ReifiedListBenchMark.valuelist_intbox_innervalue_inlined_reduce  avgt    9    0.029 ±   0.001  ms/op
ReifiedListBenchMark.valuelist_intbox_reduce                     avgt    9    0.033 ±   0.009  ms/op

Best regards,

More information about the valhalla-dev mailing list