On Thu, 29 Aug 2024 05:11:36 GMT, Chen Liang <[email protected]> wrote:
>> This is a large method. By splitting it into multiple methods with the same
>> name, the caller can automatically select based on the different types of
>> parameters, avoiding this large call that cannot be inlined, which can also
>> improve startup performance.
>>
>> * current
>>
>> CodeBuilder {
>> default CodeBuilder loadConstant(ConstantDesc value) { ... }
>> }
>>
>> java.lang.classfile.CodeBuilder::loadConstant (465 bytes) failed to
>> inline: callee is too large
>
> src/java.base/share/classes/java/lang/classfile/CodeBuilder.java line 646:
>
>> 644: if (value instanceof Float ) return loadConstant((float)
>> value);
>> 645: if (value instanceof Double ) return loadConstant((double)
>> value);
>> 646: else return ldc(value);
>
> I think we need to rearrange this to follow the code style, like:
>
> if (value instanceof Number) {
> if (value instanceof Integer i)
> return loadConstant(i);
> if (value instanceof Long l)
> return loadConstant(l);
> if (value instanceof Float f)
> return loadConstant(f);
> if (value instanceof Double d)
> return loadConstant(d);
> }
> if (value == null || value == ConstantDescs.NULL)
> return aconst_null();
> return ldc(value);
Many parts of the existing JDK code are written in this style, which looks
clean and easy to read.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20761#discussion_r1735605374