On Mon, 2 Sep 2024 14:01:36 GMT, Shaojin Wen <s...@openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/classfile/impl/BytecodeHelpers.java 
>> line 61:
>> 
>>> 59:         return switch (tk) {
>>> 60:             case INT, SHORT, BYTE, CHAR, BOOLEAN
>>> 61:                            -> iload(slot);
>> 
>> Can you do
>> 
>> switch (tk.asLoadable()) {
>>     case INT      -> iload(slot);
>
> I'm not sure if that's better, because there's a getField and branch in the 
> implementation of asLoadable

Logically I think `asLoadable` is clearer and reduces switch size.
And enum `ordinal` field is already constant-folded: 
https://bugs.openjdk.org/browse/JDK-81612454
So it can be elided by JIT if the enum argument is constant.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20739#discussion_r1741000967

Reply via email to