RFR: 8282722: Regard mapping array in enum switches as stable for constant folding
Joshua Zhu
jzhu at openjdk.java.net
Mon Mar 7 09:43:01 UTC 2022
On Mon, 7 Mar 2022 09:16:45 GMT, Joshua Zhu <jzhu at openjdk.org> wrote:
>> Is there a jmh micro-ben to show the perf improvement?
>> Or a jtreg test to show the inlining effect after this patch?
>>
>> Copyright year in `fieldInfo.hpp` needs to be updated.
>>
>> Thanks.
>
>> Is there a jmh micro-ben to show the perf improvement? Or a jtreg test to show the inlining effect after this patch?
>>
>> Copyright year in `fieldInfo.hpp` needs to be updated.
>>
>> Thanks.
>
> Thanks for your comments.
> This change is an optimization workable for all enum switches.
> Please check the example at http://cr.openjdk.java.net/~jzhu/8282722/
> You can check the generated codes or IR graph of function "test2" for differences with/without this change.
> Hi @JoshuaZhuwj , Can we also augment mentioned method [1] with a @forceinline attribute. Since SPECIES itself is static final it's constantness will propagate down to its fields and enable expression folding. But your fix looks generic one.
Jatin, this change is just like adding @Stable annotation to SwitchMap array (a translation table generated for enum switches in javac) to let c2's constant-folding take effect. I choose to implement this generic optimization so that class files in Java8 or Java11 could also benefit from this change.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7721
More information about the hotspot-dev
mailing list