public class ChainedCallSite extends AbstractRelinkableCallSite
MethodHandles.guardWithTest(MethodHandle, MethodHandle, MethodHandle)
. When this call site has to link a new
method handle and the length of the chain is already at the maximum, it will throw away the oldest method handle.
Switchpoint-invalidated handles in the chain are removed eagerly (on each linking request, and whenever a
switchpoint-invalidated method handle is traversed during invocation). There is currently no profiling
attached to the handles in the chain, so they are never reordered based on usage; the most recently linked method
handle is always at the start of the chain.Constructor and Description |
---|
ChainedCallSite(CallSiteDescriptor descriptor)
Creates a new chained call site.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getMaxChainLength()
The maximum number of method handles in the chain.
|
void |
relink(GuardedInvocation guardedInvocation,
MethodHandle fallback)
This method will be called by the dynamic linker every time the call site is normally relinked.
|
void |
resetAndRelink(GuardedInvocation guardedInvocation,
MethodHandle fallback)
This method will be called by the dynamic linker every time the call site is relinked and the linker wishes the
call site to throw away any prior linkage state.
|
getDescriptor, initialize
dynamicInvoker, getTarget, setTarget, syncAll
public ChainedCallSite(CallSiteDescriptor descriptor)
descriptor
- the descriptor for the call site.protected int getMaxChainLength()
public void relink(GuardedInvocation guardedInvocation, MethodHandle fallback)
RelinkableCallSite
GuardedInvocation
that the call site should incorporate into its target method handle. When this method
is called, the call site is allowed to keep other non-invalidated invocations around for implementation of
polymorphic inline caches and compose them with this invocation to form its final target.guardedInvocation
- the guarded invocation that the call site should incorporate into its target method
handle.fallback
- the fallback method. This is a method matching the method type of the call site that is supplied
by the DynamicLinker
to be used by this call site as a fallback when it can't invoke its target with the
passed arguments. The fallback method is such that when it's invoked, it'll try to discover the adequate target
for the invocation, subsequently invoke RelinkableCallSite.relink(GuardedInvocation, MethodHandle)
or
RelinkableCallSite.resetAndRelink(GuardedInvocation, MethodHandle)
, and finally invoke the target.public void resetAndRelink(GuardedInvocation guardedInvocation, MethodHandle fallback)
RelinkableCallSite
GuardedInvocation
that the call site
should use to build its target method handle. When this method is called, the call site is discouraged from
keeping previous state around, and is supposed to only link the current invocation.guardedInvocation
- the guarded invocation that the call site should use to build its target method handle.fallback
- the fallback method. This is a method matching the method type of the call site that is supplied
by the DynamicLinker
to be used by this call site as a fallback when it can't invoke its target with the
passed arguments. The fallback method is such that when it's invoked, it'll try to discover the adequate target
for the invocation, subsequently invoke RelinkableCallSite.relink(GuardedInvocation, MethodHandle)
or
RelinkableCallSite.resetAndRelink(GuardedInvocation, MethodHandle)
, and finally invoke the target.Copyright © 2013 Attila Szegedi. All rights reserved.