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

public class CacheableCallSite extends MutableCallSite
Represents a cacheable call site, which can reduce the cost of resolving methods

Since:
  3.0.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CacheableCallSite(MethodType type, MethodHandles.Lookup lookup)`
  Creates a cacheable call site for the supplied type and lookup context.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `MethodHandle`
  `getDefaultTarget()`
  Returns the default target currently installed on this call site.
  `AtomicLong`
  `getFallbackRound()`
  Returns the fallback round counter.
  `MethodHandle`
  `getFallbackTarget()`
  Returns the fallback target used when guards fail.
  `MethodHandles.Lookup`
  `getLookup()`
  Returns the lookup associated with this call site.
  `long`
  `incrementFallbackCount()`
  Increments the number of fallback executions for this call site.
  `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.
  `void`
  `resetFallbackCount()`
  Resets the fallback count and advances the fallback round marker.
  `void`
  `setDefaultTarget(MethodHandle defaultTarget)`
  Stores the default target for this call site.
  `void`
  `setFallbackTarget(MethodHandle fallbackTarget)`
  Stores the fallback target used when guards fail.

  ### Methods inherited from class java.lang.invoke.MutableCallSite

  `dynamicInvoker, getTarget, setTarget, syncAll`

  ### Methods inherited from class java.lang.invoke.CallSite

  `type`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CacheableCallSite

    public CacheableCallSite(MethodType type, MethodHandles.Lookup lookup)
    Creates a cacheable call site for the supplied type and lookup context.
    Parameters:
      `type` - the call-site type
      `lookup` - 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 key
      `valueProvider` - 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 key
      `mhw` - the wrapper to cache
    Returns:
      the previously cached wrapper, or `null` if 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

    public AtomicLong getFallbackRound()
    Returns the fallback round counter.
    Returns:
      the fallback round counter

  - ### getDefaultTarget

    public MethodHandle getDefaultTarget()
    Returns the default target currently installed on this call site.
    Returns:
      the default target

  - ### setDefaultTarget

    public void setDefaultTarget(MethodHandle defaultTarget)
    Stores the default target for this call site.
    Parameters:
      `defaultTarget` - the default target handle

  - ### getFallbackTarget

    public MethodHandle getFallbackTarget()
    Returns the fallback target used when guards fail.
    Returns:
      the fallback target

  - ### setFallbackTarget

    public void setFallbackTarget(MethodHandle fallbackTarget)
    Stores the fallback target used when guards fail.
    Parameters:
      `fallbackTarget` - the fallback target handle

  - ### getLookup

    public MethodHandles.Lookup getLookup()
    Returns the lookup associated with this call site.
    Returns:
      the call-site lookup