RelinkableCallSite
public class ChainedCallSite extends AbstractRelinkableCallSite
GuardedInvocation
s 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.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 relinkAndInvoke)
This method will be called by the dynamic linker every time the call site
is relinked (but see
RelinkableCallSite.resetAndRelink(GuardedInvocation, MethodHandle) for an
exception). |
void |
resetAndRelink(GuardedInvocation guardedInvocation,
MethodHandle relinkAndInvoke)
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 (that is how it differs from
RelinkableCallSite.relink(GuardedInvocation, MethodHandle) ). |
getDescriptor, initialize
dynamicInvoker, getTarget, setTarget, syncAll
public ChainedCallSite(CallSiteDescriptor descriptor)
descriptor
- the descriptor for the call site.protected int getMaxChainLength()
RuntimeException
will be thrown.public void relink(GuardedInvocation guardedInvocation, MethodHandle relinkAndInvoke)
RelinkableCallSite
RelinkableCallSite.resetAndRelink(GuardedInvocation, MethodHandle)
for an
exception). It will be passed a 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.relinkAndInvoke
- a relink-and-invoke method handle. This is a
method handle matching the method type of the call site that is supplied
by the DynamicLinker
as a callback. It should be used by this
call site as the ultimate 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 obtain an adequate target GuardedInvocation
for the
invocation, and subsequently invoke
RelinkableCallSite.relink(GuardedInvocation, MethodHandle)
or
RelinkableCallSite.resetAndRelink(GuardedInvocation, MethodHandle)
, and finally
invoke the target.public void resetAndRelink(GuardedInvocation guardedInvocation, MethodHandle relinkAndInvoke)
RelinkableCallSite
RelinkableCallSite.relink(GuardedInvocation, MethodHandle)
). It will be passed a
GuardedInvocation
that the call site should use to build its new
target method handle. When this method is called, the call site is
discouraged from keeping any previous state, 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.relinkAndInvoke
- a relink-and-invoke method handle. This is a
method handle matching the method type of the call site that is supplied
by the DynamicLinker
as a callback. It should be used by this
call site as the ultimate 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 obtain an adequate target GuardedInvocation
for the
invocation, and subsequently invoke
RelinkableCallSite.relink(GuardedInvocation, MethodHandle)
or
RelinkableCallSite.resetAndRelink(GuardedInvocation, MethodHandle)
, and finally
invoke the target.
Copyright © 2015, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-09-03-162606.buildd.src