RFR: 8282722: Regard mapping array in enum switches as stable for constant folding
Jatin Bhateja
jbhateja at openjdk.java.net
Tue Mar 8 02:31:58 UTC 2022
On Mon, 7 Mar 2022 11:58:42 GMT, Joshua Zhu <jzhu at openjdk.org> wrote:
> > Fix is checking an integer array field name starting with "$SwitchMap" to be marked as stable if it is decorated with ACC_STATIC | ACC_FINAL attributes. Wandering why is not being honored during constant folding currently.
>
> "static final int[] $SwitchMap$xxx" does not mean elements in the array are immutable. Hence it is necessary to treat mapping array generated in enum switches as stable so that their elements can be constant-folded. Please do not miss JVM_ACC_SYNTHETIC flag in this change. "A field marked with the ACC_SYNTHETIC flag indicates that it was generated by a compiler and does not appear in source code."
Thanks @JoshuaZhuwj , Got it,
FTR references from JLS17 section 4.12.4 (final) and Stable documentation give the necessary details on semantics. https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java#L51
-------------
PR: https://git.openjdk.java.net/jdk/pull/7721
More information about the hotspot-dev
mailing list