RFR: 8295537: Debug tracing for resolved java.lang.invoke.CallSite [v2]
Ioi Lam
iklam at openjdk.org
Tue Oct 25 17:34:15 UTC 2022
> I've added a `java.lang.invoke.MethodHandle.TRACE_CALLSITE` property to show how invokedynamic call sites are resolved.
>
> For example:
>
>
> public class StrConcat {
> static String hello = "Hello";
> static String world = "World";
> public static void main(String args[]) {
> System.out.println(hello + world);
> System.out.println(hello + "World");
> }
> }
>
> $ java -Djava.lang.invoke.MethodHandle.TRACE_CALLSITE=true -cp . StrConcat
> ======== CallSite: StrConcat.main(StrConcat.java:5)
> BSM = java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:354)
> target class = java.lang.invoke.BoundMethodHandle$Species_L
> target = (String,String)String : BMH.reinvoke=Lambda(a0:L/SpeciesData[L => Species_L],a1:L,a2:L)=>{
> t3:L=Species_L.argL0(a0:L);
> t4:L=MethodHandle.invokeBasic(t3:L,a1:L,a2:L);t4:L}
> & BMH=[
> 0: MethodHandle = {(Object,Object)String : DMH.invokeStatic=Lambda(a0:L,a1:L,a2:L)=>{
> t3:L=DirectMethodHandle.internalMemberName(a0:L);
> t4:L=MethodHandle.linkToStatic(a1:L,a2:L,t3:L);t4:L}
> & DMH.MN=java.lang.StringConcatHelper.simpleConcat(Object,Object)String/invokeStatic
> }
> ]
> HelloWorld
> ======== CallSite: StrConcat.main(StrConcat.java:6)
> BSM = java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:354)
> target class = java.lang.invoke.BoundMethodHandle$Species_LL
> target = (String)String : invoke=Lambda(a0:L/SpeciesData[LL => BoundMethodHandle$Species_LL],a1:L)=>{
> t2:L=BoundMethodHandle$Species_LL.argL1(a0:L);
> t3:L=BoundMethodHandle$Species_LL.argL0(a0:L);
> t4:L=MethodHandle.invokeBasic(t3:L,a1:L,t2:L);t4:L}
> & BMH=[
> 0: MethodHandle = {(Object,Object)String : DMH.invokeStatic=Lambda(a0:L,a1:L,a2:L)=>{
> t3:L=DirectMethodHandle.internalMemberName(a0:L);
> t4:L=MethodHandle.linkToStatic(a1:L,a2:L,t3:L);t4:L}
> & DMH.MN=java.lang.StringConcatHelper.simpleConcat(Object,Object)String/invokeStatic
> }
> 1: ( World )
> ]
> HelloWorld
>
>
> More complex examples are in the JBS bug report
> - https://bugs.openjdk.org/secure/attachment/101170/eclipse-ide-log.txt
> - https://bugs.openjdk.org/secure/attachment/101168/lambda-expression.txt
> - https://bugs.openjdk.org/secure/attachment/101174/pattern-matching-switch.txt
> - https://bugs.openjdk.org/secure/attachment/101169/str-concat.txt
Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
@JornVernee comments
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/10842/files
- new: https://git.openjdk.org/jdk/pull/10842/files/b09baf43..94d7a900
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=10842&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=10842&range=00-01
Stats: 106 lines in 4 files changed: 29 ins; 73 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/10842.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10842/head:pull/10842
PR: https://git.openjdk.org/jdk/pull/10842
More information about the core-libs-dev
mailing list