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.org.codehaus.groovy.vmplugin.v8.MethodHandleWrappergetIfPresent(String className) Read-only PIC lookup: the cached wrapper for the receiver class, ornullwhen absent or its soft reference has been cleared.Returns the lookup associated with this call site.longIncrements the number of fallback executions for this call site.booleanWhether this site was linked in AOT mode (GraalVM native image, or thegroovy.indy.aot.linkdiagnostic knob): the site is wrapped in aConstantCallSiteover the cache-consulting default path, is never retargeted, and cache freshness is carried by theAotDispatchstamp instead of SwitchPoints.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.voidsetTarget(MethodHandle newTarget) Fails fast on any retarget attempt in AOT mode.Methods inherited from class java.lang.invoke.MutableCallSite
dynamicInvoker, getTarget, 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
-
isAotLinked
public boolean isAotLinked()Whether this site was linked in AOT mode (GraalVM native image, or thegroovy.indy.aot.linkdiagnostic knob): the site is wrapped in aConstantCallSiteover the cache-consulting default path, is never retargeted, and cache freshness is carried by theAotDispatchstamp instead of SwitchPoints. -
setTarget
Fails fast on any retarget attempt in AOT mode. Under a real native imagesetTargetthrowsUnsupportedFeatureErroranyway — and worse, execution would continue with the stale target if that error were swallowed — so a missed gate is a bug on every platform; this surfaces it on the JVM, where tests run with the diagnostic knob.- Overrides:
setTargetin classMutableCallSite
-
getIfPresent
Read-only PIC lookup: the cached wrapper for the receiver class, ornullwhen absent or its soft reference has been cleared. Used by the AOT dispatch path, which resolves misses itself and must not pay for a value-provider allocation per call.- Parameters:
className- the receiver cache key- Returns:
- the cached wrapper or
null
-
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
-