RFR: 8339704: Refactor StringConcatHelper simpleConcat [v6]
Shaojin Wen
swen at openjdk.org
Tue Sep 17 13:16:10 UTC 2024
On Tue, 10 Sep 2024 13:24:33 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 529:
>>
>>> 527: mh = simpleConcat3(paramType0);
>>> 528: mh = MethodHandles.insertArguments(mh, 0, prefix);
>>> 529: return MethodHandles.filterArguments(mh, 1, objectStringifier());
>>
>> While this is a fun trick it seems like there's a non-trivial cost here? We'd go down different paths and generate different classes for `"foo" + bar + baz` and `"foo" + bar + " .. " + baz` with this. Special casing when we get the added shapes for more or less free (plain `simpleConcat()`) is a different matter but here you need to construct a new couple of shapes with `insert-` and `filterArguments`.
>>
>> (Check on paramType1 could be `!paramType1.isPrimitive()`)
>
> I'm also not sure how much cost the simpleConcat handling of the 2 parameters would bring, I've removed that, and this is more appropriately implemented by the InlineHiddenClassStrategy.
If we handle the null values of prefix and suffix, the cost of supporting the 2-parameter scenario will be much lower.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20726#discussion_r1763226369
More information about the core-libs-dev
mailing list