RFR: 8336856: Optimize String Concat [v11]
Shaojin Wen
duke at openjdk.org
Wed Jul 24 14:59:33 UTC 2024
On Wed, 24 Jul 2024 14:34:01 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 32 commits:
>>
>> - Merge remote-tracking branch 'upstream/master' into optim_concat_factory_202407
>> - typo
>> - change comments
>> - minor refactor
>> - minor refactor
>> - reduce change
>> - copyright
>> - reduce change
>> - refactor based on 8335182
>> - use Float.toString & Double.toString
>> - ... and 22 more: https://git.openjdk.org/jdk/compare/05d88de0...6faecfd7
>
> src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 1119:
>
>> 1117:
>> 1118: private static MethodHandle generate(Lookup lookup, MethodType args, String[] constants) throws Exception {
>> 1119: lookup = MethodHandles.Lookup.IMPL_LOOKUP;
>
> I think you can try moving the inline copy generation to java.lang's StringConcatHelper; this way, we don't need to expose stringSize, coder etc. through JavaLangAccess (we may update String impl detail in the future) and just access the generated MethodHandle.
If you do not use TRUSTED Lookup, errors will occur when processing records.
You can see this build error https://github.com/wenshao/jdk/actions/runs/10049344961/job/27775952878
TEST: java/lang/reflect/records/RecordReflectionTest.java
Caused by: java.lang.IllegalAccessException: no such method: java.lang.StringConcatHelper$$StringConcat/0xad1b77c0.concat(R1,R2,R3)String/invokeStatic
at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:906)
at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:989)
at java.base/java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:3750)
at java.base/java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:2648)
at java.base/java.lang.invoke.StringConcatFactory$SimpleStringBuilderStrategy.generate(StringConcatFactory.java:727)
... 41 more
Caused by: java.lang.LinkageError: bad method type alias: (R1,R2,R3)String not visible from class java.lang.StringConcatHelper$$StringConcat/0xad1b77c0
at java.base/java.lang.invoke.MemberName.ensureTypeVisible(MemberName.java:812)
at java.base/java.lang.invoke.MemberName$Factory.resolve(MemberName.java:961)
at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:986)
... 44 more
record R1() {}
record R2(int i, int j) {}
record R3(List<String> ls) {}
// error
record R4(R1 r1, R2 r2, R3 r3) {}
This PR also fixes the issue with TRUSTED not working in MemberName.java after using TRUSTED Lookup.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20273#discussion_r1689972638
More information about the core-libs-dev
mailing list