APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.dynalink.support

public Class ChainedCallSite

extends AbstractRelinkableCallSite
Class Inheritance
Imports
java.lang.invoke.MethodHandle, .MethodHandles, java.util.Arrays, .LinkedList, jdk.dynalink.CallSiteDescriptor, jdk.dynalink.linker.GuardedInvocation, jdk.dynalink.linker.support.Lookup

A relinkable call site that implements a polymorphic inline caching strategy. It remembers up to 8 GuardedInvocations it was linked with, and on each relink request builds a cascading chain of method handles of one invocation falling back to the next one. The number of remembered invocations can be customized by overriding getMaxChainLength() in a subclass. When this call site is relinked with a new invocation and the length of the chain is already at the maximum, it will throw away the oldest invocation. Invocations with invalidated switch points and ones for which their invalidating exception triggered are removed eagerly from the chain. The invocations are never reordered; the most recently linked method handle is always at the start of the chain and the least recently linked at its end. The call site can be safely relinked on more than one thread concurrently. Race conditions in linking are resolved by throwing away the GuardedInvocation produced on the losing thread without incorporating it into the chain, so it can lead to repeated linking for the same arguments.
Since
9

Field Summary

Modifier and TypeField and Description
private Object
invocations

Contains the invocations currently linked into this call site's target.

private static final MethodHandle
private static final MethodHandle

Constructor Summary

AccessConstructor and Description
public
ChainedCallSite(final CallSiteDescriptor
the descriptor for the call site.
descriptor
)

Creates a new chained call site.

Method Summary

Modifier and TypeMethod and Description
private static int
checkMaxChainLength(final int maxChainLength)

protected int

Returns:

the maximum number of method handles in the chain. The return value is checked, and if your override returns a value less than 1, a RuntimeException will be thrown.
getMaxChainLength
()

The maximum number of method handles in the chain.

private MethodHandle

Returns:

a method handle for prune-and-invoke
makePruneAndInvokeMethod
(final MethodHandle
the ultimate fallback for the chain passed from the dynamic linker.
relinkAndInvoke
,
final MethodHandle prune)

Creates a method that rebuilds our call chain, pruning it of any invalidated switchpoints, and then invokes that chain.

private MethodHandle
prune(final MethodHandle relink, final boolean catches)

private MethodHandle
relinkInternal(final GuardedInvocation invocation, final MethodHandle relink, final boolean reset, final boolean removeCatches)

Inherited from jdk.dynalink.support.AbstractRelinkableCallSite:
getDescriptorinitialize

Field Detail

invocationsback to summary
private Object invocations

Contains the invocations currently linked into this call site's target. They are used when we are relinking to rebuild the guardWithTest chain. Valid values for this field are: null if there's no linked invocations, or an instance of GuardedInvocation if there is exactly one previous invocation, or an instance of GuardedInvocation[] if there is more than one previous invocation.

PRUNE_CATCHESback to summary
private static final MethodHandle PRUNE_CATCHES
PRUNE_SWITCHPOINTSback to summary
private static final MethodHandle PRUNE_SWITCHPOINTS

Constructor Detail

ChainedCallSiteback to summary
public ChainedCallSite(final CallSiteDescriptor descriptor)

Creates a new chained call site.

Parameters
descriptor:CallSiteDescriptor

the descriptor for the call site.

Method Detail

checkMaxChainLengthback to summary
private static int checkMaxChainLength(final int maxChainLength)
getMaxChainLengthback to summary
protected int getMaxChainLength()

The maximum number of method handles in the chain. Defaults to 8. You can override it in a subclass if you need to change the value.

Returns:int

the maximum number of method handles in the chain. The return value is checked, and if your override returns a value less than 1, a RuntimeException will be thrown.

makePruneAndInvokeMethodback to summary
private MethodHandle makePruneAndInvokeMethod(final MethodHandle relinkAndInvoke, final MethodHandle prune)

Creates a method that rebuilds our call chain, pruning it of any invalidated switchpoints, and then invokes that chain.

Parameters
relinkAndInvoke:MethodHandle

the ultimate fallback for the chain passed from the dynamic linker.

Returns:MethodHandle

a method handle for prune-and-invoke

pruneback to summary
private MethodHandle prune(final MethodHandle relink, final boolean catches)
Annotations
@SuppressWarnings:unused
relinkInternalback to summary
private MethodHandle relinkInternal(final GuardedInvocation invocation, final MethodHandle relink, final boolean reset, final boolean removeCatches)