APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.lang.invoke

pack-priv Class InvokerBytecodeGenerator

extends Object
Class Inheritance
Imports
jdk.internal.constant.ClassOrInterfaceDescImpl, .ConstantUtils, .MethodTypeDescImpl, sun.invoke.util.VerifyAccess, .VerifyType, .Wrapper, java.lang.classfile.*, java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute, .SourceFileAttribute, java.lang.classfile.constantpool.ClassEntry, .ConstantPoolBuilder, .FieldRefEntry, java.lang.classfile.instruction.SwitchCase, java.lang.constant.ClassDesc, .ConstantDesc, .MethodTypeDesc, java.lang.invoke.LambdaForm.BasicType, .LambdaForm.Name, .LambdaForm.NamedFunction, java.lang.reflect.Modifier, java.util.ArrayList, .Arrays, .HashMap, .List, java.util.function.Consumer, java.util.stream.Stream

Code generation backend for LambdaForm.

Author
John Rose, JSR 292 EG

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static record

Field Summary

Modifier and TypeField and Description
private static final ClassDesc
CD_CasesHolder

Define class names for convenience.

private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final String
private final List<InvokerBytecodeGenerator.ClassData>
private final ClassEntry
private final String
pack-priv static final Annotation
private static final HashMap<String, Integer>
DUMP_CLASS_FILES_COUNTERS

instance counters for dumped classes

pack-priv static final Annotation
pack-priv static final Annotation
private static final Class<?>
pack-priv static final Annotation
pack-priv static final ClassDesc
INVOKER_SUPER_DESC

Name of its super class

private final String
private final MethodType
private final LambdaForm
pack-priv static final Annotation
public static final RuntimeVisibleAnnotationsAttribute
public static final RuntimeVisibleAnnotationsAttribute
public static final RuntimeVisibleAnnotationsAttribute
public static final RuntimeVisibleAnnotationsAttribute
private Class<?>[]
private int[]
localsMap

Info about local variables in compiled lambda form

private static final MethodHandles.Lookup
private static final MemberName.Factory
private static final MethodTypeDesc
private static final MethodTypeDesc
private static final MethodTypeDesc
private static final MethodTypeDesc
private final String
name

Name of new class

private final ConstantPoolBuilder
private static final String
private static final Class<?>[]

Constructor Summary

AccessConstructor and Description
private
InvokerBytecodeGenerator(LambdaForm lambdaForm, int localsMapSize, String name, String invokerName, MethodType invokerType)

Main constructor; other constructors delegate to this one.

private
InvokerBytecodeGenerator(String name, String invokerName, MethodType invokerType)

For generating LambdaForm interpreter entry points.

private
InvokerBytecodeGenerator(String name, LambdaForm form, MethodType invokerType)

For generating customized code for a single LambdaForm.

pack-priv
InvokerBytecodeGenerator(String name, String invokerName, LambdaForm form, MethodType invokerType)

For generating customized code for a single LambdaForm.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addMethod(ClassBuilder clb, boolean alive)

private boolean
assertStaticType(Class<?> cls, LambdaForm.Name n)

Update localClasses type map.

private void
bogusMethod(ClassBuilder clb, Object os)

Emit a bogus method that just loads some string constants.

private boolean
checkActualReceiver(CodeBuilder cob)

Generates code to check that actual receiver and LambdaForm matches

pack-priv FieldRefEntry
private Object
classDataValues()

Returns the class data object that will be passed to `Lookup.defineHiddenClassWithClassData`.

pack-priv static ClassDesc
classDesc(Class<?> cls)

private byte[]
classFileSetup(Consumer<? super ClassBuilder> config)

Set up class file generation.

pack-priv static void
pack-priv void
pack-priv void
pack-priv void
private void
emitBoxing(CodeBuilder cob, TypeKind tk)

Emit a boxing call.

private LambdaForm.Name
emitGuardWithCatch(CodeBuilder cob, int pos)

Emit bytecode for the guardWithCatch idiom.

private void
emitImplicitConversion(CodeBuilder cob, LambdaForm.BasicType
type of value present on stack
ptype
,
Class<?>
type of value required on stack
pclass
,
Object
compile-time representation of value on stack (Node, constant) or null if none
arg
)

Emit an implicit conversion for an argument which must be of the given pclass.

pack-priv void
emitInvoke(CodeBuilder cob, LambdaForm.Name name)

Emit an invoke for the given name.

private void
emitLoadInsn(CodeBuilder cob, TypeKind type, int index)

private LambdaForm.Name
emitLoop(CodeBuilder cob, int pos)

Emit bytecode for the loop idiom.

private void
emitLoopHandleInvoke(CodeBuilder cob, LambdaForm.Name holder, int handles, int clause, LambdaForm.Name args, boolean pushLocalState, MethodType type, Class<?>[] loopLocalStateTypes, int clauseDataSlot, int firstLoopStateSlot)

private void
private void
emitPrimCast(CodeBuilder cob, TypeKind from, TypeKind to)

Emit a type conversion bytecode casting from "from" to "to".

private void
emitPushArgument(CodeBuilder cob, LambdaForm.Name name, int paramIndex)

private void
private void
private void
emitPushClauseArray(CodeBuilder cob, int clauseDataSlot, int which)

private void
private void
emitReturn(CodeBuilder cob, LambdaForm.Name onStack)

Emits a return statement from a LF invoker.

private LambdaForm.Name
emitSelectAlternative(CodeBuilder cob, LambdaForm.Name selectAlternativeName, LambdaForm.Name invokeBasicName)

Emit bytecode for the selectAlternative idiom.

pack-priv void
pack-priv void
emitStaticInvoke(CodeBuilder cob, MemberName member, LambdaForm.Name name)

Emit an invoke for the given name, using the MemberName directly.

private void
emitStoreInsn(CodeBuilder cob, TypeKind type, int index)

private void
emitStoreResult(CodeBuilder cob, LambdaForm.Name name)

Store the name to its local, if necessary.

private LambdaForm.Name
emitTableSwitch(CodeBuilder cob, int pos, int numCases)

private LambdaForm.Name
emitTryFinally(CodeBuilder cob, int pos)

Emit bytecode for the tryFinally idiom.

private void
emitUnboxing(CodeBuilder cob, TypeKind target)

Emit an unboxing call (plus preceding checkcast).

private void
private int
extendLocalsMap(Class<?>[] types)

pack-priv static MemberName
generateCustomizedCode(LambdaForm form, MethodType invokerType)

Generate customized bytecode for a given LambdaForm.

private byte[]
generateCustomizedCodeBytes()

Generate an invoker method for the passed LambdaForm.

pack-priv static MemberName
generateLambdaFormInterpreterEntryPoint(MethodType mt)

Generate bytecode for a LambdaForm.vmentry which calls interpretWithArguments.

private byte[]
pack-priv static MemberName
generateNamedFunctionInvoker(MethodTypeForm typeForm)

Generate bytecode for a NamedFunction invoker.

private byte[]
pack-priv static boolean
pack-priv static boolean
pack-priv static boolean
private static boolean
pack-priv static boolean
private MemberName
loadMethod(byte[] classFile)

Extract the MemberName of a newly-defined method.

private static MethodHandles.Lookup
private static MemberName
lookupPregenerated(LambdaForm form, MethodType invokerType)

Look up a method that may have been generated by GenerateJLIClassesHelper.

private static String
pack-priv static MethodTypeDesc
private void
pack-priv Opcode
refKindOpcode(byte refKind)

private static MemberName
resolveFrom(String name, MethodType type, Class<?> holder)

private static MemberName
resolveInvokerMember(Class<?> invokerClass, String name, MethodType type)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CD_CasesHolderback to summary
private static final ClassDesc CD_CasesHolder

Define class names for convenience.

CD_DirectMethodHandleback to summary
private static final ClassDesc CD_DirectMethodHandle
CD_LambdaFormback to summary
private static final ClassDesc CD_LambdaForm
CD_LambdaForm_Nameback to summary
private static final ClassDesc CD_LambdaForm_Name
CD_LoopClausesback to summary
private static final ClassDesc CD_LoopClauses
CD_MemberNameback to summary
private static final ClassDesc CD_MemberName
CD_MethodHandle_arrayback to summary
private static final ClassDesc CD_MethodHandle_array
CD_MethodHandle_array2back to summary
private static final ClassDesc CD_MethodHandle_array2
CD_MethodHandleImplback to summary
private static final ClassDesc CD_MethodHandleImpl
CD_Object_arrayback to summary
private static final ClassDesc CD_Object_array
CLASS_PREFIXback to summary
private static final String CLASS_PREFIX
classDataback to summary
private final List<InvokerBytecodeGenerator.ClassData> classData
classEntryback to summary
private final ClassEntry classEntry
classNameback to summary
private final String className
DONTINLINEback to summary
pack-priv static final Annotation DONTINLINE
DUMP_CLASS_FILES_COUNTERSback to summary
private static final HashMap<String, Integer> DUMP_CLASS_FILES_COUNTERS

instance counters for dumped classes

FORCEINLINEback to summary
pack-priv static final Annotation FORCEINLINE
HIDDENback to summary
pack-priv static final Annotation HIDDEN
HOST_CLASSback to summary
private static final Class<?> HOST_CLASS
INJECTEDPROFILEback to summary
pack-priv static final Annotation INJECTEDPROFILE
INVOKER_SUPER_DESCback to summary
pack-priv static final ClassDesc INVOKER_SUPER_DESC

Name of its super class

invokerNameback to summary
private final String invokerName
invokerTypeback to summary
private final MethodType invokerType
lambdaFormback to summary
private final LambdaForm lambdaForm
LF_COMPILEDback to summary
pack-priv static final Annotation LF_COMPILED
LF_DONTINLINE_ANNOTATIONSback to summary
public static final RuntimeVisibleAnnotationsAttribute LF_DONTINLINE_ANNOTATIONS
LF_DONTINLINE_PROFILE_ANNOTATIONSback to summary
public static final RuntimeVisibleAnnotationsAttribute LF_DONTINLINE_PROFILE_ANNOTATIONS
LF_FORCEINLINE_ANNOTATIONSback to summary
public static final RuntimeVisibleAnnotationsAttribute LF_FORCEINLINE_ANNOTATIONS
LF_FORCEINLINE_PROFILE_ANNOTATIONSback to summary
public static final RuntimeVisibleAnnotationsAttribute LF_FORCEINLINE_PROFILE_ANNOTATIONS
localClassesback to summary
private Class<?>[] localClasses
localsMapback to summary
private int[] localsMap

Info about local variables in compiled lambda form

LOOKUPback to summary
private static final MethodHandles.Lookup LOOKUP
MEMBERNAME_FACTORYback to summary
private static final MemberName.Factory MEMBERNAME_FACTORY
MTD_boolean_Objectback to summary
private static final MethodTypeDesc MTD_boolean_Object
MTD_Object_Classback to summary
private static final MethodTypeDesc MTD_Object_Class
MTD_Object_intback to summary
private static final MethodTypeDesc MTD_Object_int
MTD_Object_Objectback to summary
private static final MethodTypeDesc MTD_Object_Object
nameback to summary
private final String name

Name of new class

poolback to summary
private final ConstantPoolBuilder pool
SOURCE_PREFIXback to summary
private static final String SOURCE_PREFIX
STATICALLY_INVOCABLE_PACKAGESback to summary
private static final Class<?>[] STATICALLY_INVOCABLE_PACKAGES

Constructor Detail

InvokerBytecodeGeneratorback to summary
private InvokerBytecodeGenerator(LambdaForm lambdaForm, int localsMapSize, String name, String invokerName, MethodType invokerType)

Main constructor; other constructors delegate to this one.

InvokerBytecodeGeneratorback to summary
private InvokerBytecodeGenerator(String name, String invokerName, MethodType invokerType)

For generating LambdaForm interpreter entry points.

InvokerBytecodeGeneratorback to summary
private InvokerBytecodeGenerator(String name, LambdaForm form, MethodType invokerType)

For generating customized code for a single LambdaForm.

InvokerBytecodeGeneratorback to summary
pack-priv InvokerBytecodeGenerator(String name, String invokerName, LambdaForm form, MethodType invokerType)

For generating customized code for a single LambdaForm.

Method Detail

addMethodback to summary
pack-priv void addMethod(ClassBuilder clb, boolean alive)
assertStaticTypeback to summary
private boolean assertStaticType(Class<?> cls, LambdaForm.Name n)

Update localClasses type map. Return true if the information is already present.

bogusMethodback to summary
private void bogusMethod(ClassBuilder clb, Object os)

Emit a bogus method that just loads some string constants. This is to get the constants into the constant pool for debugging purposes.

checkActualReceiverback to summary
private boolean checkActualReceiver(CodeBuilder cob)

Generates code to check that actual receiver and LambdaForm matches

classDataback to summary
pack-priv FieldRefEntry classData(ClassFileBuilder<?, ?> cfb, Object arg, ClassDesc desc)
classDataValuesback to summary
private Object classDataValues()

Returns the class data object that will be passed to `Lookup.defineHiddenClassWithClassData`. The classData is loaded in the method of the generated class. If the class data contains only one single object, this method returns that single object. If the class data contains more than one objects, this method returns a List. This method returns null if no class data.

classDescback to summary
pack-priv static ClassDesc classDesc(Class<?> cls)
classFileSetupback to summary
private byte[] classFileSetup(Consumer<? super ClassBuilder> config)

Set up class file generation.

clinitback to summary
pack-priv static void clinit(ClassBuilder clb, ClassEntry classEntry, List<InvokerBytecodeGenerator.ClassData> classData)
emitArrayLengthback to summary
pack-priv void emitArrayLength(CodeBuilder cob, LambdaForm.Name name)
emitArrayLoadback to summary
pack-priv void emitArrayLoad(CodeBuilder cob, LambdaForm.Name name)
emitArrayStoreback to summary
pack-priv void emitArrayStore(CodeBuilder cob, LambdaForm.Name name)
emitBoxingback to summary
private void emitBoxing(CodeBuilder cob, TypeKind tk)

Emit a boxing call.

emitGuardWithCatchback to summary
private LambdaForm.Name emitGuardWithCatch(CodeBuilder cob, int pos)

Emit bytecode for the guardWithCatch idiom. The pattern looks like (Cf. MethodHandleImpl.makeGuardWithCatch):

guardWithCatch=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L,a6:L,a7:L)=>{
   t8:L=MethodHandle.invokeBasic(a4:L,a6:L,a7:L);
   t9:L=MethodHandleImpl.guardWithCatch(a1:L,a2:L,a3:L,t8:L);
  t10:I=MethodHandle.invokeBasic(a5:L,t9:L);t10:I}
It is compiled into bytecode equivalent of the following code:
try {
     return a1.invokeBasic(a6, a7);
 } catch (Throwable e) {
     if (!a2.isInstance(e)) throw e;
     return a3.invokeBasic(ex, a6, a7);
 }
emitImplicitConversionback to summary
private void emitImplicitConversion(CodeBuilder cob, LambdaForm.BasicType ptype, Class<?> pclass, Object arg)

Emit an implicit conversion for an argument which must be of the given pclass. This is usually a no-op, except when pclass is a subword type or a reference other than Object or an interface.

Parameters
ptype:LambdaForm.BasicType

type of value present on stack

pclass:Class<?>

type of value required on stack

arg:Object

compile-time representation of value on stack (Node, constant) or null if none

emitInvokeback to summary
pack-priv void emitInvoke(CodeBuilder cob, LambdaForm.Name name)

Emit an invoke for the given name.

emitLoadInsnback to summary
private void emitLoadInsn(CodeBuilder cob, TypeKind type, int index)
emitLoopback to summary
private LambdaForm.Name emitLoop(CodeBuilder cob, int pos)

Emit bytecode for the loop idiom.

The pattern looks like (Cf. MethodHandleImpl.loop):

// a0: BMH
// a1: LoopClauses (containing an array of arrays: inits, steps, preds, finis)
// a2: box, a3: unbox
// a4 (and following): arguments
loop=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L)=>{
  t5:L=MethodHandle.invokeBasic(a2:L,a4:L);          // box the arguments into an Object[]
  t6:L=MethodHandleImpl.loop(bt:L,a1:L,t5:L);        // call the loop executor (with supplied types in bt)
  t7:L=MethodHandle.invokeBasic(a3:L,t6:L);t7:L}     // unbox the result; return the result

It is compiled into bytecode equivalent to the code seen in MethodHandleImpl#loop(BasicType[], MethodHandleImpl.LoopClauses, Object...), with the difference that no arrays will be used for local state storage. Instead, the local state will be mapped to actual stack slots.

Bytecode generation applies an unrolling scheme to enable better bytecode generation regarding local state type handling. The generated bytecode will have the following form (void types are ignored for convenience). Assume there are C clauses in the loop.

PREINIT: ALOAD_1
         CHECKCAST LoopClauses
         GETFIELD LoopClauses.clauses
         ASTORE clauseDataIndex          // place the clauses 2-dimensional array on the stack
INIT:    (INIT_SEQ for clause 1)
         ...
         (INIT_SEQ for clause C)
LOOP:    (LOOP_SEQ for clause 1)
         ...
         (LOOP_SEQ for clause C)
         GOTO LOOP
DONE:    ...

The INIT_SEQ_x sequence for clause x (with x ranging from 0 to C-1) has the following shape. Assume slot vx is used to hold the state for clause x.

INIT_SEQ_x:  ALOAD clauseDataIndex
             ICONST_0
             AALOAD      // load the inits array
             ICONST x
             AALOAD      // load the init handle for clause x
             load args
             INVOKEVIRTUAL MethodHandle.invokeBasic
             store vx

The LOOP_SEQ_x sequence for clause x (with x ranging from 0 to C-1) has the following shape. Again, assume slot vx is used to hold the state for clause x.

LOOP_SEQ_x:  ALOAD clauseDataIndex
             ICONST_1
             AALOAD              // load the steps array
             ICONST x
             AALOAD              // load the step handle for clause x
             load locals
             load args
             INVOKEVIRTUAL MethodHandle.invokeBasic
             store vx
             ALOAD clauseDataIndex
             ICONST_2
             AALOAD              // load the preds array
             ICONST x
             AALOAD              // load the pred handle for clause x
             load locals
             load args
             INVOKEVIRTUAL MethodHandle.invokeBasic
             IFNE LOOP_SEQ_x+1   // predicate returned false -> jump to next clause
             ALOAD clauseDataIndex
             ICONST_3
             AALOAD              // load the finis array
             ICONST x
             AALOAD              // load the fini handle for clause x
             load locals
             load args
             INVOKEVIRTUAL MethodHandle.invokeBasic
             GOTO DONE           // jump beyond end of clauses to return from loop
emitLoopHandleInvokeback to summary
private void emitLoopHandleInvoke(CodeBuilder cob, LambdaForm.Name holder, int handles, int clause, LambdaForm.Name args, boolean pushLocalState, MethodType type, Class<?>[] loopLocalStateTypes, int clauseDataSlot, int firstLoopStateSlot)
emitPopInsnback to summary
private void emitPopInsn(CodeBuilder cob, LambdaForm.BasicType type)
emitPrimCastback to summary
private void emitPrimCast(CodeBuilder cob, TypeKind from, TypeKind to)

Emit a type conversion bytecode casting from "from" to "to".

emitPushArgumentback to summary
private void emitPushArgument(CodeBuilder cob, LambdaForm.Name name, int paramIndex)
emitPushArgumentback to summary
private void emitPushArgument(CodeBuilder cob, Class<?> ptype, Object arg)
emitPushArgumentsback to summary
private void emitPushArguments(CodeBuilder cob, LambdaForm.Name args, int start)
emitPushClauseArrayback to summary
private void emitPushClauseArray(CodeBuilder cob, int clauseDataSlot, int which)
emitReferenceCastback to summary
private void emitReferenceCast(CodeBuilder cob, Class<?> cls, Object arg)
emitReturnback to summary
private void emitReturn(CodeBuilder cob, LambdaForm.Name onStack)

Emits a return statement from a LF invoker. If required, the result type is cast to the correct return type.

emitSelectAlternativeback to summary
private LambdaForm.Name emitSelectAlternative(CodeBuilder cob, LambdaForm.Name selectAlternativeName, LambdaForm.Name invokeBasicName)

Emit bytecode for the selectAlternative idiom. The pattern looks like (Cf. MethodHandleImpl.makeGuardWithTest):

Lambda(a0:L,a1:I)=>{
    t2:I=foo.test(a1:I);
    t3:L=MethodHandleImpl.selectAlternative(t2:I,(MethodHandle(int)int),(MethodHandle(int)int));
    t4:I=MethodHandle.invokeBasic(t3:L,a1:I);t4:I}
emitStaticInvokeback to summary
pack-priv void emitStaticInvoke(CodeBuilder cob, LambdaForm.Name name)
emitStaticInvokeback to summary
pack-priv void emitStaticInvoke(CodeBuilder cob, MemberName member, LambdaForm.Name name)

Emit an invoke for the given name, using the MemberName directly.

emitStoreInsnback to summary
private void emitStoreInsn(CodeBuilder cob, TypeKind type, int index)
emitStoreResultback to summary
private void emitStoreResult(CodeBuilder cob, LambdaForm.Name name)

Store the name to its local, if necessary.

emitTableSwitchback to summary
private LambdaForm.Name emitTableSwitch(CodeBuilder cob, int pos, int numCases)
emitTryFinallyback to summary
private LambdaForm.Name emitTryFinally(CodeBuilder cob, int pos)

Emit bytecode for the tryFinally idiom.

The pattern looks like (Cf. MethodHandleImpl.makeTryFinally):

// a0: BMH
// a1: target, a2: cleanup
// a3: box, a4: unbox
// a5 (and following): arguments
tryFinally=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L)=>{
  t6:L=MethodHandle.invokeBasic(a3:L,a5:L);         // box the arguments into an Object[]
  t7:L=MethodHandleImpl.tryFinally(a1:L,a2:L,t6:L); // call the tryFinally executor
  t8:L=MethodHandle.invokeBasic(a4:L,t7:L);t8:L}    // unbox the result; return the result

It is compiled into bytecode equivalent to the following code:

Throwable t;
Object r;
try {
    r = a1.invokeBasic(a5);
} catch (Throwable thrown) {
    t = thrown;
    throw t;
} finally {
    r = a2.invokeBasic(t, r, a5);
}
return r;

Specifically, the bytecode will have the following form (the stack effects are given for the beginnings of blocks, and for the situations after executing the given instruction - the code will have a slightly different shape if the return type is void):

TRY:                 (--)
                     load target                             (-- target)
                     load args                               (-- args... target)
                     INVOKEVIRTUAL MethodHandle.invokeBasic  (depends)
FINALLY_NORMAL:      (-- r_2nd* r)
                     store returned value                    (--)
                     load cleanup                            (-- cleanup)
                     ACONST_NULL                             (-- t cleanup)
                     load returned value                     (-- r_2nd* r t cleanup)
                     load args                               (-- args... r_2nd* r t cleanup)
                     INVOKEVIRTUAL MethodHandle.invokeBasic  (-- r_2nd* r)
                     GOTO DONE
CATCH:               (-- t)
                     DUP                                     (-- t t)
FINALLY_EXCEPTIONAL: (-- t t)
                     load cleanup                            (-- cleanup t t)
                     SWAP                                    (-- t cleanup t)
                     load default for r                      (-- r_2nd* r t cleanup t)
                     load args                               (-- args... r_2nd* r t cleanup t)
                     INVOKEVIRTUAL MethodHandle.invokeBasic  (-- r_2nd* r t)
                     POP/POP2*                               (-- t)
                     ATHROW
DONE:                (-- r)
* = depends on whether the return type takes up 2 stack slots.
emitUnboxingback to summary
private void emitUnboxing(CodeBuilder cob, TypeKind target)

Emit an unboxing call (plus preceding checkcast).

emitZeroback to summary
private void emitZero(CodeBuilder cob, LambdaForm.BasicType type)
extendLocalsMapback to summary
private int extendLocalsMap(Class<?>[] types)
generateCustomizedCodeback to summary
pack-priv static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType)

Generate customized bytecode for a given LambdaForm.

generateCustomizedCodeBytesback to summary
private byte[] generateCustomizedCodeBytes()

Generate an invoker method for the passed LambdaForm.

generateLambdaFormInterpreterEntryPointback to summary
pack-priv static MemberName generateLambdaFormInterpreterEntryPoint(MethodType mt)

Generate bytecode for a LambdaForm.vmentry which calls interpretWithArguments.

generateLambdaFormInterpreterEntryPointBytesback to summary
private byte[] generateLambdaFormInterpreterEntryPointBytes()
generateNamedFunctionInvokerback to summary
pack-priv static MemberName generateNamedFunctionInvoker(MethodTypeForm typeForm)

Generate bytecode for a NamedFunction invoker.

generateNamedFunctionInvokerImplback to summary
private byte[] generateNamedFunctionInvokerImpl(MethodTypeForm typeForm)
isStaticallyInvocableback to summary
pack-priv static boolean isStaticallyInvocable(LambdaForm.NamedFunction... functions)
isStaticallyInvocableback to summary
pack-priv static boolean isStaticallyInvocable(LambdaForm.Name name)
isStaticallyInvocableback to summary
pack-priv static boolean isStaticallyInvocable(MemberName member)
isStaticallyInvocableTypeback to summary
private static boolean isStaticallyInvocableType(MethodType mtype)
isStaticallyNameableback to summary
pack-priv static boolean isStaticallyNameable(Class<?> cls)
loadMethodback to summary
private MemberName loadMethod(byte[] classFile)

Extract the MemberName of a newly-defined method.

lookupback to summary
private static MethodHandles.Lookup lookup()
lookupPregeneratedback to summary
private static MemberName lookupPregenerated(LambdaForm form, MethodType invokerType)

Look up a method that may have been generated by GenerateJLIClassesHelper.

makeDumpableClassNameback to summary
private static String makeDumpableClassName(String className)
methodDescback to summary
pack-priv static MethodTypeDesc methodDesc(MethodType mt)
methodSetupback to summary
private void methodSetup(ClassBuilder clb, Consumer<? super MethodBuilder> config)
refKindOpcodeback to summary
pack-priv Opcode refKindOpcode(byte refKind)
resolveFromback to summary
private static MemberName resolveFrom(String name, MethodType type, Class<?> holder)
resolveInvokerMemberback to summary
private static MemberName resolveInvokerMember(Class<?> invokerClass, String name, MethodType type)
java.lang.invoke back to summary

pack-priv final Class InvokerBytecodeGenerator.BytecodeGenerationException

extends RuntimeException
Class Inheritance
Annotations
@SuppressWarnings:serial

The BytecodeGenerationException.

Constructor Summary

AccessConstructor and Description
pack-priv

Constructor Detail

BytecodeGenerationExceptionback to summary
pack-priv BytecodeGenerationException(Exception cause)
java.lang.invoke back to summary

pack-priv final Record InvokerBytecodeGenerator.ClassData

extends Record
Class Inheritance
Record Components
field:FieldRefEntry 
value:Object 

Field Summary

Modifier and TypeField and Description
private final FieldRefEntry
field

Record Component accessed by field().

private final Object
value

Record Component accessed by value().

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public FieldRefEntry
field()

Record Component getter of field.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public Object
value()

Record Component getter of value.

Field Detail

fieldback to summary
private final FieldRefEntry field

Record Component accessed by field().

valueback to summary
private final Object value

Record Component accessed by value().

Constructor Detail

ClassDataback to summary
pack-priv ClassData(FieldRefEntry field, Object value)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
fieldback to summary
public FieldRefEntry field()

Record Component getter of field.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

valueback to summary
public Object value()

Record Component getter of value.