mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-17 22:05:31 +00:00
8139269: Do not expose prune method handles from ChainedCallSite
Reviewed-by: hannesw, lagergren
This commit is contained in:
parent
f932f4f869
commit
ea36ed2bc8
@ -103,27 +103,14 @@ import jdk.internal.dynalink.support.Lookup;
|
||||
* handle is always at the start of the chain.
|
||||
*/
|
||||
public class ChainedCallSite extends AbstractRelinkableCallSite {
|
||||
private static final MethodHandle PRUNE_CATCHES =
|
||||
MethodHandles.insertArguments(
|
||||
Lookup.findOwnSpecial(
|
||||
MethodHandles.lookup(),
|
||||
"prune",
|
||||
MethodHandle.class,
|
||||
MethodHandle.class,
|
||||
boolean.class),
|
||||
2,
|
||||
true);
|
||||
|
||||
private static final MethodHandle PRUNE_SWITCHPOINTS =
|
||||
MethodHandles.insertArguments(
|
||||
Lookup.findOwnSpecial(
|
||||
MethodHandles.lookup(),
|
||||
"prune",
|
||||
MethodHandle.class,
|
||||
MethodHandle.class,
|
||||
boolean.class),
|
||||
2,
|
||||
false);
|
||||
private static final MethodHandle PRUNE_CATCHES;
|
||||
private static final MethodHandle PRUNE_SWITCHPOINTS;
|
||||
static {
|
||||
final MethodHandle PRUNE = Lookup.findOwnSpecial(MethodHandles.lookup(), "prune", MethodHandle.class,
|
||||
MethodHandle.class, boolean.class);
|
||||
PRUNE_CATCHES = MethodHandles.insertArguments(PRUNE, 2, true);
|
||||
PRUNE_SWITCHPOINTS = MethodHandles.insertArguments(PRUNE, 2, false);
|
||||
}
|
||||
|
||||
private final AtomicReference<LinkedList<GuardedInvocation>> invocations = new AtomicReference<>();
|
||||
|
||||
@ -181,8 +168,8 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
|
||||
|
||||
// prune-and-invoke is used as the fallback for invalidated switchpoints. If a switchpoint gets invalidated, we
|
||||
// rebuild the chain and get rid of all invalidated switchpoints instead of letting them linger.
|
||||
final MethodHandle pruneAndInvokeSwitchPoints = makePruneAndInvokeMethod(relink, getPruneSwitchpoints());
|
||||
final MethodHandle pruneAndInvokeCatches = makePruneAndInvokeMethod(relink, getPruneCatches());
|
||||
final MethodHandle pruneAndInvokeSwitchPoints = makePruneAndInvokeMethod(relink, PRUNE_SWITCHPOINTS);
|
||||
final MethodHandle pruneAndInvokeCatches = makePruneAndInvokeMethod(relink, PRUNE_CATCHES);
|
||||
|
||||
// Fold the new chain
|
||||
MethodHandle target = relink;
|
||||
@ -199,22 +186,6 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the switchpoint pruning function for a chained call site
|
||||
* @return function that removes invalidated switchpoints tied to callsite guard chain and relinks
|
||||
*/
|
||||
protected MethodHandle getPruneSwitchpoints() {
|
||||
return PRUNE_SWITCHPOINTS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the catch pruning function for a chained call site
|
||||
* @return function that removes all catches tied to callsite guard chain and relinks
|
||||
*/
|
||||
protected MethodHandle getPruneCatches() {
|
||||
return PRUNE_CATCHES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a method that rebuilds our call chain, pruning it of any invalidated switchpoints, and then invokes that
|
||||
* chain.
|
||||
|
||||
@ -64,9 +64,6 @@ public class LinkerCallSite extends ChainedCallSite {
|
||||
private static final String PROFILEFILE = Options.getStringProperty("nashorn.profilefile", "NashornProfile.txt");
|
||||
|
||||
private static final MethodHandle INCREASE_MISS_COUNTER = MH.findStatic(MethodHandles.lookup(), LinkerCallSite.class, "increaseMissCount", MH.type(Object.class, String.class, Object.class));
|
||||
private static final MethodHandle ON_CATCH_INVALIDATION = MH.findStatic(MethodHandles.lookup(), LinkerCallSite.class, "onCatchInvalidation", MH.type(ChainedCallSite.class, LinkerCallSite.class));
|
||||
|
||||
private int catchInvalidations;
|
||||
|
||||
LinkerCallSite(final NashornCallSiteDescriptor descriptor) {
|
||||
super(descriptor);
|
||||
@ -75,34 +72,6 @@ public class LinkerCallSite extends ChainedCallSite {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MethodHandle getPruneCatches() {
|
||||
return MH.filterArguments(super.getPruneCatches(), 0, ON_CATCH_INVALIDATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform when a catch guard around a callsite triggers. Increases
|
||||
* catch invalidation counter
|
||||
* @param callSite callsite
|
||||
* @return the callsite, so this can be used as argument filter
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static ChainedCallSite onCatchInvalidation(final LinkerCallSite callSite) {
|
||||
++callSite.catchInvalidations;
|
||||
return callSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of catch invalidations that have happened at this call site so far
|
||||
* @param callSiteToken call site token, unique to the callsite.
|
||||
* @return number of catch invalidations, i.e. thrown exceptions caught by the linker
|
||||
*/
|
||||
public static int getCatchInvalidationCount(final Object callSiteToken) {
|
||||
if (callSiteToken instanceof LinkerCallSite) {
|
||||
return ((LinkerCallSite)callSiteToken).catchInvalidations;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Construct a new linker call site.
|
||||
* @param name Name of method.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user