forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 1
Demo caching VarHandle in static fields and in CONSTANT_dynamic #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
retronym
wants to merge
4
commits into
2.13.x
Choose a base branch
from
condy
base: 2.13.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```
public class Staticify {
// compiled from: <console>
@Lscala/reflect/ScalaSignature;(bytes="\u0006\u0005A2A!\u0002\u0004\u0001\u0013!)\u0001\u0003\u0001C\u0001#!)A\u0003\u0001C\u0001+!!\u0011\u0005\u0001\u0001#\u0011\u001dI\u0003\u0001\"A\u0001\u0002)\u0012\u0011b\u0015;bi&\u001c\u0017NZ=\u000b\u0003\u001d\u0009q\u0001P3naRLhh\u0001\u0001\u0014\u0005\u0001Q\u0001CA\u0006\u000f\u001b\u0005a!\"A\u0007\u0002\u000bM\u001c\u0017\r\\1\n\u0005=a!AB!osJ+g-\u0001\u0004=S:LGO\u0010\u000b\u0002%A\u00111\u0003A\u0007\u0002\r\u00051A-\u001b:fGR,\u0012A\u0006\u0009\u0003/yq!\u0001\u0007\u000f\u0011\u0005eaQ\"\u0001\u000e\u000b\u0005mA\u0011A\u0002\u001fs_>$h(\u0003\u0002\u001e\u0019\u00051\u0001K]3eK\u001aL!a\u0008\u0011\u0003\rM#(/\u001b8h\u0015\u0009iB\"A\u0006eSJ,7\r\u001e\u0013j[Bd\u0007CA\u0012)\u001b\u0005!#BA\u0013'\u0003\u0011a\u0017M\\4\u000b\u0003\u001d\nAA[1wC&\u0011q\u0004J\u0001\nI&\u0014Xm\u0019;%m\"\u0004\"a\u000b\u0018\u000e\u00031R!!\u000c\u0013\u0002\r%tgo\\6f\u0013\u0009yCFA\u0005WCJD\u0015M\u001c3mK\u0002")
ATTRIBUTE ScalaSig : unknown
ATTRIBUTE ScalaInlineInfo : unknown
// access flags 0x19
public final static INNERCLASS java/lang/invoke/MethodHandles$Lookup java/lang/invoke/MethodHandles Lookup
// access flags 0x11
public final Ljava/lang/String; direct$impl
// access flags 0x19
public final static Ljava/lang/invoke/VarHandle; direct$vh
// access flags 0x9
public static <clinit>()V
L0
LINENUMBER 1 L0
INVOKESTATIC java/lang/invoke/MethodHandles.lookup ()Ljava/lang/invoke/MethodHandles$Lookup;
LDC LStaticify;.class
LDC "direct$impl"
LDC Ljava/lang/String;.class
INVOKEVIRTUAL java/lang/invoke/MethodHandles$Lookup.findVarHandle (Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;
PUTSTATIC Staticify.direct$vh : Ljava/lang/invoke/VarHandle;
RETURN
MAXSTACK = 4
MAXLOCALS = 0
// access flags 0x1
public direct()Ljava/lang/String;
L0
LINENUMBER 1 L0
ACONST_NULL
ARETURN
L1
LOCALVARIABLE this LStaticify; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public <init>()V
L0
LINENUMBER 1 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
ALOAD 0
ACONST_NULL
PUTFIELD Staticify.direct$impl : Ljava/lang/String;
RETURN
L1
LOCALVARIABLE this LStaticify; L0 L1 0
MAXSTACK = 2
MAXLOCALS = 1
}
```
Treat:
ConstantBootstaps.findVarHandle(...)
as an intrinsic if called with literal arguments and emit it
as with constant-dynamic.
```
// class version 55.0 (55)
// access flags 0x21
public class Staticify {
// compiled from: <console>
@Lscala/reflect/ScalaSignature;(bytes="\u0006\u0005Y2AAB\u0004\u0001\u0015!)\u0011\u0003\u0001C\u0001%!)Q\u0003\u0001C\u0001-!)!\u0005\u0001C\u0001G!!A\u0006\u0001\u0001.\u0011\u001dy\u0003\u0001\"A\u0001\u0002A\u0012\u0011b\u0015;bi&\u001c\u0017NZ=\u000b\u0003!\u0009q\u0001P3naRLhh\u0001\u0001\u0014\u0005\u0001Y\u0001C\u0001\u0007\u0010\u001b\u0005i!\"\u0001\u0008\u0002\u000bM\u001c\u0017\r\\1\n\u0005Ai!AB!osJ+g-\u0001\u0004=S:LGO\u0010\u000b\u0002'A\u0011A\u0003A\u0007\u0002\u000f\u00051A-\u001b:fGR,\u0012a\u0006\u0009\u00031}q!!G\u000f\u0011\u0005iiQ\"A\u000e\u000b\u0005qI\u0011A\u0002\u001fs_>$h(\u0003\u0002\u001f\u001b\u00051\u0001K]3eK\u001aL!\u0001I\u0011\u0003\rM#(/\u001b8h\u0015\u0009qR\"A\u0006vg\u0016$\u0015N]3diZCU#\u0001\u0013\u0011\u0005\u0015RS\"\u0001\u0014\u000b\u0005\u001dB\u0013\u0001\u00027b]\u001eT\u0011!K\u0001\u0005U\u00064\u0018-\u0003\u0002,M\u00091qJ\u00196fGR\u000c1\u0002Z5sK\u000e$H%[7qYB\u0011QEL\u0005\u0003A\u0019\n\u0011\u0002Z5sK\u000e$HE\u001e5\u0011\u0005E\"T\"\u0001\u001a\u000b\u0005M2\u0013AB5om>\\W-\u0003\u00026e\u0009Ia+\u0019:IC:$G.\u001a")
ATTRIBUTE ScalaSig : unknown
ATTRIBUTE ScalaInlineInfo : unknown
// access flags 0x19
public final static INNERCLASS java/lang/invoke/MethodHandles$Lookup java/lang/invoke/MethodHandles Lookup
// access flags 0x11
public final Ljava/lang/String; direct$impl
// access flags 0x19
public final static Ljava/lang/invoke/VarHandle; direct$vh
// access flags 0x9
public static <clinit>()V
L0
LINENUMBER 6 L0
INVOKESTATIC java/lang/invoke/MethodHandles.lookup ()Ljava/lang/invoke/MethodHandles$Lookup;
LDC LStaticify;.class
LDC "direct$impl"
LDC Ljava/lang/String;.class
INVOKEVIRTUAL java/lang/invoke/MethodHandles$Lookup.findVarHandle (Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;
PUTSTATIC Staticify.direct$vh : Ljava/lang/invoke/VarHandle;
L1
LINENUMBER 2 L1
RETURN
MAXSTACK = 4
MAXLOCALS = 0
// access flags 0x1
public direct()Ljava/lang/String;
L0
LINENUMBER 6 L0
ACONST_NULL
ARETURN
L1
LOCALVARIABLE this LStaticify; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public useDirectVH()Ljava/lang/Object;
L0
LINENUMBER 9 L0
LDC direct$impl : Ljava/lang/invoke/VarHandle; java/lang/invoke/ConstantBootstraps.fieldVarHandle(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle; (6) [LStaticify;, Ljava/lang/String;]
ASTORE 1
L1
LINENUMBER 10 L1
ALOAD 1
ALOAD 0
INVOKEVIRTUAL java/lang/invoke/VarHandle.get (LStaticify;)Ljava/lang/Object;
ARETURN
L2
LOCALVARIABLE vh Ljava/lang/invoke/VarHandle; L1 L2 1
LOCALVARIABLE this LStaticify; L0 L2 0
MAXSTACK = 2
MAXLOCALS = 2
// access flags 0x1
public <init>()V
L0
LINENUMBER 2 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
L1
LINENUMBER 3 L1
ALOAD 0
INVOKEVIRTUAL Staticify.useDirectVH ()Ljava/lang/Object;
POP
L2
LINENUMBER 6 L2
ALOAD 0
ACONST_NULL
PUTFIELD Staticify.direct$impl : Ljava/lang/String;
L3
LINENUMBER 2 L3
RETURN
L4
LOCALVARIABLE this LStaticify; L0 L4 0
MAXSTACK = 2
MAXLOCALS = 1
}
```
Refactor previous change to treat: ConstantBootstaps.*(...) as an intrinsic if called with literal arguments and emit it as with constant-dynamic. _AND_ to let macros or compiler plugins emit ApplyDynamic trees
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.