8135332: ScriptFunction constructor should use is bound and is strict check rather than checking for 'arguments' and 'caller'

Thu, 10 Sep 2015 19:09:23 +0530

author
sundar
date
Thu, 10 Sep 2015 19:09:23 +0530
changeset 1529
098356b162c9
parent 1528
e7e277e29b1a
child 1530
fd307cc5f58c

8135332: ScriptFunction constructor should use is bound and is strict check rather than checking for 'arguments' and 'caller'
Reviewed-by: attila, hannesw

src/jdk/nashorn/internal/runtime/ScriptFunction.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptFunctionData.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Sep 10 15:28:05 2015 +0200
     1.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Sep 10 19:09:23 2015 +0530
     1.3 @@ -203,12 +203,9 @@
     1.4          // We have to fill user accessor functions late as these are stored
     1.5          // in this object rather than in the PropertyMap of this object.
     1.6          assert objectSpill == null;
     1.7 -        final ScriptFunction typeErrorThrower = global.getTypeErrorThrower();
     1.8 -        if (findProperty("arguments", true) != null) {
     1.9 +        if (isStrict() || isBoundFunction()) {
    1.10 +            final ScriptFunction typeErrorThrower = global.getTypeErrorThrower();
    1.11              initUserAccessors("arguments", Property.NOT_CONFIGURABLE | Property.NOT_ENUMERABLE, typeErrorThrower, typeErrorThrower);
    1.12 -        }
    1.13 -
    1.14 -        if (findProperty("caller", true) != null) {
    1.15              initUserAccessors("caller", Property.NOT_CONFIGURABLE | Property.NOT_ENUMERABLE, typeErrorThrower, typeErrorThrower);
    1.16          }
    1.17      }
     2.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Thu Sep 10 15:28:05 2015 +0200
     2.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Thu Sep 10 19:09:23 2015 +0530
     2.3 @@ -151,7 +151,7 @@
     2.4       * Is this a ScriptFunction generated with strict semantics?
     2.5       * @return true if strict, false otherwise
     2.6       */
     2.7 -    public boolean isStrict() {
     2.8 +    public final boolean isStrict() {
     2.9          return (flags & IS_STRICT) != 0;
    2.10      }
    2.11  
    2.12 @@ -164,11 +164,11 @@
    2.13          return getName();
    2.14      }
    2.15  
    2.16 -    boolean isBuiltin() {
    2.17 +    final boolean isBuiltin() {
    2.18          return (flags & IS_BUILTIN) != 0;
    2.19      }
    2.20  
    2.21 -    boolean isConstructor() {
    2.22 +    final boolean isConstructor() {
    2.23          return (flags & IS_CONSTRUCTOR) != 0;
    2.24      }
    2.25  
    2.26 @@ -179,7 +179,7 @@
    2.27       * according to ECMA 10.4.3.
    2.28       * @return true if this argument must be an object
    2.29       */
    2.30 -    boolean needsWrappedThis() {
    2.31 +    final boolean needsWrappedThis() {
    2.32          return (flags & USES_THIS) != 0 && (flags & IS_STRICT_OR_BUILTIN) == 0;
    2.33      }
    2.34  

mercurial