# HG changeset patch # User sundar # Date 1441892363 -19800 # Node ID 882bbbfcaf03cad23a13f410ac62c9612dd54b47 # Parent bbe835067b8981b8a5c2a586a80d4215347cb99d 8135332: ScriptFunction constructor should use is bound and is strict check rather than checking for 'arguments' and 'caller' Reviewed-by: attila, hannesw diff -r bbe835067b89 -r 882bbbfcaf03 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java Thu Sep 10 15:28:05 2015 +0200 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java Thu Sep 10 19:09:23 2015 +0530 @@ -203,12 +203,9 @@ // We have to fill user accessor functions late as these are stored // in this object rather than in the PropertyMap of this object. assert objectSpill == null; - final ScriptFunction typeErrorThrower = global.getTypeErrorThrower(); - if (findProperty("arguments", true) != null) { + if (isStrict() || isBoundFunction()) { + final ScriptFunction typeErrorThrower = global.getTypeErrorThrower(); initUserAccessors("arguments", Property.NOT_CONFIGURABLE | Property.NOT_ENUMERABLE, typeErrorThrower, typeErrorThrower); - } - - if (findProperty("caller", true) != null) { initUserAccessors("caller", Property.NOT_CONFIGURABLE | Property.NOT_ENUMERABLE, typeErrorThrower, typeErrorThrower); } } diff -r bbe835067b89 -r 882bbbfcaf03 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java Thu Sep 10 15:28:05 2015 +0200 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java Thu Sep 10 19:09:23 2015 +0530 @@ -151,7 +151,7 @@ * Is this a ScriptFunction generated with strict semantics? * @return true if strict, false otherwise */ - public boolean isStrict() { + public final boolean isStrict() { return (flags & IS_STRICT) != 0; } @@ -164,11 +164,11 @@ return getName(); } - boolean isBuiltin() { + final boolean isBuiltin() { return (flags & IS_BUILTIN) != 0; } - boolean isConstructor() { + final boolean isConstructor() { return (flags & IS_CONSTRUCTOR) != 0; } @@ -179,7 +179,7 @@ * according to ECMA 10.4.3. * @return true if this argument must be an object */ - boolean needsWrappedThis() { + final boolean needsWrappedThis() { return (flags & USES_THIS) != 0 && (flags & IS_STRICT_OR_BUILTIN) == 0; }