aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsundar <none@none>2013-12-09 09:53:14 +0530
committersundar <none@none>2013-12-09 09:53:14 +0530
commit22a13be2563822aad6e4819df54ffe661b00e9be (patch)
treeb02821e9a4bc37bc24a78294d1627cdd166dac77
parent208335058b336978ff244cbd2c3fe45abb1dcb11 (diff)
parent05aea6cce7ec94559efb4b246f7acd006ca0f435 (diff)
downloadnashorn-22a13be2563822aad6e4819df54ffe661b00e9be.tar.gz
Merge
-rw-r--r--src/jdk/nashorn/internal/objects/Global.java17
-rw-r--r--src/jdk/nashorn/internal/objects/NativeStrictArguments.java2
-rw-r--r--src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java25
3 files changed, 21 insertions, 23 deletions
diff --git a/src/jdk/nashorn/internal/objects/Global.java b/src/jdk/nashorn/internal/objects/Global.java
index 0a09370a..db79f5f9 100644
--- a/src/jdk/nashorn/internal/objects/Global.java
+++ b/src/jdk/nashorn/internal/objects/Global.java
@@ -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();
diff --git a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java
index de6e4b51..b81cc2af 100644
--- a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java
+++ b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java
@@ -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);
diff --git a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
index 638d18a2..f0bea3a6 100644
--- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
+++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
@@ -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);
}
}
}