Merge
authorsundar
Mon, 09 Dec 2013 09:53:14 +0530
changeset 22397 1bafe007322d
parent 21993 2960e826c39d (current diff)
parent 22382 2abc7240ef59 (diff)
child 22398 3a4323527e36
Merge
--- a/nashorn/src/jdk/nashorn/internal/objects/Global.java	Wed Dec 04 14:37:51 2013 +0530
+++ b/nashorn/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();
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Wed Dec 04 14:37:51 2013 +0530
+++ b/nashorn/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);
--- a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Wed Dec 04 14:37:51 2013 +0530
+++ b/nashorn/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);
         }
     }
 }