mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8167037: Remove CALL_METHOD support from internal Nashorn linkers
Reviewed-by: hannesw, sundar
This commit is contained in:
parent
70e402c190
commit
13b1a55ffa
@ -472,22 +472,6 @@ public final class NativeJSAdapter extends ScriptObject {
|
||||
return findHook(desc, __new__, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
|
||||
if (overrides && super.hasOwnProperty(NashornCallSiteDescriptor.getOperand(desc))) {
|
||||
try {
|
||||
final GuardedInvocation inv = super.findCallMethodMethod(desc, request);
|
||||
if (inv != null) {
|
||||
return inv;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
|
||||
return findHook(desc, __call__);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
|
||||
final String name = NashornCallSiteDescriptor.getOperand(desc);
|
||||
|
||||
@ -80,7 +80,6 @@ import jdk.nashorn.internal.objects.Global;
|
||||
import jdk.nashorn.internal.objects.NativeArray;
|
||||
import jdk.nashorn.internal.runtime.arrays.ArrayData;
|
||||
import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
|
||||
import jdk.nashorn.internal.runtime.linker.Bootstrap;
|
||||
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
|
||||
import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
|
||||
import jdk.nashorn.internal.runtime.linker.NashornGuards;
|
||||
@ -1883,8 +1882,6 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable {
|
||||
return findCallMethod(desc, request);
|
||||
case NEW:
|
||||
return findNewMethod(desc, request);
|
||||
case CALL_METHOD:
|
||||
return findCallMethodMethod(desc, request);
|
||||
default:
|
||||
}
|
||||
return null;
|
||||
@ -1919,32 +1916,6 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable {
|
||||
throw typeError("not.a.function", NashornCallSiteDescriptor.getFunctionErrorMessage(desc, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an implementation for a CALL_METHOD operation. Note that Nashorn internally never uses
|
||||
* CALL_METHOD, but instead always emits two call sites in bytecode, one for GET_METHOD, and then another
|
||||
* one for CALL. Explicit support for CALL_METHOD is provided for the benefit of potential external
|
||||
* callers. The implementation itself actually folds a GET_METHOD method handle into a CALL method handle.
|
||||
*
|
||||
* @param desc the call site descriptor.
|
||||
* @param request the link request
|
||||
*
|
||||
* @return GuardedInvocation to be invoked at call site.
|
||||
*/
|
||||
protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
|
||||
// R(P0, P1, ...)
|
||||
final MethodType callType = desc.getMethodType();
|
||||
// use type Object(P0) for the getter
|
||||
final CallSiteDescriptor getterType = desc.changeMethodType(MethodType.methodType(Object.class, callType.parameterType(0)));
|
||||
final GuardedInvocation getter = findGetMethod(getterType, request, StandardOperation.GET_METHOD);
|
||||
|
||||
// Object(P0) => Object(P0, P1, ...)
|
||||
final MethodHandle argDroppingGetter = MH.dropArguments(getter.getInvocation(), 1, callType.parameterList().subList(1, callType.parameterCount()));
|
||||
// R(Object, P0, P1, ...)
|
||||
final MethodHandle invoker = Bootstrap.createDynamicInvoker("", NashornCallSiteDescriptor.CALL, callType.insertParameterTypes(0, argDroppingGetter.type().returnType()));
|
||||
// Fold Object(P0, P1, ...) into R(Object, P0, P1, ...) => R(P0, P1, ...)
|
||||
return getter.replaceMethods(MH.foldArguments(invoker, argDroppingGetter), getter.getGuard());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether this object contains in its prototype chain or is itself a with-object.
|
||||
* @return true if a with-object was found
|
||||
|
||||
@ -103,8 +103,6 @@ public final class Undefined extends DefaultPropertyAccess {
|
||||
final String name = NashornCallSiteDescriptor.getOperand(desc);
|
||||
final String msg = name != null? "not.a.function" : "cant.call.undefined";
|
||||
throw typeError(msg, name);
|
||||
case CALL_METHOD:
|
||||
throw lookupTypeError("cant.read.property.of.undefined", desc);
|
||||
case GET_PROPERTY:
|
||||
case GET_ELEMENT:
|
||||
case GET_METHOD:
|
||||
|
||||
@ -86,13 +86,11 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo
|
||||
private static final MethodHandle EMPTY_ELEM_SETTER =
|
||||
MH.dropArguments(EMPTY_PROP_SETTER, 0, Object.class);
|
||||
|
||||
private static final MethodHandle THROW_NO_SUCH_FUNCTION;
|
||||
private static final MethodHandle THROW_STRICT_PROPERTY_SETTER;
|
||||
private static final MethodHandle THROW_OPTIMISTIC_UNDEFINED;
|
||||
|
||||
static {
|
||||
final Lookup lookup = new Lookup(MethodHandles.lookup());
|
||||
THROW_NO_SUCH_FUNCTION = lookup.findOwnStatic("throwNoSuchFunction", Object.class, Object.class, Object.class);
|
||||
THROW_STRICT_PROPERTY_SETTER = lookup.findOwnStatic("throwStrictPropertySetter", void.class, Object.class, Object.class);
|
||||
THROW_OPTIMISTIC_UNDEFINED = lookup.findOwnStatic("throwOptimisticUndefined", Object.class, int.class);
|
||||
}
|
||||
@ -130,8 +128,6 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo
|
||||
if (op != null) {
|
||||
final String operand = NashornCallSiteDescriptor.getOperand(desc);
|
||||
switch (op) {
|
||||
case CALL_METHOD:
|
||||
return adaptThrower(bindOperand(THROW_NO_SUCH_FUNCTION, operand), desc);
|
||||
case GET_METHOD:
|
||||
case GET_PROPERTY:
|
||||
case GET_ELEMENT: {
|
||||
@ -171,11 +167,6 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo
|
||||
.asType(targetType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Object throwNoSuchFunction(final Object self, final Object name) {
|
||||
throw createTypeError(self, name, "no.such.function");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void throwStrictPropertySetter(final Object self, final Object name) {
|
||||
throw createTypeError(self, name, "cant.set.property");
|
||||
@ -230,7 +221,6 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo
|
||||
case NEW:
|
||||
case CALL:
|
||||
throw typeError("not.a.function", "null");
|
||||
case CALL_METHOD:
|
||||
case GET_METHOD:
|
||||
throw typeError("no.such.function", getArgument(linkRequest), "null");
|
||||
case GET_PROPERTY:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user