8022782: publicLookup access failures in ScriptObject, ScriptFunction and ScriptFunction
Reviewed-by: lagergren, attila, hannesw
This commit is contained in:
parent
8ee7468a8c
commit
ec9506c0fe
@ -488,20 +488,6 @@ public enum CompilerConstants {
|
||||
return staticField(className(clazz), name, typeDescriptor(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a static call, looking up the method handle for it at the same time
|
||||
*
|
||||
* @param clazz the class
|
||||
* @param name the name of the method
|
||||
* @param rtype the return type of the method
|
||||
* @param ptypes the parameter types of the method
|
||||
*
|
||||
* @return the call object representing the static call
|
||||
*/
|
||||
public static Call staticCall(final Class<?> clazz, final String name, final Class<?> rtype, final Class<?>... ptypes) {
|
||||
return staticCall(MethodHandles.publicLookup(), clazz, name, rtype, ptypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a static call, given an explicit lookup, looking up the method handle for it at the same time
|
||||
*
|
||||
@ -522,20 +508,6 @@ public enum CompilerConstants {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a virtual call, looking up the method handle for it at the same time
|
||||
*
|
||||
* @param clazz the class
|
||||
* @param name the name of the method
|
||||
* @param rtype the return type of the method
|
||||
* @param ptypes the parameter types of the method
|
||||
*
|
||||
* @return the call object representing the virtual call
|
||||
*/
|
||||
public static Call virtualCall(final Class<?> clazz, final String name, final Class<?> rtype, final Class<?>... ptypes) {
|
||||
return virtualCall(MethodHandles.publicLookup(), clazz, name, rtype, ptypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a virtual call, given an explicit lookup, looking up the method handle for it at the same time
|
||||
*
|
||||
|
@ -28,6 +28,7 @@ package jdk.nashorn.internal.runtime;
|
||||
import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall;
|
||||
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Locale;
|
||||
import jdk.internal.dynalink.beans.BeansLinker;
|
||||
import jdk.internal.dynalink.beans.StaticClass;
|
||||
@ -63,47 +64,49 @@ public enum JSType {
|
||||
/** Max value for an uint32 in JavaScript */
|
||||
public static final long MAX_UINT = 0xFFFF_FFFFL;
|
||||
|
||||
private static final MethodHandles.Lookup myLookup = MethodHandles.lookup();
|
||||
|
||||
/** JavaScript compliant conversion function from Object to boolean */
|
||||
public static final Call TO_BOOLEAN = staticCall(JSType.class, "toBoolean", boolean.class, Object.class);
|
||||
public static final Call TO_BOOLEAN = staticCall(myLookup, JSType.class, "toBoolean", boolean.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from number to boolean */
|
||||
public static final Call TO_BOOLEAN_D = staticCall(JSType.class, "toBoolean", boolean.class, double.class);
|
||||
public static final Call TO_BOOLEAN_D = staticCall(myLookup, JSType.class, "toBoolean", boolean.class, double.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to integer */
|
||||
public static final Call TO_INTEGER = staticCall(JSType.class, "toInteger", int.class, Object.class);
|
||||
public static final Call TO_INTEGER = staticCall(myLookup, JSType.class, "toInteger", int.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to long */
|
||||
public static final Call TO_LONG = staticCall(JSType.class, "toLong", long.class, Object.class);
|
||||
public static final Call TO_LONG = staticCall(myLookup, JSType.class, "toLong", long.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to number */
|
||||
public static final Call TO_NUMBER = staticCall(JSType.class, "toNumber", double.class, Object.class);
|
||||
public static final Call TO_NUMBER = staticCall(myLookup, JSType.class, "toNumber", double.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to int32 */
|
||||
public static final Call TO_INT32 = staticCall(JSType.class, "toInt32", int.class, Object.class);
|
||||
public static final Call TO_INT32 = staticCall(myLookup, JSType.class, "toInt32", int.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from double to int32 */
|
||||
public static final Call TO_INT32_D = staticCall(JSType.class, "toInt32", int.class, double.class);
|
||||
public static final Call TO_INT32_D = staticCall(myLookup, JSType.class, "toInt32", int.class, double.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to uint32 */
|
||||
public static final Call TO_UINT32 = staticCall(JSType.class, "toUint32", long.class, Object.class);
|
||||
public static final Call TO_UINT32 = staticCall(myLookup, JSType.class, "toUint32", long.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from number to uint32 */
|
||||
public static final Call TO_UINT32_D = staticCall(JSType.class, "toUint32", long.class, double.class);
|
||||
public static final Call TO_UINT32_D = staticCall(myLookup, JSType.class, "toUint32", long.class, double.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to int64 */
|
||||
public static final Call TO_INT64 = staticCall(JSType.class, "toInt64", long.class, Object.class);
|
||||
public static final Call TO_INT64 = staticCall(myLookup, JSType.class, "toInt64", long.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from number to int64 */
|
||||
public static final Call TO_INT64_D = staticCall(JSType.class, "toInt64", long.class, double.class);
|
||||
public static final Call TO_INT64_D = staticCall(myLookup, JSType.class, "toInt64", long.class, double.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to String */
|
||||
public static final Call TO_STRING = staticCall(JSType.class, "toString", String.class, Object.class);
|
||||
public static final Call TO_STRING = staticCall(myLookup, JSType.class, "toString", String.class, Object.class);
|
||||
|
||||
/** JavaScript compliant conversion function from number to String */
|
||||
public static final Call TO_STRING_D = staticCall(JSType.class, "toString", String.class, double.class);
|
||||
public static final Call TO_STRING_D = staticCall(myLookup, JSType.class, "toString", String.class, double.class);
|
||||
|
||||
/** JavaScript compliant conversion function from Object to primitive */
|
||||
public static final Call TO_PRIMITIVE = staticCall(JSType.class, "toPrimitive", Object.class, Object.class);
|
||||
public static final Call TO_PRIMITIVE = staticCall(myLookup, JSType.class, "toPrimitive", Object.class, Object.class);
|
||||
|
||||
private static final double INT32_LIMIT = 4294967296.0;
|
||||
|
||||
|
@ -138,10 +138,10 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
|
||||
private static final MethodHandle KNOWNFUNCPROPGUARD = findOwnMH("knownFunctionPropertyGuard", boolean.class, Object.class, PropertyMap.class, MethodHandle.class, Object.class, ScriptFunction.class);
|
||||
|
||||
/** Method handle for getting a function argument at a given index. Used from MapCreator */
|
||||
public static final Call GET_ARGUMENT = virtualCall(ScriptObject.class, "getArgument", Object.class, int.class);
|
||||
public static final Call GET_ARGUMENT = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArgument", Object.class, int.class);
|
||||
|
||||
/** Method handle for setting a function argument at a given index. Used from MapCreator */
|
||||
public static final Call SET_ARGUMENT = virtualCall(ScriptObject.class, "setArgument", void.class, int.class, Object.class);
|
||||
public static final Call SET_ARGUMENT = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setArgument", void.class, int.class, Object.class);
|
||||
|
||||
/** Method handle for getting the proto of a ScriptObject */
|
||||
public static final Call GET_PROTO = virtualCallNoLookup(ScriptObject.class, "getProto", ScriptObject.class);
|
||||
@ -150,7 +150,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
|
||||
public static final Call SET_PROTO = virtualCallNoLookup(ScriptObject.class, "setProto", void.class, ScriptObject.class);
|
||||
|
||||
/** Method handle for setting the user accessors of a ScriptObject */
|
||||
public static final Call SET_USER_ACCESSORS = virtualCall(ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class);
|
||||
public static final Call SET_USER_ACCESSORS = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -33,6 +33,7 @@ import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
|
||||
import static jdk.nashorn.internal.runtime.JSType.isRepresentableAsInt;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@ -100,7 +101,7 @@ public final class ScriptRuntime {
|
||||
* call sites that are known to be megamorphic. Using an invoke dynamic here would
|
||||
* lead to the JVM deoptimizing itself to death
|
||||
*/
|
||||
public static final Call APPLY = staticCall(ScriptRuntime.class, "apply", Object.class, ScriptFunction.class, Object.class, Object[].class);
|
||||
public static final Call APPLY = staticCall(MethodHandles.lookup(), ScriptRuntime.class, "apply", Object.class, ScriptFunction.class, Object.class, Object[].class);
|
||||
|
||||
/**
|
||||
* Converts a switch tag value to a simple integer. deflt value if it can't.
|
||||
|
Loading…
Reference in New Issue
Block a user