[code-reflection] RFR: Concat Transform Optimizations [v6]

Ian Graves igraves at openjdk.org
Fri Jun 28 20:41:56 UTC 2024


On Fri, 28 Jun 2024 20:14:39 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> Ian Graves has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Updates and revisions
>
> src/java.base/share/classes/java/lang/reflect/code/analysis/StringConcatTransformer.java line 112:
> 
>> 110:         else {
>> 111:             appendType = JavaType.J_L_OBJECT;
>> 112:         }
> 
> I think you can simplify as its hard to follow the logic when the type is string. We can now collapse the append methods into one (the two methods were used in a prior version).
> e.g.,
> 
> private static Op append(Block.Builder block, Value builder, Value arg) {
>    TypeElement type = arg.type();
>    if (type.equals(JavaType.BYTE) || type.equals(JavaType.SHORT)) {
>        // Widen
>        arg = block.op(CoreOp.conv(JavaType.INT, arg));
>        type = JavaType.INT;
>     } else if (!type.equals(JavaType.J_L_STRING)) {
>         type = JavaType.J_L_OBJECT;
>     }
> 
>     MethodRef appendMethod = MethodRef.method(J_L_STRING_BUILDER, "append", J_L_STRING_BUILDER, type);
>     return CoreOp.invoke(appendMethod, builder, arg)
> }

Good move. Done.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/149#discussion_r1659299006


More information about the babylon-dev mailing list