Package org.codehaus.groovy.vmplugin.v8
Class CacheableCallSite
java.lang.Object
java.lang.invoke.CallSite
java.lang.invoke.MutableCallSite
org.codehaus.groovy.vmplugin.v8.CacheableCallSite
Represents a cacheable call site, which can reduce the cost of resolving methods
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionCacheableCallSite(MethodType type, MethodHandles.Lookup lookup) Creates a cacheable call site for the supplied type and lookup context. -
Method Summary
Modifier and TypeMethodDescriptionorg.codehaus.groovy.vmplugin.v8.MethodHandleWrappergetAndPut(String className, MemoizeCache.ValueProvider<? super String, ? extends org.codehaus.groovy.vmplugin.v8.MethodHandleWrapper> valueProvider) Returns a cached method-handle wrapper for the receiver class, computing and storing it if needed.Returns the default target currently installed on this call site.Returns the fallback round counter.Returns the fallback target used when guards fail.Returns the lookup associated with this call site.longIncrements the number of fallback executions for this call site.org.codehaus.groovy.vmplugin.v8.MethodHandleWrapperStores a method-handle wrapper under the supplied cache key.voidResets the fallback count and advances the fallback round marker.voidsetDefaultTarget(MethodHandle defaultTarget) Stores the default target for this call site.voidsetFallbackTarget(MethodHandle fallbackTarget) Stores the fallback target used when guards fail.Methods inherited from class java.lang.invoke.MutableCallSite
dynamicInvoker, getTarget, setTarget, syncAll
-
Constructor Details
-
CacheableCallSite
Creates a cacheable call site for the supplied type and lookup context.- Parameters:
type- the call-site typelookup- the lookup used to unreflect targets
-
-
Method Details
-
getAndPut
public org.codehaus.groovy.vmplugin.v8.MethodHandleWrapper getAndPut(String className, MemoizeCache.ValueProvider<? super String, ? extends org.codehaus.groovy.vmplugin.v8.MethodHandleWrapper> valueProvider) Returns a cached method-handle wrapper for the receiver class, computing and storing it if needed.- Parameters:
className- the receiver cache keyvalueProvider- the provider used to compute a missing entry- Returns:
- the cached or newly created wrapper
-
put
public org.codehaus.groovy.vmplugin.v8.MethodHandleWrapper put(String name, org.codehaus.groovy.vmplugin.v8.MethodHandleWrapper mhw) Stores a method-handle wrapper under the supplied cache key.- Parameters:
name- the receiver cache keymhw- the wrapper to cache- Returns:
- the previously cached wrapper, or
nullif none existed
-
incrementFallbackCount
public long incrementFallbackCount()Increments the number of fallback executions for this call site.- Returns:
- the updated fallback count
-
resetFallbackCount
public void resetFallbackCount()Resets the fallback count and advances the fallback round marker. -
getFallbackRound
Returns the fallback round counter.- Returns:
- the fallback round counter
-
getDefaultTarget
Returns the default target currently installed on this call site.- Returns:
- the default target
-
setDefaultTarget
Stores the default target for this call site.- Parameters:
defaultTarget- the default target handle
-
getFallbackTarget
Returns the fallback target used when guards fail.- Returns:
- the fallback target
-
setFallbackTarget
Stores the fallback target used when guards fail.- Parameters:
fallbackTarget- the fallback target handle
-
getLookup
Returns the lookup associated with this call site.- Returns:
- the call-site lookup
-