Top Description Inners Fields Constructors Methods
org.codehaus.groovy.vmplugin.v8

public Class IndyInterface

extends Object
Class Inheritance
Imports
groovy.lang.GroovySystem, org.apache.groovy.util.SystemUtil, org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.runtime.NullObject, java.lang.invoke.CallSite, .ConstantCallSite, .MethodHandle, .MethodHandles, .MethodHandles.Lookup, .MethodType, .MutableCallSite, .SwitchPoint, java.util.Map, java.util.function.BiFunction, .Function, java.util.logging.Level, .Logger, java.util.stream.Collectors, .Stream

Bytecode level interface for bootstrap methods used by invokedynamic. This class provides a logging ability by using the boolean system property groovy.indy.logging. Other than that this class contains the interfacing methods with bytecode for invokedynamic as well as some helper methods and classes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
IndyInterface.CallType

Enum for easy differentiation between call types

private static class

Field Summary

Modifier and TypeField and Description
private static final MethodHandle
FROM_CACHE_METHOD

handle for the fromCache method

public static final int
GROOVY_OBJECT

flags for method and property calls

public static final int
IMPLICIT_THIS

flags for method and property calls

private static final long
private static final long
protected static final Logger
LOG

Logger

protected static final boolean
LOG_ENABLED

boolean to indicate if logging for indy is enabled

public static final MethodHandles.Lookup
LOOKUP

LOOKUP constant used for for example unreflect calls

private static final MethodHandleWrapper
public static final int
SAFE_NAVIGATION

flags for method and property calls

private static final MethodHandle
SELECT_METHOD

handle for the selectMethod method

public static final int
SPREAD_CALL

flags for method and property calls

protected static SwitchPoint
public static final int
THIS_CALL

flags for method and property calls

public static final int
UNCACHED_CALL

flags for method and property calls

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static CallSite

Returns:

the produced CallSite
bootstrap
(MethodHandles.Lookup
- the caller
caller
,
String
- the type of the call
callType
,
MethodType
- the call site type
type
,
String
- the real method name
name
,
int
- call flags
flags
)

bootstrap method for method calls from Groovy compiled code with indy enabled.

private static <T> T
doWithCallSite(MutableCallSite callSite, Object[] arguments, BiFunction<? super CacheableCallSite, ? super Object, ? extends T> f)

private static MethodHandleWrapper
fallback(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments)

public static Object
fromCache(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments)

Get the cached methodhandle.

protected static void
invalidateSwitchPoints()

Callback for constant meta class update change

private static MethodHandle
make(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall, MethodHandle originalMH)

private static MethodHandle
makeAdapter(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall)

Makes an adapter method for method selection, i.e. get the cached methodhandle(fast path) or fallback

protected static MethodHandle
makeFallBack(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall)

Makes a fallback method for an invalidated method selection

private static CallSite
realBootstrap(MethodHandles.Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall)

backing bootstrap method with all parameters

public static Object
selectMethod(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments)

Core method for indy method selection using runtime types.

public static CallSite
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FROM_CACHE_METHODback to summary
private static final MethodHandle FROM_CACHE_METHOD

handle for the fromCache method

GROOVY_OBJECTback to summary
public static final int GROOVY_OBJECT

flags for method and property calls

IMPLICIT_THISback to summary
public static final int IMPLICIT_THIS

flags for method and property calls

INDY_FALLBACK_THRESHOLDback to summary
private static final long INDY_FALLBACK_THRESHOLD
INDY_OPTIMIZE_THRESHOLDback to summary
private static final long INDY_OPTIMIZE_THRESHOLD
LOGback to summary
protected static final Logger LOG

Logger

LOG_ENABLEDback to summary
protected static final boolean LOG_ENABLED

boolean to indicate if logging for indy is enabled

LOOKUPback to summary
public static final MethodHandles.Lookup LOOKUP

LOOKUP constant used for for example unreflect calls

NULL_METHOD_HANDLE_WRAPPERback to summary
private static final MethodHandleWrapper NULL_METHOD_HANDLE_WRAPPER
SAFE_NAVIGATIONback to summary
public static final int SAFE_NAVIGATION

flags for method and property calls

SELECT_METHODback to summary
private static final MethodHandle SELECT_METHOD

handle for the selectMethod method

SPREAD_CALLback to summary
public static final int SPREAD_CALL

flags for method and property calls

switchPointback to summary
protected static SwitchPoint switchPoint
THIS_CALLback to summary
public static final int THIS_CALL

flags for method and property calls

UNCACHED_CALLback to summary
public static final int UNCACHED_CALL

flags for method and property calls

Constructor Detail

IndyInterfaceback to summary
public IndyInterface()

Method Detail

bootstrapback to summary
public static CallSite bootstrap(MethodHandles.Lookup caller, String callType, MethodType type, String name, int flags)

bootstrap method for method calls from Groovy compiled code with indy enabled. This method gets a flags parameter which uses the following encoding:

Parameters
caller:MethodHandles.Lookup

- the caller

callType:String

- the type of the call

type:MethodType

- the call site type

name:String

- the real method name

flags:int

- call flags

Returns:CallSite

the produced CallSite

Since
Groovy 2.1.0
doWithCallSiteback to summary
private static <T> T doWithCallSite(MutableCallSite callSite, Object[] arguments, BiFunction<? super CacheableCallSite, ? super Object, ? extends T> f)
fallbackback to summary
private static MethodHandleWrapper fallback(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments)
fromCacheback to summary
public static Object fromCache(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable

Get the cached methodhandle. if the related methodhandle is not found in the inline cache, cache and return it.

invalidateSwitchPointsback to summary
protected static void invalidateSwitchPoints()

Callback for constant meta class update change

makeback to summary
private static MethodHandle make(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall, MethodHandle originalMH)
makeAdapterback to summary
private static MethodHandle makeAdapter(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall)

Makes an adapter method for method selection, i.e. get the cached methodhandle(fast path) or fallback

makeFallBackback to summary
protected static MethodHandle makeFallBack(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall)

Makes a fallback method for an invalidated method selection

realBootstrapback to summary
private static CallSite realBootstrap(MethodHandles.Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall)

backing bootstrap method with all parameters

selectMethodback to summary
public static Object selectMethod(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable

Core method for indy method selection using runtime types.

staticArrayAccessback to summary
public static CallSite staticArrayAccess(MethodHandles.Lookup lookup, String name, MethodType type)
Since
2.5.0
org.codehaus.groovy.vmplugin.v8 back to summary

public final Enum IndyInterface.CallType

extends Enum<IndyInterface.CallType>
Class Inheritance

Enum for easy differentiation between call types

Field Summary

Modifier and TypeField and Description
public static final IndyInterface.CallType
CAST

Cast invocation type

public static final IndyInterface.CallType
GET

Get property invocation type

public static final IndyInterface.CallType
INIT

Constructor invocation type

public static final IndyInterface.CallType
METHOD

Method invocation type

private final String
name

Hides java.lang.Enum.name.

The name of the call site type
private static final Map<String, IndyInterface.CallType>
public static final IndyInterface.CallType
SET

Set property invocation type

Constructor Summary

AccessConstructor and Description
private
CallType(String callSiteName)

Method Summary

Modifier and TypeMethod and Description
public static IndyInterface.CallType
fromCallSiteName(String callSiteName)

public String
getCallSiteName()

Returns the name of the call site type

public static IndyInterface.CallType
public static IndyInterface.CallType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CASTback to summary
public static final IndyInterface.CallType CAST

Cast invocation type

GETback to summary
public static final IndyInterface.CallType GET

Get property invocation type

INITback to summary
public static final IndyInterface.CallType INIT

Constructor invocation type

METHODback to summary
public static final IndyInterface.CallType METHOD

Method invocation type

nameback to summary
private final String name

Hides java.lang.Enum.name.

The name of the call site type

NAME_CALLTYPE_MAPback to summary
private static final Map<String, IndyInterface.CallType> NAME_CALLTYPE_MAP
SETback to summary
public static final IndyInterface.CallType SET

Set property invocation type

Constructor Detail

CallTypeback to summary
private CallType(String callSiteName)

Method Detail

fromCallSiteNameback to summary
public static IndyInterface.CallType fromCallSiteName(String callSiteName)
getCallSiteNameback to summary
public String getCallSiteName()

Returns the name of the call site type

valueOfback to summary
public static IndyInterface.CallType valueOf(String name)
valuesback to summary
public static IndyInterface.CallType[] values()
org.codehaus.groovy.vmplugin.v8 back to summary

private Class IndyInterface.FallbackSupplier

extends Object
Class Inheritance
  • java.lang.Object
  • org.codehaus.groovy.vmplugin.v8.IndyInterface.FallbackSupplier

Field Summary

Modifier and TypeField and Description
private final Object[]
private final int
private final MutableCallSite
private final Object
private final String
private MethodHandleWrapper
private final Boolean
private final Class<?>
private final Boolean
private final Boolean

Constructor Summary

AccessConstructor and Description
pack-priv
FallbackSupplier(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments)

Method Summary

Modifier and TypeMethod and Description
pack-priv MethodHandleWrapper
get()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentsback to summary
private final Object[] arguments
callIDback to summary
private final int callID
callSiteback to summary
private final MutableCallSite callSite
dummyReceiverback to summary
private final Object dummyReceiver
methodNameback to summary
private final String methodName
resultback to summary
private MethodHandleWrapper result
safeNavigationback to summary
private final Boolean safeNavigation
senderback to summary
private final Class<?> sender
spreadCallback to summary
private final Boolean spreadCall
thisCallback to summary
private final Boolean thisCall

Constructor Detail

FallbackSupplierback to summary
pack-priv FallbackSupplier(MutableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments)

Method Detail

getback to summary
pack-priv MethodHandleWrapper get()