Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@PaintNinja
Copy link

Allows for more efficient LDC bytecode for supported primitives.

Example:

int count(Object o) {
    return ldc(() -> count);
}

Before:

count(Ljava/lang/Object;)I
   L0
    LINENUMBER 25 L0
    LDC 2 : Ljava/lang/Integer; java/lang/invoke/ConstantBootstraps.invoke(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object; (6) [DyconTest.lambda$count$1()Ljava/lang/Integer; (6)]
    INVOKEVIRTUAL java/lang/Integer.intValue ()I
    IRETURN
   L1
    LOCALVARIABLE this LDyconTest; L0 L1 0
    LOCALVARIABLE o Ljava/lang/Object; L0 L1 1
    MAXSTACK = 1
    MAXLOCALS = 2

After:

count(Ljava/lang/Object;)I
   L0
    LINENUMBER 27 L0
    LDC 2 : I java/lang/invoke/ConstantBootstraps.invoke(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object; (6) [DyconTest.lambda$count$1()I (6)]
    IRETURN
   L1
    LOCALVARIABLE this LDyconTest; L0 L1 0
    LOCALVARIABLE o Ljava/lang/Object; L0 L1 1
    MAXSTACK = 1
    MAXLOCALS = 2

(Note the lack of an Integer#intValue() call)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant