AbstractRelinkableCallSite
, ChainedCallSite
, SimpleRelinkableCallSite
public interface RelinkableCallSite
DynamicLinker
. Users of
Dynalink must use subclasses of CallSite
that also implement this
interface as their call site implementations. There is a readily usable
SimpleRelinkableCallSite
subclass that implements monomorphic inline
caching strategy as well as ChainedCallSite
that implements a
polymorphic inline caching strategy and retains a chain of previously linked
method handles. A relinkable call site will be managed by a
DynamicLinker
object after being associated with it using its
DynamicLinker.link(RelinkableCallSite)
method.Modifier and Type | Method | Description |
---|---|---|
CallSiteDescriptor |
getDescriptor() |
Returns the descriptor for this call site.
|
void |
initialize(MethodHandle relinkAndInvoke) |
Invoked by dynamic linker to initialize the relinkable call site by
setting a relink-and-invoke method handle.
|
void |
relink(GuardedInvocation guardedInvocation,
MethodHandle relinkAndInvoke) |
This method will be called by the dynamic linker every time the call site
is relinked (but see
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
relink(GuardedInvocation, MethodHandle) ). |
void initialize(MethodHandle relinkAndInvoke)
CallSite.setTarget(MethodHandle)
. Relink-and-invoke is the
initial method handle set by
DynamicLinker.link(RelinkableCallSite)
that will cause the call
site to be relinked to an appropriate target on its first invocation
based on its arguments, and that linked target will then be invoked
(hence the name). This linking protocol effectively delays linking until
the call site is invoked with actual arguments and thus ensures that
linkers can make nuanced linking decisions based on those arguments and
not just on the static method type of the call site.relinkAndInvoke
- a relink-and-invoke method handle supplied by
Dynalink.CallSiteDescriptor getDescriptor()
void relink(GuardedInvocation guardedInvocation, MethodHandle relinkAndInvoke)
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
relink(GuardedInvocation, MethodHandle)
or
resetAndRelink(GuardedInvocation, MethodHandle)
, and finally
invoke the target.void resetAndRelink(GuardedInvocation guardedInvocation, MethodHandle relinkAndInvoke)
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
relink(GuardedInvocation, MethodHandle)
or
resetAndRelink(GuardedInvocation, MethodHandle)
, and finally
invoke the target. Submit a bug or feature
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 2015, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-Ubuntu+0-9b151-2