# HG changeset patch # User sundar # Date 1386562994 -19800 # Node ID 739f3abdfa55844ef6ad478b398bdbfd1f288265 # Parent c14fe3f90616839fc605a3deaec5e808b4888b70# Parent 752554d45a07d01f9e181437463753fa1f6ee3c5 Merge diff -r c14fe3f90616 -r 739f3abdfa55 src/jdk/nashorn/internal/objects/Global.java --- a/src/jdk/nashorn/internal/objects/Global.java Wed Dec 04 14:37:51 2013 +0530 +++ b/src/jdk/nashorn/internal/objects/Global.java Mon Dec 09 09:53:14 2013 +0530 @@ -44,6 +44,7 @@ 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 @@ 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 @@ return builtinArray; } + ScriptFunction getTypeErrorThrower() { + return typeErrorThrower; + } + /** * Called from compiled script code to test if builtin has been overridden * @@ -2000,6 +2010,13 @@ 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(); diff -r c14fe3f90616 -r 739f3abdfa55 src/jdk/nashorn/internal/objects/NativeStrictArguments.java --- a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Wed Dec 04 14:37:51 2013 +0530 +++ b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Mon Dec 09 09:53:14 2013 +0530 @@ -76,7 +76,7 @@ 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); diff -r c14fe3f90616 -r 739f3abdfa55 src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java --- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Wed Dec 04 14:37:51 2013 +0530 +++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Mon Dec 09 09:53:14 2013 +0530 @@ -170,26 +170,6 @@ 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 @@ // 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); } } }