提交 e2e004f7 编写于 作者: S sundar

Merge

......@@ -44,6 +44,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import jdk.internal.dynalink.linker.GuardedInvocation;
import jdk.internal.dynalink.linker.LinkRequest;
import jdk.nashorn.internal.lookup.Lookup;
import jdk.nashorn.internal.objects.annotations.Attribute;
import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
......@@ -364,6 +365,11 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private ScriptObject builtinFloat32Array;
private ScriptObject builtinFloat64Array;
/*
* ECMA section 13.2.3 The [[ThrowTypeError]] Function Object
*/
private ScriptFunction typeErrorThrower;
private PropertyMap accessorPropertyDescriptorMap;
private PropertyMap arrayBufferViewMap;
private PropertyMap dataPropertyDescriptorMap;
......@@ -1114,6 +1120,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
return builtinArray;
}
ScriptFunction getTypeErrorThrower() {
return typeErrorThrower;
}
/**
* Called from compiled script code to test if builtin has been overridden
*
......@@ -2000,6 +2010,13 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
anon.set("constructor", builtinFunction, false);
anon.deleteOwnProperty(anon.getMap().findProperty("prototype"));
// use "getter" so that [[ThrowTypeError]] function's arity is 0 - as specified in step 10 of section 13.2.3
this.typeErrorThrower = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_GETTER, null, null, false, false, false);
typeErrorThrower.setPrototype(UNDEFINED);
// Non-constructor built-in functions do not have "prototype" property
typeErrorThrower.deleteOwnProperty(typeErrorThrower.getMap().findProperty("prototype"));
typeErrorThrower.preventExtensions();
// now initialize Object
this.builtinObject = (ScriptFunction)initConstructor("Object");
final ScriptObject ObjectPrototype = getObjectPrototype();
......
......@@ -76,7 +76,7 @@ public final class NativeStrictArguments extends ScriptObject {
super(proto, map);
setIsArguments();
final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower();
final ScriptFunction func = Global.instance().getTypeErrorThrower();
// We have to fill user accessor functions late as these are stored
// in this object rather than in the PropertyMap of this object.
setUserAccessors("caller", func, func);
......
......@@ -170,26 +170,6 @@ public class ScriptFunctionImpl extends ScriptFunction {
boundfunctionmap$.setIsShared();
}
// function object representing TypeErrorThrower
private static ScriptFunction typeErrorThrower;
/*
* ECMA section 13.2.3 The [[ThrowTypeError]] Function Object
*/
static synchronized ScriptFunction getTypeErrorThrower() {
if (typeErrorThrower == null) {
// use "getter" so that [[ThrowTypeError]] function's arity is 0 - as specified in step 10 of section 13.2.3
final ScriptFunctionImpl func = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_GETTER, null, null, false, false, false);
func.setPrototype(UNDEFINED);
// Non-constructor built-in functions do not have "prototype" property
func.deleteOwnProperty(func.getMap().findProperty("prototype"));
func.preventExtensions();
typeErrorThrower = func;
}
return typeErrorThrower;
}
private static PropertyMap createStrictModeMap(final PropertyMap map) {
final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
PropertyMap newMap = map;
......@@ -313,12 +293,13 @@ public class ScriptFunctionImpl extends ScriptFunction {
// We have to fill user accessor functions late as these are stored
// in this object rather than in the PropertyMap of this object.
final ScriptFunction errorThrower = global.getTypeErrorThrower();
if (findProperty("arguments", true) != null) {
setUserAccessors("arguments", getTypeErrorThrower(), getTypeErrorThrower());
setUserAccessors("arguments", errorThrower, errorThrower);
}
if (findProperty("caller", true) != null) {
setUserAccessors("caller", getTypeErrorThrower(), getTypeErrorThrower());
setUserAccessors("caller", errorThrower, errorThrower);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册