Merge

Mon, 06 Oct 2014 15:53:22 -0700

author
asaha
date
Mon, 06 Oct 2014 15:53:22 -0700
changeset 1044
61442718321f
parent 1043
596dd29c71dc
parent 1023
6a8ecdeae4a9
child 1046
ec10633470f8

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Wed Sep 24 14:43:37 2014 -0700
     1.2 +++ b/.hgtags	Mon Oct 06 15:53:22 2014 -0700
     1.3 @@ -326,3 +326,4 @@
     1.4  2d75c391f61f31538b4c3dcc9778fc6742125ec4 jdk8u40-b05
     1.5  1196f17cf7bc709766319f5bf7a5394a7251b47a jdk8u40-b06
     1.6  0032961e1866c22afe3d0bbbb217f8840be61846 jdk8u40-b07
     1.7 +89551828b279233825204b72233edafc72d8feb3 jdk8u40-b08
     2.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Wed Sep 24 14:43:37 2014 -0700
     2.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Mon Oct 06 15:53:22 2014 -0700
     2.3 @@ -50,6 +50,7 @@
     2.4  import jdk.nashorn.internal.runtime.ScriptObject;
     2.5  import jdk.nashorn.internal.runtime.ScriptRuntime;
     2.6  import jdk.nashorn.internal.runtime.arrays.ArrayData;
     2.7 +import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
     2.8  
     2.9  /**
    2.10   * Mirror object that wraps a given Nashorn Script object.
    2.11 @@ -261,7 +262,7 @@
    2.12      public void setSlot(final int index, final Object value) {
    2.13          inGlobal(new Callable<Void>() {
    2.14              @Override public Void call() {
    2.15 -                sobj.set(index, unwrap(value, global), strict);
    2.16 +                sobj.set(index, unwrap(value, global), getCallSiteFlags());
    2.17                  return null;
    2.18              }
    2.19          });
    2.20 @@ -425,7 +426,7 @@
    2.21                  for (final Map.Entry<? extends String, ? extends Object> entry : map.entrySet()) {
    2.22                      final Object value = entry.getValue();
    2.23                      final Object modValue = globalChanged? wrap(value, oldGlobal) : value;
    2.24 -                    sobj.set(entry.getKey(), unwrap(modValue, global), strict);
    2.25 +                    sobj.set(entry.getKey(), unwrap(modValue, global), getCallSiteFlags());
    2.26                  }
    2.27                  return null;
    2.28              }
    2.29 @@ -756,6 +757,10 @@
    2.30          return (obj == ScriptRuntime.UNDEFINED)? null : obj;
    2.31      }
    2.32  
    2.33 +    private int getCallSiteFlags() {
    2.34 +        return strict ? NashornCallSiteDescriptor.CALLSITE_STRICT : 0;
    2.35 +    }
    2.36 +
    2.37      // internals only below this.
    2.38      private <V> V inGlobal(final Callable<V> callable) {
    2.39          final Global oldGlobal = Context.getGlobal();
     3.1 --- a/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Wed Sep 24 14:43:37 2014 -0700
     3.2 +++ b/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Mon Oct 06 15:53:22 2014 -0700
     3.3 @@ -231,7 +231,7 @@
     3.4              if (symbol != null) {
     3.5                  if (hasArguments() && symbol.isParam()) {
     3.6                      symbol.setFieldIndex(paramCount++);
     3.7 -                } else {
     3.8 +                } else if (!isValidArrayIndex(getArrayIndex(tuple.key))) {
     3.9                      symbol.setFieldIndex(fieldCount++);
    3.10                  }
    3.11              }
     4.1 --- a/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Wed Sep 24 14:43:37 2014 -0700
     4.2 +++ b/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Mon Oct 06 15:53:22 2014 -0700
     4.3 @@ -558,7 +558,7 @@
     4.4                      // of the compilation that the object being iterated over must use strings for property
     4.5                      // names (e.g., it is a native JS object or array), then we'll not bother trying to treat
     4.6                      // the property names optimistically.
     4.7 -                    !forNode.isForEach() && compiler.hasStringPropertyIterator(iterable.getExpression()));
     4.8 +                    !compiler.useOptimisticTypes() || (!forNode.isForEach() && compiler.hasStringPropertyIterator(iterable.getExpression())));
     4.9          } else {
    4.10              if(init != null) {
    4.11                  init.accept(this);
    4.12 @@ -686,6 +686,10 @@
    4.13  
    4.14      @Override
    4.15      public boolean enterReturnNode(final ReturnNode returnNode) {
    4.16 +        if(!reachable) {
    4.17 +            return false;
    4.18 +        }
    4.19 +
    4.20          final Expression returnExpr = returnNode.getExpression();
    4.21          final Type returnExprType;
    4.22          if(returnExpr != null) {
    4.23 @@ -701,6 +705,9 @@
    4.24  
    4.25      @Override
    4.26      public boolean enterSplitNode(final SplitNode splitNode) {
    4.27 +        if(!reachable) {
    4.28 +            return false;
    4.29 +        }
    4.30          // Need to visit inside of split nodes. While it's true that they don't have local variables, we need to visit
    4.31          // breaks, continues, and returns in them.
    4.32          if(topSplit == null) {
    4.33 @@ -950,6 +957,9 @@
    4.34  
    4.35      @Override
    4.36      public boolean enterVarNode(final VarNode varNode) {
    4.37 +        if (!reachable) {
    4.38 +            return false;
    4.39 +        }
    4.40          final Expression init = varNode.getInit();
    4.41          if(init != null) {
    4.42              init.accept(this);
     5.1 --- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java	Wed Sep 24 14:43:37 2014 -0700
     5.2 +++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java	Mon Oct 06 15:53:22 2014 -0700
     5.3 @@ -228,11 +228,11 @@
     5.4      private static void copyElements(final ArrayBufferView dest, final int length, final ScriptObject source, final int offset) {
     5.5          if (!dest.isFloatArray()) {
     5.6              for (int i = 0, j = offset; i < length; i++, j++) {
     5.7 -                dest.set(j, source.getInt(i, INVALID_PROGRAM_POINT), false);
     5.8 +                dest.set(j, source.getInt(i, INVALID_PROGRAM_POINT), 0);
     5.9              }
    5.10          } else {
    5.11              for (int i = 0, j = offset; i < length; i++, j++) {
    5.12 -                dest.set(j, source.getDouble(i, INVALID_PROGRAM_POINT), false);
    5.13 +                dest.set(j, source.getDouble(i, INVALID_PROGRAM_POINT), 0);
    5.14              }
    5.15          }
    5.16      }
     6.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Wed Sep 24 14:43:37 2014 -0700
     6.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Mon Oct 06 15:53:22 2014 -0700
     6.3 @@ -439,8 +439,8 @@
     6.4  
     6.5      // current ScriptContext to use - can be null.
     6.6      private ScriptContext scontext;
     6.7 -    // associated Property object for "context" property.
     6.8 -    private jdk.nashorn.internal.runtime.Property scontextProperty;
     6.9 +    // current ScriptEngine associated - can be null.
    6.10 +    private ScriptEngine engine;
    6.11  
    6.12      /**
    6.13       * Set the current script context
    6.14 @@ -448,7 +448,6 @@
    6.15       */
    6.16      public void setScriptContext(final ScriptContext scontext) {
    6.17          this.scontext = scontext;
    6.18 -        scontextProperty.setValue(this, this, scontext, false);
    6.19      }
    6.20  
    6.21      // global constants for this global - they can be replaced with MethodHandle.constant until invalidated
    6.22 @@ -581,6 +580,7 @@
    6.23              return;
    6.24          }
    6.25  
    6.26 +        this.engine = engine;
    6.27          init(engine);
    6.28      }
    6.29  
    6.30 @@ -917,6 +917,13 @@
    6.31              }
    6.32          }
    6.33  
    6.34 +        switch (nameStr) {
    6.35 +            case "context":
    6.36 +                return sctxt;
    6.37 +            case "engine":
    6.38 +                return global.engine;
    6.39 +        }
    6.40 +
    6.41          if (self == UNDEFINED) {
    6.42              // scope access and so throw ReferenceError
    6.43              throw referenceError(global, "not.defined", nameStr);
    6.44 @@ -1789,9 +1796,6 @@
    6.45          }
    6.46  
    6.47          if (engine != null) {
    6.48 -            final int NOT_ENUMERABLE_NOT_CONFIG = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE;
    6.49 -            scontextProperty = addOwnProperty("context", NOT_ENUMERABLE_NOT_CONFIG, null);
    6.50 -            addOwnProperty("engine", NOT_ENUMERABLE_NOT_CONFIG, engine);
    6.51              // default file name
    6.52              addOwnProperty(ScriptEngine.FILENAME, Attribute.NOT_ENUMERABLE, null);
    6.53              // __noSuchProperty__ hook for ScriptContext search of missing variables
    6.54 @@ -1821,10 +1825,10 @@
    6.55  
    6.56          // ECMA 15.11.4.2 Error.prototype.name
    6.57          // Error.prototype.name = "Error";
    6.58 -        errorProto.set(NativeError.NAME, "Error", false);
    6.59 +        errorProto.set(NativeError.NAME, "Error", 0);
    6.60          // ECMA 15.11.4.3 Error.prototype.message
    6.61          // Error.prototype.message = "";
    6.62 -        errorProto.set(NativeError.MESSAGE, "", false);
    6.63 +        errorProto.set(NativeError.MESSAGE, "", 0);
    6.64  
    6.65          this.builtinEvalError = initErrorSubtype("EvalError", errorProto);
    6.66          this.builtinRangeError = initErrorSubtype("RangeError", errorProto);
    6.67 @@ -1837,8 +1841,8 @@
    6.68      private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) {
    6.69          final ScriptFunction cons = initConstructor(name, ScriptFunction.class);
    6.70          final ScriptObject prototype = ScriptFunction.getPrototype(cons);
    6.71 -        prototype.set(NativeError.NAME, name, false);
    6.72 -        prototype.set(NativeError.MESSAGE, "", false);
    6.73 +        prototype.set(NativeError.NAME, name, 0);
    6.74 +        prototype.set(NativeError.MESSAGE, "", 0);
    6.75          prototype.setInitialProto(errorProto);
    6.76          return cons;
    6.77      }
    6.78 @@ -1898,7 +1902,7 @@
    6.79      private static void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) {
    6.80          for (final Field f : scriptEnv.getClass().getFields()) {
    6.81              try {
    6.82 -                options.set(f.getName(), f.get(scriptEnv), false);
    6.83 +                options.set(f.getName(), f.get(scriptEnv), 0);
    6.84              } catch (final IllegalArgumentException | IllegalAccessException exp) {
    6.85                  throw new RuntimeException(exp);
    6.86              }
    6.87 @@ -2042,7 +2046,7 @@
    6.88          // <anon-function>
    6.89          builtinFunction.setInitialProto(anon);
    6.90          builtinFunction.setPrototype(anon);
    6.91 -        anon.set("constructor", builtinFunction, false);
    6.92 +        anon.set("constructor", builtinFunction, 0);
    6.93          anon.deleteOwnProperty(anon.getMap().findProperty("prototype"));
    6.94  
    6.95          // use "getter" so that [[ThrowTypeError]] function's arity is 0 - as specified in step 10 of section 13.2.3
     7.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java	Wed Sep 24 14:43:37 2014 -0700
     7.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java	Mon Oct 06 15:53:22 2014 -0700
     7.3 @@ -32,6 +32,7 @@
     7.4  import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.isValidArrayIndex;
     7.5  import static jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator.arrayLikeIterator;
     7.6  import static jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator.reverseArrayLikeIterator;
     7.7 +import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT;
     7.8  
     7.9  import java.lang.invoke.MethodHandle;
    7.10  import java.util.ArrayList;
    7.11 @@ -69,6 +70,7 @@
    7.12  import jdk.nashorn.internal.runtime.arrays.IteratorAction;
    7.13  import jdk.nashorn.internal.runtime.linker.Bootstrap;
    7.14  import jdk.nashorn.internal.runtime.linker.InvokeByName;
    7.15 +import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
    7.16  
    7.17  /**
    7.18   * Runtime representation of a JavaScript array. NativeArray only holds numeric
    7.19 @@ -341,7 +343,7 @@
    7.20              if (!newWritable) {
    7.21                  // make 'length' property not writable
    7.22                  final ScriptObject newDesc = Global.newEmptyInstance();
    7.23 -                newDesc.set(WRITABLE, false, false);
    7.24 +                newDesc.set(WRITABLE, false, 0);
    7.25                  return super.defineOwnProperty("length", newDesc, false);
    7.26              }
    7.27  
    7.28 @@ -808,7 +810,7 @@
    7.29              final long len = JSType.toUint32(sobj.getLength());
    7.30  
    7.31              if (len == 0) {
    7.32 -                sobj.set("length", 0, true);
    7.33 +                sobj.set("length", 0, CALLSITE_STRICT);
    7.34                  return ScriptRuntime.UNDEFINED;
    7.35              }
    7.36  
    7.37 @@ -816,7 +818,7 @@
    7.38              final Object element = sobj.get(index);
    7.39  
    7.40              sobj.delete(index, true);
    7.41 -            sobj.set("length", index, true);
    7.42 +            sobj.set("length", index, CALLSITE_STRICT);
    7.43  
    7.44              return element;
    7.45          } catch (final ClassCastException | NullPointerException e) {
    7.46 @@ -844,9 +846,9 @@
    7.47  
    7.48              long len = JSType.toUint32(sobj.getLength());
    7.49              for (final Object element : args) {
    7.50 -                sobj.set(len++, element, true);
    7.51 +                sobj.set(len++, element, CALLSITE_STRICT);
    7.52              }
    7.53 -            sobj.set("length", len, true);
    7.54 +            sobj.set("length", len, CALLSITE_STRICT);
    7.55  
    7.56              return len;
    7.57          } catch (final ClassCastException | NullPointerException e) {
    7.58 @@ -928,8 +930,8 @@
    7.59              }
    7.60  
    7.61              long len = JSType.toUint32(sobj.getLength());
    7.62 -            sobj.set(len++, arg, true);
    7.63 -            sobj.set("length", len, true);
    7.64 +            sobj.set(len++, arg, CALLSITE_STRICT);
    7.65 +            sobj.set("length", len, CALLSITE_STRICT);
    7.66              return len;
    7.67          } catch (final ClassCastException | NullPointerException e) {
    7.68              throw typeError("not.an.object", ScriptRuntime.safeToString(self));
    7.69 @@ -957,14 +959,14 @@
    7.70                  final boolean upperExists = sobj.has(upper);
    7.71  
    7.72                  if (lowerExists && upperExists) {
    7.73 -                    sobj.set(lower, upperValue, true);
    7.74 -                    sobj.set(upper, lowerValue, true);
    7.75 +                    sobj.set(lower, upperValue, CALLSITE_STRICT);
    7.76 +                    sobj.set(upper, lowerValue, CALLSITE_STRICT);
    7.77                  } else if (!lowerExists && upperExists) {
    7.78 -                    sobj.set(lower, upperValue, true);
    7.79 +                    sobj.set(lower, upperValue, CALLSITE_STRICT);
    7.80                      sobj.delete(upper, true);
    7.81                  } else if (lowerExists && !upperExists) {
    7.82                      sobj.delete(lower, true);
    7.83 -                    sobj.set(upper, lowerValue, true);
    7.84 +                    sobj.set(upper, lowerValue, CALLSITE_STRICT);
    7.85                  }
    7.86              }
    7.87              return sobj;
    7.88 @@ -1003,7 +1005,7 @@
    7.89                  for (long k = 1; k < len; k++) {
    7.90                      final boolean hasCurrent = sobj.has(k);
    7.91                      if (hasCurrent) {
    7.92 -                        sobj.set(k - 1, sobj.get(k), true);
    7.93 +                        sobj.set(k - 1, sobj.get(k), CALLSITE_STRICT);
    7.94                      } else if (hasPrevious) {
    7.95                          sobj.delete(k - 1, true);
    7.96                      }
    7.97 @@ -1015,7 +1017,7 @@
    7.98              len = 0;
    7.99          }
   7.100  
   7.101 -        sobj.set("length", len, true);
   7.102 +        sobj.set("length", len, CALLSITE_STRICT);
   7.103  
   7.104          return first;
   7.105      }
   7.106 @@ -1226,7 +1228,7 @@
   7.107                  final long to   = k + items.length;
   7.108  
   7.109                  if (sobj.has(from)) {
   7.110 -                    sobj.set(to, sobj.get(from), true);
   7.111 +                    sobj.set(to, sobj.get(from), CALLSITE_STRICT);
   7.112                  } else {
   7.113                      sobj.delete(to, true);
   7.114                  }
   7.115 @@ -1242,7 +1244,7 @@
   7.116  
   7.117                  if (sobj.has(from)) {
   7.118                      final Object fromValue = sobj.get(from);
   7.119 -                    sobj.set(to, fromValue, true);
   7.120 +                    sobj.set(to, fromValue, CALLSITE_STRICT);
   7.121                  } else {
   7.122                      sobj.delete(to, true);
   7.123                  }
   7.124 @@ -1251,11 +1253,11 @@
   7.125  
   7.126          long k = start;
   7.127          for (int i = 0; i < items.length; i++, k++) {
   7.128 -            sobj.set(k, items[i], true);
   7.129 +            sobj.set(k, items[i], CALLSITE_STRICT);
   7.130          }
   7.131  
   7.132          final long newLength = len - deleteCount + items.length;
   7.133 -        sobj.set("length", newLength, true);
   7.134 +        sobj.set("length", newLength, CALLSITE_STRICT);
   7.135  
   7.136          return array;
   7.137      }
   7.138 @@ -1295,19 +1297,19 @@
   7.139  
   7.140                  if (sobj.has(from)) {
   7.141                      final Object fromValue = sobj.get(from);
   7.142 -                    sobj.set(to, fromValue, true);
   7.143 +                    sobj.set(to, fromValue, CALLSITE_STRICT);
   7.144                  } else {
   7.145                      sobj.delete(to, true);
   7.146                  }
   7.147              }
   7.148  
   7.149              for (int j = 0; j < items.length; j++) {
   7.150 -                sobj.set(j, items[j], true);
   7.151 +                sobj.set(j, items[j], CALLSITE_STRICT);
   7.152              }
   7.153          }
   7.154  
   7.155          final long newLength = len + items.length;
   7.156 -        sobj.set("length", newLength, true);
   7.157 +        sobj.set("length", newLength, CALLSITE_STRICT);
   7.158  
   7.159          return newLength;
   7.160      }
     8.1 --- a/src/jdk/nashorn/internal/objects/NativeDebug.java	Wed Sep 24 14:43:37 2014 -0700
     8.2 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java	Mon Oct 06 15:53:22 2014 -0700
     8.3 @@ -42,6 +42,7 @@
     8.4  import jdk.nashorn.internal.runtime.ScriptObject;
     8.5  import jdk.nashorn.internal.runtime.events.RuntimeEvent;
     8.6  import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
     8.7 +import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
     8.8  
     8.9  /**
    8.10   * Nashorn specific debug utils. This is meant for Nashorn developers.
    8.11 @@ -266,7 +267,7 @@
    8.12       */
    8.13      @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
    8.14      public static void setEventQueueCapacity(final Object self, final Object newCapacity) {
    8.15 -        ((ScriptObject)self).set(EVENT_QUEUE_CAPACITY, newCapacity, true);
    8.16 +        ((ScriptObject)self).set(EVENT_QUEUE_CAPACITY, newCapacity, NashornCallSiteDescriptor.CALLSITE_STRICT);
    8.17      }
    8.18  
    8.19      /**
    8.20 @@ -355,7 +356,7 @@
    8.21          if (sobj.has(EVENT_QUEUE)) {
    8.22              q = (LinkedList<RuntimeEvent<?>>)((ScriptObject)self).get(EVENT_QUEUE);
    8.23          } else {
    8.24 -            ((ScriptObject)self).set(EVENT_QUEUE, q = new LinkedList<>(), true);
    8.25 +            ((ScriptObject)self).set(EVENT_QUEUE, q = new LinkedList<>(), NashornCallSiteDescriptor.CALLSITE_STRICT);
    8.26          }
    8.27          return q;
    8.28      }
     9.1 --- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Wed Sep 24 14:43:37 2014 -0700
     9.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Mon Oct 06 15:53:22 2014 -0700
     9.3 @@ -250,146 +250,146 @@
     9.4      }
     9.5  
     9.6      @Override
     9.7 -    public void set(final Object key, final int value, final boolean strict) {
     9.8 +    public void set(final Object key, final int value, final int flags) {
     9.9          if (overrides && super.hasOwnProperty(key)) {
    9.10 -            super.set(key, value, strict);
    9.11 +            super.set(key, value, flags);
    9.12          } else {
    9.13 -            callAdaptee(__put__, key, value, strict);
    9.14 +            callAdaptee(__put__, key, value, flags);
    9.15          }
    9.16      }
    9.17  
    9.18      @Override
    9.19 -    public void set(final Object key, final long value, final boolean strict) {
    9.20 +    public void set(final Object key, final long value, final int flags) {
    9.21          if (overrides && super.hasOwnProperty(key)) {
    9.22 -            super.set(key, value, strict);
    9.23 +            super.set(key, value, flags);
    9.24          } else {
    9.25 -            callAdaptee(__put__, key, value, strict);
    9.26 +            callAdaptee(__put__, key, value, flags);
    9.27          }
    9.28      }
    9.29  
    9.30      @Override
    9.31 -    public void set(final Object key, final double value, final boolean strict) {
    9.32 +    public void set(final Object key, final double value, final int flags) {
    9.33          if (overrides && super.hasOwnProperty(key)) {
    9.34 -            super.set(key, value, strict);
    9.35 +            super.set(key, value, flags);
    9.36          } else {
    9.37 -            callAdaptee(__put__, key, value, strict);
    9.38 +            callAdaptee(__put__, key, value, flags);
    9.39          }
    9.40      }
    9.41  
    9.42      @Override
    9.43 -    public void set(final Object key, final Object value, final boolean strict) {
    9.44 +    public void set(final Object key, final Object value, final int flags) {
    9.45          if (overrides && super.hasOwnProperty(key)) {
    9.46 -            super.set(key, value, strict);
    9.47 +            super.set(key, value, flags);
    9.48          } else {
    9.49 -            callAdaptee(__put__, key, value, strict);
    9.50 +            callAdaptee(__put__, key, value, flags);
    9.51          }
    9.52      }
    9.53  
    9.54      @Override
    9.55 -    public void set(final double key, final int value, final boolean strict) {
    9.56 +    public void set(final double key, final int value, final int flags) {
    9.57          if (overrides && super.hasOwnProperty(key)) {
    9.58 -            super.set(key, value, strict);
    9.59 +            super.set(key, value, flags);
    9.60          } else {
    9.61 -            callAdaptee(__put__, key, value, strict);
    9.62 +            callAdaptee(__put__, key, value, flags);
    9.63          }
    9.64      }
    9.65  
    9.66      @Override
    9.67 -    public void set(final double key, final long value, final boolean strict) {
    9.68 +    public void set(final double key, final long value, final int flags) {
    9.69          if (overrides && super.hasOwnProperty(key)) {
    9.70 -            super.set(key, value, strict);
    9.71 +            super.set(key, value, flags);
    9.72          } else {
    9.73 -            callAdaptee(__put__, key, value, strict);
    9.74 +            callAdaptee(__put__, key, value, flags);
    9.75          }
    9.76      }
    9.77  
    9.78      @Override
    9.79 -    public void set(final double key, final double value, final boolean strict) {
    9.80 +    public void set(final double key, final double value, final int flags) {
    9.81          if (overrides && super.hasOwnProperty(key)) {
    9.82 -            super.set(key, value, strict);
    9.83 +            super.set(key, value, flags);
    9.84          } else {
    9.85 -            callAdaptee(__put__, key, value, strict);
    9.86 +            callAdaptee(__put__, key, value, flags);
    9.87          }
    9.88      }
    9.89  
    9.90      @Override
    9.91 -    public void set(final double key, final Object value, final boolean strict) {
    9.92 +    public void set(final double key, final Object value, final int flags) {
    9.93          if (overrides && super.hasOwnProperty(key)) {
    9.94 -            super.set(key, value, strict);
    9.95 +            super.set(key, value, flags);
    9.96          } else {
    9.97 -            callAdaptee(__put__, key, value, strict);
    9.98 +            callAdaptee(__put__, key, value, flags);
    9.99          }
   9.100      }
   9.101  
   9.102      @Override
   9.103 -    public void set(final long key, final int value, final boolean strict) {
   9.104 +    public void set(final long key, final int value, final int flags) {
   9.105          if (overrides && super.hasOwnProperty(key)) {
   9.106 -            super.set(key, value, strict);
   9.107 +            super.set(key, value, flags);
   9.108          } else {
   9.109 -            callAdaptee(__put__, key, value, strict);
   9.110 +            callAdaptee(__put__, key, value, flags);
   9.111          }
   9.112      }
   9.113  
   9.114      @Override
   9.115 -    public void set(final long key, final long value, final boolean strict) {
   9.116 +    public void set(final long key, final long value, final int flags) {
   9.117          if (overrides && super.hasOwnProperty(key)) {
   9.118 -            super.set(key, value, strict);
   9.119 +            super.set(key, value, flags);
   9.120          } else {
   9.121 -            callAdaptee(__put__, key, value, strict);
   9.122 +            callAdaptee(__put__, key, value, flags);
   9.123          }
   9.124      }
   9.125  
   9.126      @Override
   9.127 -    public void set(final long key, final double value, final boolean strict) {
   9.128 +    public void set(final long key, final double value, final int flags) {
   9.129          if (overrides && super.hasOwnProperty(key)) {
   9.130 -            super.set(key, value, strict);
   9.131 +            super.set(key, value, flags);
   9.132          } else {
   9.133 -            callAdaptee(__put__, key, value, strict);
   9.134 +            callAdaptee(__put__, key, value, flags);
   9.135          }
   9.136      }
   9.137  
   9.138      @Override
   9.139 -    public void set(final long key, final Object value, final boolean strict) {
   9.140 +    public void set(final long key, final Object value, final int flags) {
   9.141          if (overrides && super.hasOwnProperty(key)) {
   9.142 -            super.set(key, value, strict);
   9.143 +            super.set(key, value, flags);
   9.144          } else {
   9.145 -            callAdaptee(__put__, key, value, strict);
   9.146 +            callAdaptee(__put__, key, value, flags);
   9.147          }
   9.148      }
   9.149  
   9.150      @Override
   9.151 -    public void set(final int key, final int value, final boolean strict) {
   9.152 +    public void set(final int key, final int value, final int flags) {
   9.153          if (overrides && super.hasOwnProperty(key)) {
   9.154 -            super.set(key, value, strict);
   9.155 +            super.set(key, value, flags);
   9.156          } else {
   9.157 -            callAdaptee(__put__, key, value, strict);
   9.158 +            callAdaptee(__put__, key, value, flags);
   9.159          }
   9.160      }
   9.161  
   9.162      @Override
   9.163 -    public void set(final int key, final long value, final boolean strict) {
   9.164 +    public void set(final int key, final long value, final int flags) {
   9.165          if (overrides && super.hasOwnProperty(key)) {
   9.166 -            super.set(key, value, strict);
   9.167 +            super.set(key, value, flags);
   9.168          } else {
   9.169 -            callAdaptee(__put__, key, value, strict);
   9.170 +            callAdaptee(__put__, key, value, flags);
   9.171          }
   9.172      }
   9.173  
   9.174      @Override
   9.175 -    public void set(final int key, final double value, final boolean strict) {
   9.176 +    public void set(final int key, final double value, final int flags) {
   9.177          if (overrides && super.hasOwnProperty(key)) {
   9.178 -            super.set(key, value, strict);
   9.179 +            super.set(key, value, flags);
   9.180          } else {
   9.181 -            callAdaptee(__put__, key, value, strict);
   9.182 +            callAdaptee(__put__, key, value, flags);
   9.183          }
   9.184      }
   9.185  
   9.186      @Override
   9.187 -    public void set(final int key, final Object value, final boolean strict) {
   9.188 +    public void set(final int key, final Object value, final int flags) {
   9.189          if (overrides && super.hasOwnProperty(key)) {
   9.190 -            super.set(key, value, strict);
   9.191 +            super.set(key, value, flags);
   9.192          } else {
   9.193 -            callAdaptee(__put__, key, value, strict);
   9.194 +            callAdaptee(__put__, key, value, flags);
   9.195          }
   9.196      }
   9.197  
    10.1 --- a/src/jdk/nashorn/internal/objects/NativeJSON.java	Wed Sep 24 14:43:37 2014 -0700
    10.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSON.java	Mon Oct 06 15:53:22 2014 -0700
    10.3 @@ -191,7 +191,7 @@
    10.4          state.gap = gap;
    10.5  
    10.6          final ScriptObject wrapper = Global.newEmptyInstance();
    10.7 -        wrapper.set("", value, false);
    10.8 +        wrapper.set("", value, 0);
    10.9  
   10.10          return str("", wrapper, state);
   10.11      }
    11.1 --- a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java	Wed Sep 24 14:43:37 2014 -0700
    11.2 +++ b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java	Mon Oct 06 15:53:22 2014 -0700
    11.3 @@ -146,7 +146,7 @@
    11.4          final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    11.5          final Object value = createProperty(name);
    11.6          if(value != null) {
    11.7 -            set(name, value, false);
    11.8 +            set(name, value, 0);
    11.9              return true;
   11.10          }
   11.11          return false;
    12.1 --- a/src/jdk/nashorn/internal/parser/Parser.java	Wed Sep 24 14:43:37 2014 -0700
    12.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java	Mon Oct 06 15:53:22 2014 -0700
    12.3 @@ -54,6 +54,7 @@
    12.4  import static jdk.nashorn.internal.parser.TokenType.TERNARY;
    12.5  import static jdk.nashorn.internal.parser.TokenType.WHILE;
    12.6  
    12.7 +import java.io.Serializable;
    12.8  import java.util.ArrayDeque;
    12.9  import java.util.ArrayList;
   12.10  import java.util.Collections;
   12.11 @@ -2977,11 +2978,13 @@
   12.12       * Encapsulates part of the state of the parser, enough to reconstruct the state of both parser and lexer
   12.13       * for resuming parsing after skipping a function body.
   12.14       */
   12.15 -    private static class ParserState {
   12.16 +    private static class ParserState implements Serializable {
   12.17          private final int position;
   12.18          private final int line;
   12.19          private final int linePosition;
   12.20  
   12.21 +        private static final long serialVersionUID = -2382565130754093694L;
   12.22 +
   12.23          ParserState(final int position, final int line, final int linePosition) {
   12.24              this.position = position;
   12.25              this.line = line;
    13.1 --- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Wed Sep 24 14:43:37 2014 -0700
    13.2 +++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Mon Oct 06 15:53:22 2014 -0700
    13.3 @@ -119,7 +119,7 @@
    13.4       *   produce different boun method handles wrapping the same access mechanism
    13.5       *   depending on callsite
    13.6       */
    13.7 -    private MethodHandle[] GETTER_CACHE = new MethodHandle[NOOF_TYPES];
    13.8 +    private transient MethodHandle[] GETTER_CACHE = new MethodHandle[NOOF_TYPES];
    13.9  
   13.10      /**
   13.11       * Create a new accessor property. Factory method used by nasgen generated code.
    14.1 --- a/src/jdk/nashorn/internal/runtime/CodeStore.java	Wed Sep 24 14:43:37 2014 -0700
    14.2 +++ b/src/jdk/nashorn/internal/runtime/CodeStore.java	Mon Oct 06 15:53:22 2014 -0700
    14.3 @@ -34,51 +34,42 @@
    14.4  import java.io.ObjectInputStream;
    14.5  import java.io.ObjectOutputStream;
    14.6  import java.io.Serializable;
    14.7 +import java.security.AccessControlException;
    14.8  import java.security.AccessController;
    14.9  import java.security.PrivilegedActionException;
   14.10  import java.security.PrivilegedExceptionAction;
   14.11 +import java.util.Iterator;
   14.12  import java.util.Map;
   14.13 +import java.util.ServiceLoader;
   14.14  import jdk.nashorn.internal.codegen.types.Type;
   14.15  import jdk.nashorn.internal.runtime.logging.DebugLogger;
   14.16  import jdk.nashorn.internal.runtime.logging.Loggable;
   14.17  import jdk.nashorn.internal.runtime.logging.Logger;
   14.18 +import jdk.nashorn.internal.runtime.options.Options;
   14.19  
   14.20  /**
   14.21   * A code cache for persistent caching of compiled scripts.
   14.22   */
   14.23  @Logger(name="codestore")
   14.24 -final class CodeStore implements Loggable {
   14.25 +public abstract class CodeStore implements Loggable {
   14.26  
   14.27 -    private final File dir;
   14.28 -    private final int minSize;
   14.29 -    private final DebugLogger log;
   14.30 +    /**
   14.31 +     * Permission needed to provide a CodeStore instance via ServiceLoader.
   14.32 +     */
   14.33 +    public final static String NASHORN_PROVIDE_CODE_STORE = "nashorn.provideCodeStore";
   14.34  
   14.35 -    // Default minimum size for storing a compiled script class
   14.36 -    private final static int DEFAULT_MIN_SIZE = 1000;
   14.37 +    private DebugLogger log;
   14.38  
   14.39      /**
   14.40       * Constructor
   14.41 -     * @throws IOException
   14.42       */
   14.43 -    public CodeStore(final Context context, final String path) throws IOException {
   14.44 -        this(context, path, DEFAULT_MIN_SIZE);
   14.45 -    }
   14.46 -
   14.47 -    /**
   14.48 -     * Constructor
   14.49 -     * @param path directory to store code in
   14.50 -     * @param minSize minimum file size for caching scripts
   14.51 -     * @throws IOException
   14.52 -     */
   14.53 -    public CodeStore(final Context context, final String path, final int minSize) throws IOException {
   14.54 -        this.dir = checkDirectory(path);
   14.55 -        this.minSize = minSize;
   14.56 -        this.log = initLogger(context);
   14.57 +    protected CodeStore() {
   14.58      }
   14.59  
   14.60      @Override
   14.61      public DebugLogger initLogger(final Context context) {
   14.62 -         return context.getLogger(getClass());
   14.63 +        log = context.getLogger(getClass());
   14.64 +        return log;
   14.65      }
   14.66  
   14.67      @Override
   14.68 @@ -86,29 +77,101 @@
   14.69          return log;
   14.70      }
   14.71  
   14.72 -    private static File checkDirectory(final String path) throws IOException {
   14.73 +    /**
   14.74 +     * Returns a new code store instance.
   14.75 +     *
   14.76 +     * @param context the current context
   14.77 +     * @return The instance
   14.78 +     * @throws IOException If an error occurs
   14.79 +     */
   14.80 +    public static CodeStore newCodeStore(final Context context) throws IOException {
   14.81 +        final Class<CodeStore> baseClass = CodeStore.class;
   14.82          try {
   14.83 -            return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
   14.84 -                @Override
   14.85 -                public File run() throws IOException {
   14.86 -                    final File dir = new File(path).getAbsoluteFile();
   14.87 -                    if (!dir.exists() && !dir.mkdirs()) {
   14.88 -                        throw new IOException("Could not create directory: " + dir.getPath());
   14.89 -                    } else if (!dir.isDirectory()) {
   14.90 -                        throw new IOException("Not a directory: " + dir.getPath());
   14.91 -                    } else if (!dir.canRead() || !dir.canWrite()) {
   14.92 -                        throw new IOException("Directory not readable or writable: " + dir.getPath());
   14.93 -                    }
   14.94 -                    return dir;
   14.95 -                }
   14.96 -            });
   14.97 -        } catch (final PrivilegedActionException e) {
   14.98 -            throw (IOException) e.getException();
   14.99 +            // security check first
  14.100 +            final SecurityManager sm = System.getSecurityManager();
  14.101 +            if (sm != null) {
  14.102 +                sm.checkPermission(new RuntimePermission(NASHORN_PROVIDE_CODE_STORE));
  14.103 +            }
  14.104 +            final ServiceLoader<CodeStore> services = ServiceLoader.load(baseClass);
  14.105 +            final Iterator<CodeStore> iterator = services.iterator();
  14.106 +            if (iterator.hasNext()) {
  14.107 +                final CodeStore store = iterator.next();
  14.108 +                store.initLogger(context).info("using code store provider ", store.getClass().getCanonicalName());
  14.109 +                return store;
  14.110 +            }
  14.111 +        } catch (final AccessControlException e) {
  14.112 +            context.getLogger(CodeStore.class).warning("failed to load code store provider ", e);
  14.113          }
  14.114 +        final CodeStore store = new DirectoryCodeStore();
  14.115 +        store.initLogger(context);
  14.116 +        return store;
  14.117      }
  14.118  
  14.119 -    private File getCacheFile(final Source source, final String functionKey) {
  14.120 -        return new File(dir, source.getDigest() + '-' + functionKey);
  14.121 +
  14.122 +    /**
  14.123 +     * Store a compiled script in the cache.
  14.124 +     *
  14.125 +     * @param functionKey   the function key
  14.126 +     * @param source        the source
  14.127 +     * @param mainClassName the main class name
  14.128 +     * @param classBytes    a map of class bytes
  14.129 +     * @param initializers  the function initializers
  14.130 +     * @param constants     the constants array
  14.131 +     * @param compilationId the compilation id
  14.132 +     */
  14.133 +    public StoredScript store(final String functionKey,
  14.134 +                              final Source source,
  14.135 +                              final String mainClassName,
  14.136 +                              final Map<String, byte[]> classBytes,
  14.137 +                              final Map<Integer, FunctionInitializer> initializers,
  14.138 +                              final Object[] constants,
  14.139 +                              final int compilationId) {
  14.140 +        return store(functionKey, source, storedScriptFor(source, mainClassName, classBytes, initializers, constants, compilationId));
  14.141 +    }
  14.142 +
  14.143 +    /**
  14.144 +     * Stores a compiled script.
  14.145 +     *
  14.146 +     * @param functionKey the function key
  14.147 +     * @param source the source
  14.148 +     * @param script The compiled script
  14.149 +     * @return The compiled script or {@code null} if not stored
  14.150 +     */
  14.151 +    public abstract StoredScript store(final String functionKey,
  14.152 +                                       final Source source,
  14.153 +                                       final StoredScript script);
  14.154 +
  14.155 +    /**
  14.156 +     * Return a compiled script from the cache, or null if it isn't found.
  14.157 +     *
  14.158 +     * @param source      the source
  14.159 +     * @param functionKey the function key
  14.160 +     * @return the stored script or null
  14.161 +     */
  14.162 +    public abstract StoredScript load(final Source source, final String functionKey);
  14.163 +
  14.164 +    /**
  14.165 +     * Returns a new StoredScript instance.
  14.166 +     *
  14.167 +     * @param mainClassName the main class name
  14.168 +     * @param classBytes a map of class bytes
  14.169 +     * @param initializers function initializers
  14.170 +     * @param constants the constants array
  14.171 +     * @param compilationId the compilation id
  14.172 +     * @return The compiled script
  14.173 +     */
  14.174 +    public StoredScript storedScriptFor(final Source source, final String mainClassName,
  14.175 +                                        final Map<String, byte[]> classBytes,
  14.176 +                                        final Map<Integer, FunctionInitializer> initializers,
  14.177 +                                        final Object[] constants, final int compilationId) {
  14.178 +        for (final Object constant : constants) {
  14.179 +            // Make sure all constant data is serializable
  14.180 +            if (!(constant instanceof Serializable)) {
  14.181 +                getLogger().warning("cannot store ", source, " non serializable constant ", constant);
  14.182 +                return null;
  14.183 +            }
  14.184 +        }
  14.185 +        return new StoredScript(compilationId, mainClassName, classBytes, initializers, constants);
  14.186      }
  14.187  
  14.188      /**
  14.189 @@ -129,77 +192,130 @@
  14.190      }
  14.191  
  14.192      /**
  14.193 -     * Return a compiled script from the cache, or null if it isn't found.
  14.194 -     *
  14.195 -     * @param source the source
  14.196 -     * @param functionKey the function key
  14.197 -     * @return the stored script or null
  14.198 +     * A store using a file system directory.
  14.199       */
  14.200 -    public StoredScript loadScript(final Source source, final String functionKey) {
  14.201 -        if (source.getLength() < minSize) {
  14.202 -            return null;
  14.203 +    public static class DirectoryCodeStore extends CodeStore {
  14.204 +
  14.205 +        // Default minimum size for storing a compiled script class
  14.206 +        private final static int DEFAULT_MIN_SIZE = 1000;
  14.207 +
  14.208 +        private final File dir;
  14.209 +        private final boolean readOnly;
  14.210 +        private final int minSize;
  14.211 +
  14.212 +        /**
  14.213 +         * Constructor
  14.214 +         *
  14.215 +         * @throws IOException
  14.216 +         */
  14.217 +        public DirectoryCodeStore() throws IOException {
  14.218 +            this(Options.getStringProperty("nashorn.persistent.code.cache", "nashorn_code_cache"), false, DEFAULT_MIN_SIZE);
  14.219          }
  14.220  
  14.221 -        final File file = getCacheFile(source, functionKey);
  14.222 +        /**
  14.223 +         * Constructor
  14.224 +         *
  14.225 +         * @param path    directory to store code in
  14.226 +         * @param minSize minimum file size for caching scripts
  14.227 +         * @throws IOException
  14.228 +         */
  14.229 +        public DirectoryCodeStore(final String path, final boolean readOnly, final int minSize) throws IOException {
  14.230 +            this.dir = checkDirectory(path, readOnly);
  14.231 +            this.readOnly = readOnly;
  14.232 +            this.minSize = minSize;
  14.233 +        }
  14.234  
  14.235 -        try {
  14.236 -            return AccessController.doPrivileged(new PrivilegedExceptionAction<StoredScript>() {
  14.237 -                @Override
  14.238 -                public StoredScript run() throws IOException, ClassNotFoundException {
  14.239 -                    if (!file.exists()) {
  14.240 -                        return null;
  14.241 +        private static File checkDirectory(final String path, final boolean readOnly) throws IOException {
  14.242 +            try {
  14.243 +                return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
  14.244 +                    @Override
  14.245 +                    public File run() throws IOException {
  14.246 +                        final File dir = new File(path).getAbsoluteFile();
  14.247 +                        if (readOnly) {
  14.248 +                            if (!dir.exists() || !dir.isDirectory()) {
  14.249 +                                throw new IOException("Not a directory: " + dir.getPath());
  14.250 +                            } else if (!dir.canRead()) {
  14.251 +                                throw new IOException("Directory not readable: " + dir.getPath());
  14.252 +                            }
  14.253 +                        } else if (!dir.exists() && !dir.mkdirs()) {
  14.254 +                            throw new IOException("Could not create directory: " + dir.getPath());
  14.255 +                        } else if (!dir.isDirectory()) {
  14.256 +                            throw new IOException("Not a directory: " + dir.getPath());
  14.257 +                        } else if (!dir.canRead() || !dir.canWrite()) {
  14.258 +                            throw new IOException("Directory not readable or writable: " + dir.getPath());
  14.259 +                        }
  14.260 +                        return dir;
  14.261                      }
  14.262 -                    try (ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)))) {
  14.263 -                        final StoredScript storedScript = (StoredScript) in.readObject();
  14.264 -                        getLogger().info("loaded ", source, "-", functionKey);
  14.265 -                        return storedScript;
  14.266 -                    }
  14.267 -                }
  14.268 -            });
  14.269 -        } catch (final PrivilegedActionException e) {
  14.270 -            getLogger().warning("failed to load ", source, "-", functionKey, ": ", e.getException());
  14.271 -            return null;
  14.272 -        }
  14.273 -    }
  14.274 -
  14.275 -    /**
  14.276 -     * Store a compiled script in the cache.
  14.277 -     *
  14.278 -     * @param functionKey the function key
  14.279 -     * @param source the source
  14.280 -     * @param mainClassName the main class name
  14.281 -     * @param classBytes a map of class bytes
  14.282 -     * @param constants the constants array
  14.283 -     */
  14.284 -    public void storeScript(final String functionKey, final Source source, final String mainClassName, final Map<String, byte[]> classBytes,
  14.285 -                          final Map<Integer, FunctionInitializer> initializers, final Object[] constants, final int compilationId) {
  14.286 -        if (source.getLength() < minSize) {
  14.287 -            return;
  14.288 -        }
  14.289 -        for (final Object constant : constants) {
  14.290 -            // Make sure all constant data is serializable
  14.291 -            if (! (constant instanceof Serializable)) {
  14.292 -                getLogger().warning("cannot store ", source, " non serializable constant ", constant);
  14.293 -                return;
  14.294 +                });
  14.295 +            } catch (final PrivilegedActionException e) {
  14.296 +                throw (IOException) e.getException();
  14.297              }
  14.298          }
  14.299  
  14.300 -        final File file = getCacheFile(source, functionKey);
  14.301 -        final StoredScript script = new StoredScript(compilationId, mainClassName, classBytes, initializers, constants);
  14.302 +        @Override
  14.303 +        public StoredScript load(final Source source, final String functionKey) {
  14.304 +            if (source.getLength() < minSize) {
  14.305 +                return null;
  14.306 +            }
  14.307  
  14.308 -        try {
  14.309 -            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
  14.310 -                @Override
  14.311 -                public Void run() throws IOException {
  14.312 -                    try (ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
  14.313 -                        out.writeObject(script);
  14.314 +            final File file = getCacheFile(source, functionKey);
  14.315 +
  14.316 +            try {
  14.317 +                return AccessController.doPrivileged(new PrivilegedExceptionAction<StoredScript>() {
  14.318 +                    @Override
  14.319 +                    public StoredScript run() throws IOException, ClassNotFoundException {
  14.320 +                        if (!file.exists()) {
  14.321 +                            return null;
  14.322 +                        }
  14.323 +                        try (ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)))) {
  14.324 +                            final StoredScript storedScript = (StoredScript) in.readObject();
  14.325 +                            getLogger().info("loaded ", source, "-", functionKey);
  14.326 +                            return storedScript;
  14.327 +                        }
  14.328                      }
  14.329 -                    getLogger().info("stored ", source, "-", functionKey);
  14.330 -                    return null;
  14.331 -                }
  14.332 -            });
  14.333 -        } catch (final PrivilegedActionException e) {
  14.334 -            getLogger().warning("failed to store ", script, "-", functionKey, ": ", e.getException());
  14.335 +                });
  14.336 +            } catch (final PrivilegedActionException e) {
  14.337 +                getLogger().warning("failed to load ", source, "-", functionKey, ": ", e.getException());
  14.338 +                return null;
  14.339 +            }
  14.340 +        }
  14.341 +
  14.342 +        @Override
  14.343 +        public StoredScript store(final String functionKey, final Source source, final StoredScript script) {
  14.344 +            if (readOnly || script == null || belowThreshold(source)) {
  14.345 +                return null;
  14.346 +            }
  14.347 +
  14.348 +            final File file = getCacheFile(source, functionKey);
  14.349 +
  14.350 +            try {
  14.351 +                return AccessController.doPrivileged(new PrivilegedExceptionAction<StoredScript>() {
  14.352 +                    @Override
  14.353 +                    public StoredScript run() throws IOException {
  14.354 +                        try (ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
  14.355 +                            out.writeObject(script);
  14.356 +                        }
  14.357 +                        getLogger().info("stored ", source, "-", functionKey);
  14.358 +                        return script;
  14.359 +                    }
  14.360 +                });
  14.361 +            } catch (final PrivilegedActionException e) {
  14.362 +                getLogger().warning("failed to store ", script, "-", functionKey, ": ", e.getException());
  14.363 +                return null;
  14.364 +            }
  14.365 +        }
  14.366 +
  14.367 +
  14.368 +        private File getCacheFile(final Source source, final String functionKey) {
  14.369 +            return new File(dir, source.getDigest() + '-' + functionKey);
  14.370 +        }
  14.371 +
  14.372 +        private boolean belowThreshold(final Source source) {
  14.373 +            if (source.getLength() < minSize) {
  14.374 +                getLogger().info("below size threshold ", source);
  14.375 +                return true;
  14.376 +            }
  14.377 +            return false;
  14.378          }
  14.379      }
  14.380  }
    15.1 --- a/src/jdk/nashorn/internal/runtime/Context.java	Wed Sep 24 14:43:37 2014 -0700
    15.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java	Mon Oct 06 15:53:22 2014 -0700
    15.3 @@ -29,6 +29,7 @@
    15.4  import static jdk.nashorn.internal.codegen.CompilerConstants.CREATE_PROGRAM_FUNCTION;
    15.5  import static jdk.nashorn.internal.codegen.CompilerConstants.SOURCE;
    15.6  import static jdk.nashorn.internal.codegen.CompilerConstants.STRICT_MODE;
    15.7 +import static jdk.nashorn.internal.runtime.CodeStore.newCodeStore;
    15.8  import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
    15.9  import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
   15.10  import static jdk.nashorn.internal.runtime.Source.sourceFor;
   15.11 @@ -200,14 +201,14 @@
   15.12                                  final Map<String,byte[]> classBytes, final Map<Integer, FunctionInitializer> initializers,
   15.13                                  final Object[] constants, final int compilationId) {
   15.14              if (context.codeStore != null) {
   15.15 -                context.codeStore.storeScript(cacheKey, source, mainClassName, classBytes, initializers, constants, compilationId);
   15.16 +                context.codeStore.store(cacheKey, source, mainClassName, classBytes, initializers, constants, compilationId);
   15.17              }
   15.18          }
   15.19  
   15.20          @Override
   15.21          public StoredScript loadScript(final Source source, final String functionKey) {
   15.22              if (context.codeStore != null) {
   15.23 -                return context.codeStore.loadScript(source, functionKey);
   15.24 +                return context.codeStore.load(source, functionKey);
   15.25              }
   15.26              return null;
   15.27          }
   15.28 @@ -463,8 +464,7 @@
   15.29  
   15.30          if (env._persistent_cache) {
   15.31              try {
   15.32 -                final String cacheDir = Options.getStringProperty("nashorn.persistent.code.cache", "nashorn_code_cache");
   15.33 -                codeStore = new CodeStore(this, cacheDir);
   15.34 +                codeStore = newCodeStore(this);
   15.35              } catch (final IOException e) {
   15.36                  throw new RuntimeException("Error initializing code cache", e);
   15.37              }
   15.38 @@ -1117,7 +1117,7 @@
   15.39          final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null;
   15.40  
   15.41          if (useCodeStore) {
   15.42 -            storedScript = codeStore.loadScript(source, cacheKey);
   15.43 +            storedScript = codeStore.load(source, cacheKey);
   15.44          }
   15.45  
   15.46          if (storedScript == null) {
   15.47 @@ -1194,15 +1194,16 @@
   15.48      private static Class<?> install(final StoredScript storedScript, final Source source, final CodeInstaller<ScriptEnvironment> installer) {
   15.49  
   15.50          final Map<String, Class<?>> installedClasses = new HashMap<>();
   15.51 +        final Map<String, byte[]>   classBytes       = storedScript.getClassBytes();
   15.52          final Object[] constants       = storedScript.getConstants();
   15.53          final String   mainClassName   = storedScript.getMainClassName();
   15.54 -        final byte[]   mainClassBytes  = storedScript.getClassBytes().get(mainClassName);
   15.55 +        final byte[]   mainClassBytes  = classBytes.get(mainClassName);
   15.56          final Class<?> mainClass       = installer.install(mainClassName, mainClassBytes);
   15.57          final Map<Integer, FunctionInitializer> initialzers = storedScript.getInitializers();
   15.58  
   15.59          installedClasses.put(mainClassName, mainClass);
   15.60  
   15.61 -        for (final Map.Entry<String, byte[]> entry : storedScript.getClassBytes().entrySet()) {
   15.62 +        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
   15.63              final String className = entry.getKey();
   15.64              if (className.equals(mainClassName)) {
   15.65                  continue;
    16.1 --- a/src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java	Wed Sep 24 14:43:37 2014 -0700
    16.2 +++ b/src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java	Mon Oct 06 15:53:22 2014 -0700
    16.3 @@ -112,82 +112,82 @@
    16.4      }
    16.5  
    16.6      @Override
    16.7 -    public void set(final double key, final int value, final boolean strict) {
    16.8 -        set(JSType.toObject(key), JSType.toObject(value), strict);
    16.9 +    public void set(final double key, final int value, final int flags) {
   16.10 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.11      }
   16.12  
   16.13      @Override
   16.14 -    public void set(final double key, final long value, final boolean strict) {
   16.15 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.16 +    public void set(final double key, final long value, final int flags) {
   16.17 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.18      }
   16.19  
   16.20      @Override
   16.21 -    public void set(final double key, final double value, final boolean strict) {
   16.22 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.23 +    public void set(final double key, final double value, final int flags) {
   16.24 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.25      }
   16.26  
   16.27      @Override
   16.28 -    public void set(final double key, final Object value, final boolean strict) {
   16.29 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.30 +    public void set(final double key, final Object value, final int flags) {
   16.31 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.32      }
   16.33  
   16.34      @Override
   16.35 -    public void set(final long key, final int value, final boolean strict) {
   16.36 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.37 +    public void set(final long key, final int value, final int flags) {
   16.38 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.39      }
   16.40  
   16.41      @Override
   16.42 -    public void set(final long key, final long value, final boolean strict) {
   16.43 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.44 +    public void set(final long key, final long value, final int flags) {
   16.45 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.46      }
   16.47  
   16.48      @Override
   16.49 -    public void set(final long key, final double value, final boolean strict) {
   16.50 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.51 +    public void set(final long key, final double value, final int flags) {
   16.52 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.53      }
   16.54  
   16.55      @Override
   16.56 -    public void set(final long key, final Object value, final boolean strict) {
   16.57 -        set(JSType.toObject(key), value, strict);
   16.58 +    public void set(final long key, final Object value, final int flags) {
   16.59 +        set(JSType.toObject(key), value, flags);
   16.60      }
   16.61  
   16.62      @Override
   16.63 -    public void set(final int key, final int value, final boolean strict) {
   16.64 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.65 +    public void set(final int key, final int value, final int flags) {
   16.66 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.67      }
   16.68  
   16.69      @Override
   16.70 -    public void set(final int key, final long value, final boolean strict) {
   16.71 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.72 +    public void set(final int key, final long value, final int flags) {
   16.73 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.74      }
   16.75  
   16.76      @Override
   16.77 -    public void set(final int key, final double value, final boolean strict) {
   16.78 -        set(JSType.toObject(key), JSType.toObject(value), strict);
   16.79 +    public void set(final int key, final double value, final int flags) {
   16.80 +        set(JSType.toObject(key), JSType.toObject(value), flags);
   16.81      }
   16.82  
   16.83      @Override
   16.84 -    public void set(final int key, final Object value, final boolean strict) {
   16.85 -        set(JSType.toObject(key), value, strict);
   16.86 +    public void set(final int key, final Object value, final int flags) {
   16.87 +        set(JSType.toObject(key), value, flags);
   16.88      }
   16.89  
   16.90      @Override
   16.91 -    public void set(final Object key, final int value, final boolean strict) {
   16.92 -        set(key, JSType.toObject(value), strict);
   16.93 +    public void set(final Object key, final int value, final int flags) {
   16.94 +        set(key, JSType.toObject(value), flags);
   16.95      }
   16.96  
   16.97      @Override
   16.98 -    public void set(final Object key, final long value, final boolean strict) {
   16.99 -        set(key, JSType.toObject(value), strict);
  16.100 +    public void set(final Object key, final long value, final int flags) {
  16.101 +        set(key, JSType.toObject(value), flags);
  16.102      }
  16.103  
  16.104      @Override
  16.105 -    public void set(final Object key, final double value, final boolean strict) {
  16.106 -        set(key, JSType.toObject(value), strict);
  16.107 +    public void set(final Object key, final double value, final int flags) {
  16.108 +        set(key, JSType.toObject(value), flags);
  16.109      }
  16.110  
  16.111      @Override
  16.112 -    public abstract void set(Object key, Object value, boolean strict);
  16.113 +    public abstract void set(Object key, Object value, int flags);
  16.114  
  16.115      @Override
  16.116      public abstract boolean has(Object key);
    17.1 --- a/src/jdk/nashorn/internal/runtime/ECMAException.java	Wed Sep 24 14:43:37 2014 -0700
    17.2 +++ b/src/jdk/nashorn/internal/runtime/ECMAException.java	Mon Oct 06 15:53:22 2014 -0700
    17.3 @@ -285,7 +285,7 @@
    17.4              if (!sobj.has(EXCEPTION_PROPERTY)) {
    17.5                  sobj.addOwnProperty(EXCEPTION_PROPERTY, Property.NOT_ENUMERABLE, this);
    17.6              } else {
    17.7 -                sobj.set(EXCEPTION_PROPERTY, this, false);
    17.8 +                sobj.set(EXCEPTION_PROPERTY, this, 0);
    17.9              }
   17.10          }
   17.11      }
    18.1 --- a/src/jdk/nashorn/internal/runtime/FindProperty.java	Wed Sep 24 14:43:37 2014 -0700
    18.2 +++ b/src/jdk/nashorn/internal/runtime/FindProperty.java	Mon Oct 06 15:53:22 2014 -0700
    18.3 @@ -139,6 +139,17 @@
    18.4      }
    18.5  
    18.6      /**
    18.7 +     * Return the {@code ScriptObject} where the search started. This is usually the ScriptObject the
    18.8 +     * operation was started on, except for properties found inside a 'with' statement, where it is the
    18.9 +     * top-level 'with' expression object.
   18.10 +     *
   18.11 +     * @return the start object.
   18.12 +     */
   18.13 +    public ScriptObject getSelf() {
   18.14 +        return self;
   18.15 +    }
   18.16 +
   18.17 +    /**
   18.18       * Return the appropriate receiver for a getter.
   18.19       * @return appropriate receiver
   18.20       */
    19.1 --- a/src/jdk/nashorn/internal/runtime/FunctionInitializer.java	Wed Sep 24 14:43:37 2014 -0700
    19.2 +++ b/src/jdk/nashorn/internal/runtime/FunctionInitializer.java	Mon Oct 06 15:53:22 2014 -0700
    19.3 @@ -60,6 +60,17 @@
    19.4      }
    19.5  
    19.6      /**
    19.7 +     * Copy constructor.
    19.8 +     *
    19.9 +     * @param init original initializer
   19.10 +     */
   19.11 +    FunctionInitializer(final FunctionInitializer init) {
   19.12 +        this.className = init.getClassName();
   19.13 +        this.methodType = init.getMethodType();
   19.14 +        this.flags = init.getFlags();
   19.15 +    }
   19.16 +
   19.17 +    /**
   19.18       * Constructor.
   19.19       *
   19.20       * @param functionNode the function node
    20.1 --- a/src/jdk/nashorn/internal/runtime/GlobalConstants.java	Wed Sep 24 14:43:37 2014 -0700
    20.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalConstants.java	Mon Oct 06 15:53:22 2014 -0700
    20.3 @@ -309,7 +309,7 @@
    20.4       *
    20.5       * @param find    property lookup
    20.6       * @param inv     normal guarded invocation for this setter, as computed by the ScriptObject linker
    20.7 -     * @param desc    callsite descriptr
    20.8 +     * @param desc    callsite descriptor
    20.9       * @param request link request
   20.10       *
   20.11       * @return null if failed to set up constant linkage
   20.12 @@ -376,8 +376,12 @@
   20.13       * @return resulting getter, or null if failed to create constant
   20.14       */
   20.15      synchronized GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) {
   20.16 -        // Also return null if property may have side effects
   20.17 -        if ((GLOBAL_ONLY && !find.getOwner().isGlobal()) || find.getProperty() instanceof UserAccessorProperty) {
   20.18 +        // Only use constant getter for fast scope access, because the receiver may change between invocations
   20.19 +        // for slow-scope and non-scope callsites.
   20.20 +        // Also return null for user accessor properties as they may have side effects.
   20.21 +        if (!NashornCallSiteDescriptor.isFastScope(desc)
   20.22 +                || (GLOBAL_ONLY && !find.getOwner().isGlobal())
   20.23 +                || find.getProperty() instanceof UserAccessorProperty) {
   20.24              return null;
   20.25          }
   20.26  
    21.1 --- a/src/jdk/nashorn/internal/runtime/JSONFunctions.java	Wed Sep 24 14:43:37 2014 -0700
    21.2 +++ b/src/jdk/nashorn/internal/runtime/JSONFunctions.java	Mon Oct 06 15:53:22 2014 -0700
    21.3 @@ -122,7 +122,7 @@
    21.4                  if (newElement == ScriptRuntime.UNDEFINED) {
    21.5                      valueObj.delete(key, false);
    21.6                  } else {
    21.7 -                    setPropertyValue(valueObj, key, newElement, false);
    21.8 +                    setPropertyValue(valueObj, key, newElement);
    21.9                  }
   21.10              }
   21.11          }
   21.12 @@ -179,7 +179,7 @@
   21.13  
   21.14                  final String name = pNode.getKeyName();
   21.15                  final Object value = convertNode(global, valueNode);
   21.16 -                setPropertyValue(object, name, value, false);
   21.17 +                setPropertyValue(object, name, value);
   21.18              }
   21.19  
   21.20              return object;
   21.21 @@ -193,14 +193,14 @@
   21.22      }
   21.23  
   21.24      // add a new property if does not exist already, or else set old property
   21.25 -    private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value, final boolean strict) {
   21.26 +    private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value) {
   21.27          final int index = ArrayIndex.getArrayIndex(name);
   21.28          if (ArrayIndex.isValidArrayIndex(index)) {
   21.29              // array index key
   21.30              sobj.defineOwnProperty(index, value);
   21.31          } else if (sobj.getMap().findProperty(name) != null) {
   21.32              // pre-existing non-inherited property, call set
   21.33 -            sobj.set(name, value, strict);
   21.34 +            sobj.set(name, value, 0);
   21.35          } else {
   21.36              // add new property
   21.37              sobj.addOwnProperty(name, Property.WRITABLE_ENUMERABLE_CONFIGURABLE, value);
    22.1 --- a/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java	Wed Sep 24 14:43:37 2014 -0700
    22.2 +++ b/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java	Mon Oct 06 15:53:22 2014 -0700
    22.3 @@ -256,7 +256,7 @@
    22.4              final Object constructor = BeansLinker.getConstructorMethod(
    22.5                      javaClass, propertyName.substring(openBrace + 1, lastChar));
    22.6              if (constructor != null) {
    22.7 -                set(propertyName, constructor, false);
    22.8 +                set(propertyName, constructor, 0);
    22.9                  return constructor;
   22.10              }
   22.11              // we didn't find a matching constructor!
   22.12 @@ -270,7 +270,7 @@
   22.13              propertyValue = StaticClass.forClass(javaClass);
   22.14          }
   22.15  
   22.16 -        set(propertyName, propertyValue, false);
   22.17 +        set(propertyName, propertyValue, 0);
   22.18          return propertyValue;
   22.19      }
   22.20  }
    23.1 --- a/src/jdk/nashorn/internal/runtime/Property.java	Wed Sep 24 14:43:37 2014 -0700
    23.2 +++ b/src/jdk/nashorn/internal/runtime/Property.java	Mon Oct 06 15:53:22 2014 -0700
    23.3 @@ -101,7 +101,7 @@
    23.4      private final int slot;
    23.5  
    23.6      /** SwitchPoint that is invalidated when property is changed, optional */
    23.7 -    protected SwitchPoint changeCallback;
    23.8 +    protected transient SwitchPoint changeCallback;
    23.9  
   23.10      private static final long serialVersionUID = 2099814273074501176L;
   23.11  
    24.1 --- a/src/jdk/nashorn/internal/runtime/PropertyAccess.java	Wed Sep 24 14:43:37 2014 -0700
    24.2 +++ b/src/jdk/nashorn/internal/runtime/PropertyAccess.java	Mon Oct 06 15:53:22 2014 -0700
    24.3 @@ -163,129 +163,129 @@
    24.4       * Set the value of a given key
    24.5       * @param key     the key
    24.6       * @param value   the value
    24.7 -     * @param strict  are we in strict mode
    24.8 +     * @param flags   call site flags
    24.9       */
   24.10 -    public void set(Object key, int value, boolean strict);
   24.11 +    public void set(Object key, int value, int flags);
   24.12  
   24.13      /**
   24.14       * Set the value of a given key
   24.15       * @param key     the key
   24.16       * @param value   the value
   24.17 -     * @param strict  are we in strict mode
   24.18 +     * @param flags   call site flags
   24.19       */
   24.20 -    public void set(Object key, long value, boolean strict);
   24.21 +    public void set(Object key, long value, int flags);
   24.22  
   24.23      /**
   24.24       * Set the value of a given key
   24.25       * @param key     the key
   24.26       * @param value   the value
   24.27 -     * @param strict  are we in strict mode
   24.28 +     * @param flags   call site flags
   24.29       */
   24.30 -    public void set(Object key, double value, boolean strict);
   24.31 +    public void set(Object key, double value, int flags);
   24.32  
   24.33      /**
   24.34       * Set the value of a given key
   24.35       * @param key     the key
   24.36       * @param value   the value
   24.37 -     * @param strict  are we in strict mode
   24.38 +     * @param flags   call site flags
   24.39       */
   24.40 -    public void set(Object key, Object value, boolean strict);
   24.41 +    public void set(Object key, Object value, int flags);
   24.42  
   24.43      /**
   24.44       * Set the value of a given key
   24.45       * @param key     the key
   24.46       * @param value   the value
   24.47 -     * @param strict  are we in strict mode
   24.48 +     * @param flags   call site flags
   24.49       */
   24.50 -    public void set(double key, int value, boolean strict);
   24.51 +    public void set(double key, int value, int flags);
   24.52  
   24.53      /**
   24.54       * Set the value of a given key
   24.55       * @param key     the key
   24.56       * @param value   the value
   24.57 -     * @param strict  are we in strict mode
   24.58 +     * @param flags   call site flags
   24.59       */
   24.60 -    public void set(double key, long value, boolean strict);
   24.61 +    public void set(double key, long value, int flags);
   24.62  
   24.63      /**
   24.64       * Set the value of a given key
   24.65       * @param key     the key
   24.66       * @param value   the value
   24.67 -     * @param strict  are we in strict mode
   24.68 +     * @param flags   call site flags
   24.69       */
   24.70 -    public void set(double key, double value, boolean strict);
   24.71 +    public void set(double key, double value, int flags);
   24.72  
   24.73      /**
   24.74       * Set the value of a given key
   24.75       * @param key     the key
   24.76       * @param value   the value
   24.77 -     * @param strict  are we in strict mode
   24.78 +     * @param flags   call site flags
   24.79       */
   24.80 -    public void set(double key, Object value, boolean strict);
   24.81 +    public void set(double key, Object value, int flags);
   24.82  
   24.83      /**
   24.84       * Set the value of a given key
   24.85       * @param key     the key
   24.86       * @param value   the value
   24.87 -     * @param strict  are we in strict mode
   24.88 +     * @param flags   call site flags
   24.89       */
   24.90 -    public void set(long key, int value, boolean strict);
   24.91 +    public void set(long key, int value, int flags);
   24.92  
   24.93      /**
   24.94       * Set the value of a given key
   24.95       * @param key     the key
   24.96       * @param value   the value
   24.97 -     * @param strict  are we in strict mode
   24.98 +     * @param flags   call site flags
   24.99       */
  24.100 -    public void set(long key, long value, boolean strict);
  24.101 +    public void set(long key, long value, int flags);
  24.102  
  24.103      /**
  24.104       * Set the value of a given key
  24.105       * @param key     the key
  24.106       * @param value   the value
  24.107 -     * @param strict  are we in strict mode
  24.108 +     * @param flags   call site flags
  24.109       */
  24.110 -    public void set(long key, double value, boolean strict);
  24.111 +    public void set(long key, double value, int flags);
  24.112  
  24.113      /**
  24.114       * Set the value of a given key
  24.115       * @param key     the key
  24.116       * @param value   the value
  24.117 -     * @param strict  are we in strict mode
  24.118 +     * @param flags   call site flags
  24.119       */
  24.120 -    public void set(long key, Object value, boolean strict);
  24.121 +    public void set(long key, Object value, int flags);
  24.122  
  24.123      /**
  24.124       * Set the value of a given key
  24.125       * @param key     the key
  24.126       * @param value   the value
  24.127 -     * @param strict  are we in strict mode
  24.128 +     * @param flags   call site flags
  24.129       */
  24.130 -    public void set(int key, int value, boolean strict);
  24.131 +    public void set(int key, int value, int flags);
  24.132  
  24.133      /**
  24.134       * Set the value of a given key
  24.135       * @param key     the key
  24.136       * @param value   the value
  24.137 -     * @param strict  are we in strict mode
  24.138 +     * @param flags   call site flags
  24.139       */
  24.140 -    public void set(int key, long value, boolean strict);
  24.141 +    public void set(int key, long value, int flags);
  24.142  
  24.143      /**
  24.144       * Set the value of a given key
  24.145       * @param key     the key
  24.146       * @param value   the value
  24.147 -     * @param strict  are we in strict mode
  24.148 +     * @param flags   call site flags
  24.149       */
  24.150 -    public void set(int key, double value, boolean strict);
  24.151 +    public void set(int key, double value, int flags);
  24.152  
  24.153      /**
  24.154       * Set the value of a given key
  24.155       * @param key     the key
  24.156       * @param value   the value
  24.157 -     * @param strict  are we in strict mode
  24.158 +     * @param flags   call site flags
  24.159       */
  24.160 -    public void set(int key, Object value, boolean strict);
  24.161 +    public void set(int key, Object value, int flags);
  24.162  
  24.163      /**
  24.164       * Check if the given key exists anywhere in the proto chain
    25.1 --- a/src/jdk/nashorn/internal/runtime/PropertyMap.java	Wed Sep 24 14:43:37 2014 -0700
    25.2 +++ b/src/jdk/nashorn/internal/runtime/PropertyMap.java	Mon Oct 06 15:53:22 2014 -0700
    25.3 @@ -568,9 +568,7 @@
    25.4          for (final Property property : otherProperties) {
    25.5              // This method is only safe to use with non-slotted, native getter/setter properties
    25.6              assert property.getSlot() == -1;
    25.7 -            if (isValidArrayIndex(getArrayIndex(property.getKey()))) {
    25.8 -                newMap.setContainsArrayKeys();
    25.9 -            }
   25.10 +            assert !(isValidArrayIndex(getArrayIndex(property.getKey())));
   25.11          }
   25.12  
   25.13          return newMap;
    26.1 --- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Wed Sep 24 14:43:37 2014 -0700
    26.2 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Mon Oct 06 15:53:22 2014 -0700
    26.3 @@ -491,14 +491,15 @@
    26.4      private FunctionInitializer install(final StoredScript script) {
    26.5  
    26.6          final Map<String, Class<?>> installedClasses = new HashMap<>();
    26.7 +        final Map<String, byte[]>   classBytes       = script.getClassBytes();
    26.8          final String   mainClassName   = script.getMainClassName();
    26.9 -        final byte[]   mainClassBytes  = script.getClassBytes().get(mainClassName);
   26.10 +        final byte[]   mainClassBytes  = classBytes.get(mainClassName);
   26.11  
   26.12          final Class<?> mainClass       = installer.install(mainClassName, mainClassBytes);
   26.13  
   26.14          installedClasses.put(mainClassName, mainClass);
   26.15  
   26.16 -        for (final Map.Entry<String, byte[]> entry : script.getClassBytes().entrySet()) {
   26.17 +        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
   26.18              final String className = entry.getKey();
   26.19              final byte[] code = entry.getValue();
   26.20  
    27.1 --- a/src/jdk/nashorn/internal/runtime/RewriteException.java	Wed Sep 24 14:43:37 2014 -0700
    27.2 +++ b/src/jdk/nashorn/internal/runtime/RewriteException.java	Mon Oct 06 15:53:22 2014 -0700
    27.3 @@ -45,6 +45,7 @@
    27.4  import jdk.nashorn.internal.lookup.MethodHandleFactory;
    27.5  import jdk.nashorn.internal.lookup.MethodHandleFunctionality;
    27.6  import jdk.nashorn.internal.objects.Global;
    27.7 +import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
    27.8  
    27.9  /**
   27.10   * Used to signal to the linker to relink the callee
   27.11 @@ -161,7 +162,7 @@
   27.12                  assert runtimeScope == null;
   27.13                  runtimeScope = (ScriptObject)value;
   27.14              } else if(name != null) {
   27.15 -                locals.set(name, value, true);
   27.16 +                locals.set(name, value, NashornCallSiteDescriptor.CALLSITE_STRICT);
   27.17              }
   27.18          }
   27.19          locals.setProto(runtimeScope);
    28.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Wed Sep 24 14:43:37 2014 -0700
    28.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Mon Oct 06 15:53:22 2014 -0700
    28.3 @@ -198,10 +198,10 @@
    28.4      public static final Call SET_USER_ACCESSORS = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class);
    28.5  
    28.6      static final MethodHandle[] SET_SLOW = new MethodHandle[] {
    28.7 -        findOwnMH_V("set", void.class, Object.class, int.class, boolean.class),
    28.8 -        findOwnMH_V("set", void.class, Object.class, long.class, boolean.class),
    28.9 -        findOwnMH_V("set", void.class, Object.class, double.class, boolean.class),
   28.10 -        findOwnMH_V("set", void.class, Object.class, Object.class, boolean.class)
   28.11 +        findOwnMH_V("set", void.class, Object.class, int.class, int.class),
   28.12 +        findOwnMH_V("set", void.class, Object.class, long.class, int.class),
   28.13 +        findOwnMH_V("set", void.class, Object.class, double.class, int.class),
   28.14 +        findOwnMH_V("set", void.class, Object.class, Object.class, int.class)
   28.15      };
   28.16  
   28.17      /** Method handle to reset the map of this ScriptObject */
   28.18 @@ -593,7 +593,7 @@
   28.19              if (newValue && property != null) {
   28.20                  // Temporarily clear flags.
   28.21                  property = modifyOwnProperty(property, 0);
   28.22 -                set(key, value, false);
   28.23 +                set(key, value, 0);
   28.24                  //this might change the map if we change types of the property
   28.25                  //hence we need to read it again. note that we should probably
   28.26                  //have the setter return the new property throughout and in
   28.27 @@ -758,7 +758,7 @@
   28.28       * @return FindPropertyData or null if not found.
   28.29       */
   28.30      public final FindProperty findProperty(final String key, final boolean deep) {
   28.31 -        return findProperty(key, deep, false, this);
   28.32 +        return findProperty(key, deep, this);
   28.33      }
   28.34  
   28.35      /**
   28.36 @@ -775,16 +775,11 @@
   28.37       *
   28.38       * @param key  Property key.
   28.39       * @param deep Whether the search should look up proto chain.
   28.40 -     * @param stopOnNonScope should a deep search stop on the first non-scope object?
   28.41       * @param start the object on which the lookup was originally initiated
   28.42       *
   28.43       * @return FindPropertyData or null if not found.
   28.44       */
   28.45 -    FindProperty findProperty(final String key, final boolean deep, final boolean stopOnNonScope, final ScriptObject start) {
   28.46 -        // if doing deep search, stop search on the first non-scope object if asked to do so
   28.47 -        if (stopOnNonScope && start != this && !isScope()) {
   28.48 -            return null;
   28.49 -        }
   28.50 +    FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
   28.51  
   28.52          final PropertyMap selfMap  = getMap();
   28.53          final Property    property = selfMap.findProperty(key);
   28.54 @@ -796,7 +791,7 @@
   28.55          if (deep) {
   28.56              final ScriptObject myProto = getProto();
   28.57              if (myProto != null) {
   28.58 -                return myProto.findProperty(key, deep, stopOnNonScope, start);
   28.59 +                return myProto.findProperty(key, deep, start);
   28.60              }
   28.61          }
   28.62  
   28.63 @@ -1164,7 +1159,7 @@
   28.64       * @param value the value to write at the given index
   28.65       */
   28.66      public void setArgument(final int key, final Object value) {
   28.67 -        set(key, value, false);
   28.68 +        set(key, value, 0);
   28.69      }
   28.70  
   28.71      /**
   28.72 @@ -1725,7 +1720,8 @@
   28.73       */
   28.74      public Object put(final Object key, final Object value, final boolean strict) {
   28.75          final Object oldValue = get(key);
   28.76 -        set(key, value, strict);
   28.77 +        final int flags = strict ? NashornCallSiteDescriptor.CALLSITE_STRICT : 0;
   28.78 +        set(key, value, flags);
   28.79          return oldValue;
   28.80      }
   28.81  
   28.82 @@ -1738,8 +1734,9 @@
   28.83       * @param strict strict mode or not
   28.84       */
   28.85      public void putAll(final Map<?, ?> otherMap, final boolean strict) {
   28.86 +        final int flags = strict ? NashornCallSiteDescriptor.CALLSITE_STRICT : 0;
   28.87          for (final Map.Entry<?, ?> entry : otherMap.entrySet()) {
   28.88 -            set(entry.getKey(), entry.getValue(), strict);
   28.89 +            set(entry.getKey(), entry.getValue(), flags);
   28.90          }
   28.91      }
   28.92  
   28.93 @@ -2042,7 +2039,7 @@
   28.94  
   28.95          final PropertyMap newMap = map.replaceProperty(property, property.removeFlags(Property.NEEDS_DECLARATION));
   28.96          setMap(newMap);
   28.97 -        set(key, value, true);
   28.98 +        set(key, value, 0);
   28.99      }
  28.100  
  28.101      /**
  28.102 @@ -2135,7 +2132,6 @@
  28.103              return findMegaMorphicSetMethod(desc, name);
  28.104          }
  28.105  
  28.106 -        final boolean scope                   = isScope();
  28.107          final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
  28.108  
  28.109          /*
  28.110 @@ -2145,16 +2141,18 @@
  28.111           *
  28.112           * toString = function() { print("global toString"); } // don't affect Object.prototype.toString
  28.113           */
  28.114 -        FindProperty find = findProperty(name, true, scope, this);
  28.115 +        FindProperty find = findProperty(name, true, this);
  28.116  
  28.117          // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors.
  28.118 -        if (!scope && find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
  28.119 +        if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
  28.120              // We should still check if inherited data property is not writable
  28.121              if (isExtensible() && !find.getProperty().isWritable()) {
  28.122 -                return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", false);
  28.123 +                return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
  28.124              }
  28.125 -            // Otherwise, forget the found property
  28.126 -            find = null;
  28.127 +            // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well.
  28.128 +            if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) {
  28.129 +                find = null;
  28.130 +            }
  28.131          }
  28.132  
  28.133          if (find != null) {
  28.134 @@ -2180,8 +2178,8 @@
  28.135  
  28.136      private GuardedInvocation createEmptySetMethod(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String strictErrorMessage, final boolean canBeFastScope) {
  28.137          final String  name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
  28.138 -         if (NashornCallSiteDescriptor.isStrict(desc)) {
  28.139 -           throw typeError(strictErrorMessage, name, ScriptRuntime.safeToString(this));
  28.140 +        if (NashornCallSiteDescriptor.isStrict(desc)) {
  28.141 +            throw typeError(strictErrorMessage, name, ScriptRuntime.safeToString(this));
  28.142          }
  28.143          assert canBeFastScope || !NashornCallSiteDescriptor.isFastScope(desc);
  28.144          return new GuardedInvocation(
  28.145 @@ -2207,7 +2205,7 @@
  28.146      private GuardedInvocation findMegaMorphicSetMethod(final CallSiteDescriptor desc, final String name) {
  28.147          final MethodType        type = desc.getMethodType().insertParameterTypes(1, Object.class);
  28.148          //never bother with ClassCastExceptionGuard for megamorphic callsites
  28.149 -        final GuardedInvocation inv = findSetIndexMethod(getClass(), false, type, NashornCallSiteDescriptor.isStrict(desc));
  28.150 +        final GuardedInvocation inv = findSetIndexMethod(getClass(), desc, false, type);
  28.151          return inv.replaceMethods(MH.insertArguments(inv.getInvocation(), 1, name), inv.getGuard());
  28.152      }
  28.153  
  28.154 @@ -2230,24 +2228,26 @@
  28.155       * @return GuardedInvocation to be invoked at call site.
  28.156       */
  28.157      protected GuardedInvocation findSetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) { // array, index, value
  28.158 -        return findSetIndexMethod(getClass(), explicitInstanceOfCheck(desc, request), desc.getMethodType(), NashornCallSiteDescriptor.isStrict(desc));
  28.159 +        return findSetIndexMethod(getClass(), desc, explicitInstanceOfCheck(desc, request), desc.getMethodType());
  28.160      }
  28.161  
  28.162      /**
  28.163       * Find the appropriate SETINDEX method for an invoke dynamic call.
  28.164       *
  28.165 +     * @param clazz the receiver class
  28.166 +     * @param desc  the call site descriptor
  28.167 +     * @param explicitInstanceOfCheck add an explicit instanceof check?
  28.168       * @param callType the method type at the call site
  28.169 -     * @param isStrict are we in strict mode?
  28.170       *
  28.171       * @return GuardedInvocation to be invoked at call site.
  28.172       */
  28.173 -    private static GuardedInvocation findSetIndexMethod(final Class<? extends ScriptObject> clazz, final boolean explicitInstanceOfCheck, final MethodType callType, final boolean isStrict) {
  28.174 +    private static GuardedInvocation findSetIndexMethod(final Class<? extends ScriptObject> clazz, final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final MethodType callType) {
  28.175          assert callType.parameterCount() == 3;
  28.176          final Class<?> keyClass   = callType.parameterType(1);
  28.177          final Class<?> valueClass = callType.parameterType(2);
  28.178  
  28.179 -        MethodHandle methodHandle = findOwnMH_V(clazz, "set", void.class, keyClass, valueClass, boolean.class);
  28.180 -        methodHandle = MH.insertArguments(methodHandle, 3, isStrict);
  28.181 +        MethodHandle methodHandle = findOwnMH_V(clazz, "set", void.class, keyClass, valueClass, int.class);
  28.182 +        methodHandle = MH.insertArguments(methodHandle, 3, NashornCallSiteDescriptor.getFlags(desc));
  28.183  
  28.184          return new GuardedInvocation(methodHandle, getScriptObjectGuard(callType, explicitInstanceOfCheck), (SwitchPoint)null, explicitInstanceOfCheck ? null : ClassCastException.class);
  28.185      }
  28.186 @@ -2672,7 +2672,7 @@
  28.187          if (isValidArrayIndex(index)) {
  28.188              for (ScriptObject object = this; ; ) {
  28.189                  if (object.getMap().containsArrayKeys()) {
  28.190 -                    final FindProperty find = object.findProperty(key, false, false, this);
  28.191 +                    final FindProperty find = object.findProperty(key, false, this);
  28.192  
  28.193                      if (find != null) {
  28.194                          return getIntValue(find, programPoint);
  28.195 @@ -2755,7 +2755,7 @@
  28.196          if (isValidArrayIndex(index)) {
  28.197              for (ScriptObject object = this; ; ) {
  28.198                  if (object.getMap().containsArrayKeys()) {
  28.199 -                    final FindProperty find = object.findProperty(key, false, false, this);
  28.200 +                    final FindProperty find = object.findProperty(key, false, this);
  28.201                      if (find != null) {
  28.202                          return getLongValue(find, programPoint);
  28.203                      }
  28.204 @@ -2837,7 +2837,7 @@
  28.205          if (isValidArrayIndex(index)) {
  28.206              for (ScriptObject object = this; ; ) {
  28.207                  if (object.getMap().containsArrayKeys()) {
  28.208 -                    final FindProperty find = object.findProperty(key, false, false, this);
  28.209 +                    final FindProperty find = object.findProperty(key, false, this);
  28.210                      if (find != null) {
  28.211                          return getDoubleValue(find, programPoint);
  28.212                      }
  28.213 @@ -2919,7 +2919,7 @@
  28.214          if (isValidArrayIndex(index)) {
  28.215              for (ScriptObject object = this; ; ) {
  28.216                  if (object.getMap().containsArrayKeys()) {
  28.217 -                    final FindProperty find = object.findProperty(key, false, false, this);
  28.218 +                    final FindProperty find = object.findProperty(key, false, this);
  28.219  
  28.220                      if (find != null) {
  28.221                          return find.getObjectValue();
  28.222 @@ -2996,48 +2996,48 @@
  28.223          return get(index, JSType.toString(key));
  28.224      }
  28.225  
  28.226 -    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final int value, final boolean strict) {
  28.227 +    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final int value, final int callSiteFlags) {
  28.228          if (getMap().containsArrayKeys()) {
  28.229              final String       key  = JSType.toString(longIndex);
  28.230              final FindProperty find = findProperty(key, true);
  28.231              if (find != null) {
  28.232 -                setObject(find, strict, key, value);
  28.233 +                setObject(find, callSiteFlags, key, value);
  28.234                  return true;
  28.235              }
  28.236          }
  28.237          return false;
  28.238      }
  28.239  
  28.240 -    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final long value, final boolean strict) {
  28.241 +    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final long value, final int callSiteFlags) {
  28.242          if (getMap().containsArrayKeys()) {
  28.243              final String       key  = JSType.toString(longIndex);
  28.244              final FindProperty find = findProperty(key, true);
  28.245              if (find != null) {
  28.246 -                setObject(find, strict, key, value);
  28.247 +                setObject(find, callSiteFlags, key, value);
  28.248                  return true;
  28.249              }
  28.250          }
  28.251          return false;
  28.252      }
  28.253  
  28.254 -    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final double value, final boolean strict) {
  28.255 +    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final double value, final int callSiteFlags) {
  28.256           if (getMap().containsArrayKeys()) {
  28.257              final String       key  = JSType.toString(longIndex);
  28.258              final FindProperty find = findProperty(key, true);
  28.259              if (find != null) {
  28.260 -                setObject(find, strict, key, value);
  28.261 +                setObject(find, callSiteFlags, key, value);
  28.262                  return true;
  28.263              }
  28.264          }
  28.265          return false;
  28.266      }
  28.267  
  28.268 -    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final Object value, final boolean strict) {
  28.269 +    private boolean doesNotHaveCheckArrayKeys(final long longIndex, final Object value, final int callSiteFlags) {
  28.270          if (getMap().containsArrayKeys()) {
  28.271              final String       key  = JSType.toString(longIndex);
  28.272              final FindProperty find = findProperty(key, true);
  28.273              if (find != null) {
  28.274 -                setObject(find, strict, key, value);
  28.275 +                setObject(find, callSiteFlags, key, value);
  28.276                  return true;
  28.277              }
  28.278          }
  28.279 @@ -3045,10 +3045,10 @@
  28.280      }
  28.281  
  28.282      //value agnostic
  28.283 -    private boolean doesNotHaveEnsureLength(final long longIndex, final long oldLength, final boolean strict) {
  28.284 +    private boolean doesNotHaveEnsureLength(final long longIndex, final long oldLength, final int callSiteFlags) {
  28.285          if (longIndex >= oldLength) {
  28.286              if (!isExtensible()) {
  28.287 -                if (strict) {
  28.288 +                if (NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)) {
  28.289                      throw typeError("object.non.extensible", JSType.toString(longIndex), ScriptRuntime.safeToString(this));
  28.290                  }
  28.291                  return true;
  28.292 @@ -3068,37 +3068,41 @@
  28.293          }
  28.294      }
  28.295  
  28.296 -    private void doesNotHave(final int index, final int value, final boolean strict) {
  28.297 +    private void doesNotHave(final int index, final int value, final int callSiteFlags) {
  28.298          final long oldLength = getArray().length();
  28.299          final long longIndex = ArrayIndex.toLongIndex(index);
  28.300 -        if (!doesNotHaveCheckArrayKeys(longIndex, value, strict) && !doesNotHaveEnsureLength(longIndex, oldLength, strict)) {
  28.301 +        if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
  28.302 +            final boolean strict = NashornCallSiteDescriptor.isStrictFlag(callSiteFlags);
  28.303              setArray(getArray().set(index, value, strict));
  28.304              doesNotHaveEnsureDelete(longIndex, oldLength, strict);
  28.305          }
  28.306      }
  28.307  
  28.308 -    private void doesNotHave(final int index, final long value, final boolean strict) {
  28.309 +    private void doesNotHave(final int index, final long value, final int callSiteFlags) {
  28.310          final long oldLength = getArray().length();
  28.311          final long longIndex = ArrayIndex.toLongIndex(index);
  28.312 -        if (!doesNotHaveCheckArrayKeys(longIndex, value, strict) && !doesNotHaveEnsureLength(longIndex, oldLength, strict)) {
  28.313 +        if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
  28.314 +            final boolean strict = NashornCallSiteDescriptor.isStrictFlag(callSiteFlags);
  28.315              setArray(getArray().set(index, value, strict));
  28.316              doesNotHaveEnsureDelete(longIndex, oldLength, strict);
  28.317          }
  28.318      }
  28.319  
  28.320 -    private void doesNotHave(final int index, final double value, final boolean strict) {
  28.321 +    private void doesNotHave(final int index, final double value, final int callSiteFlags) {
  28.322          final long oldLength = getArray().length();
  28.323          final long longIndex = ArrayIndex.toLongIndex(index);
  28.324 -        if (!doesNotHaveCheckArrayKeys(longIndex, value, strict) && !doesNotHaveEnsureLength(longIndex, oldLength, strict)) {
  28.325 +        if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
  28.326 +            final boolean strict = NashornCallSiteDescriptor.isStrictFlag(callSiteFlags);
  28.327              setArray(getArray().set(index, value, strict));
  28.328              doesNotHaveEnsureDelete(longIndex, oldLength, strict);
  28.329          }
  28.330      }
  28.331  
  28.332 -    private void doesNotHave(final int index, final Object value, final boolean strict) {
  28.333 +    private void doesNotHave(final int index, final Object value, final int callSiteFlags) {
  28.334          final long oldLength = getArray().length();
  28.335          final long longIndex = ArrayIndex.toLongIndex(index);
  28.336 -        if (!doesNotHaveCheckArrayKeys(longIndex, value, strict) && !doesNotHaveEnsureLength(longIndex, oldLength, strict)) {
  28.337 +        if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
  28.338 +            final boolean strict = NashornCallSiteDescriptor.isStrictFlag(callSiteFlags);
  28.339              setArray(getArray().set(index, value, strict));
  28.340              doesNotHaveEnsureDelete(longIndex, oldLength, strict);
  28.341          }
  28.342 @@ -3108,32 +3112,47 @@
  28.343       * This is the most generic of all Object setters. Most of the others use this in some form.
  28.344       * TODO: should be further specialized
  28.345       *
  28.346 -     * @param find    found property
  28.347 -     * @param strict  are we in strict mode
  28.348 -     * @param key     property key
  28.349 -     * @param value   property value
  28.350 +     * @param find          found property
  28.351 +     * @param callSiteFlags callsite flags
  28.352 +     * @param key           property key
  28.353 +     * @param value         property value
  28.354       */
  28.355 -    public final void setObject(final FindProperty find, final boolean strict, final String key, final Object value) {
  28.356 +    public final void setObject(final FindProperty find, final int callSiteFlags, final String key, final Object value) {
  28.357          FindProperty f = find;
  28.358  
  28.359 -        if (f != null && f.isInherited() && !(f.getProperty() instanceof UserAccessorProperty) && !isScope()) {
  28.360 -            // Setting a property should not modify the property in prototype unless this is a scope object.
  28.361 -            f = null;
  28.362 +        if (f != null && f.isInherited() && !(f.getProperty() instanceof UserAccessorProperty)) {
  28.363 +            final boolean isScope = NashornCallSiteDescriptor.isScopeFlag(callSiteFlags);
  28.364 +            // If the start object of the find is not this object it means the property was found inside a
  28.365 +            // 'with' statement expression (see WithObject.findProperty()). In this case we forward the 'set'
  28.366 +            // to the 'with' object.
  28.367 +            // Note that although a 'set' operation involving a with statement follows scope rules outside
  28.368 +            // the 'with' expression (the 'set' operation is performed on the owning prototype if it exists),
  28.369 +            // it follows non-scope rules inside the 'with' expression (set is performed on the top level object).
  28.370 +            // This is why we clear the callsite flags and FindProperty in the forward call to the 'with' object.
  28.371 +            if (isScope && f.getSelf() != this) {
  28.372 +                f.getSelf().setObject(null, 0, key, value);
  28.373 +                return;
  28.374 +            }
  28.375 +            // Setting a property should not modify the property in prototype unless this is a scope callsite
  28.376 +            // and the owner is a scope object as well (with the exception of 'with' statement handled above).
  28.377 +            if (!isScope || !f.getOwner().isScope()) {
  28.378 +                f = null;
  28.379 +            }
  28.380          }
  28.381  
  28.382          if (f != null) {
  28.383              if (!f.getProperty().isWritable()) {
  28.384 -                if (strict) {
  28.385 +                if (NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)) {
  28.386                      throw typeError("property.not.writable", key, ScriptRuntime.safeToString(this));
  28.387                  }
  28.388  
  28.389                  return;
  28.390              }
  28.391  
  28.392 -            f.setValue(value, strict);
  28.393 +            f.setValue(value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags));
  28.394  
  28.395          } else if (!isExtensible()) {
  28.396 -            if (strict) {
  28.397 +            if (NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)) {
  28.398                  throw typeError("object.non.extensible", key, ScriptRuntime.safeToString(this));
  28.399              }
  28.400          } else {
  28.401 @@ -3153,293 +3172,293 @@
  28.402      }
  28.403  
  28.404      @Override
  28.405 -    public void set(final Object key, final int value, final boolean strict) {
  28.406 +    public void set(final Object key, final int value, final int callSiteFlags) {
  28.407          final Object primitiveKey = JSType.toPrimitive(key, String.class);
  28.408          final int    index        = getArrayIndex(primitiveKey);
  28.409  
  28.410          if (isValidArrayIndex(index)) {
  28.411              if (getArray().has(index)) {
  28.412 -                setArray(getArray().set(index, value, strict));
  28.413 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.414              } else {
  28.415 -                doesNotHave(index, value, strict);
  28.416 +                doesNotHave(index, value, callSiteFlags);
  28.417              }
  28.418  
  28.419              return;
  28.420          }
  28.421  
  28.422          final String propName = JSType.toString(primitiveKey);
  28.423 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.424 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.425      }
  28.426  
  28.427      @Override
  28.428 -    public void set(final Object key, final long value, final boolean strict) {
  28.429 +    public void set(final Object key, final long value, final int callSiteFlags) {
  28.430          final Object primitiveKey = JSType.toPrimitive(key, String.class);
  28.431          final int    index        = getArrayIndex(primitiveKey);
  28.432  
  28.433          if (isValidArrayIndex(index)) {
  28.434              if (getArray().has(index)) {
  28.435 -                setArray(getArray().set(index, value, strict));
  28.436 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.437              } else {
  28.438 -                doesNotHave(index, value, strict);
  28.439 +                doesNotHave(index, value, callSiteFlags);
  28.440              }
  28.441  
  28.442              return;
  28.443          }
  28.444  
  28.445          final String propName = JSType.toString(primitiveKey);
  28.446 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.447 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.448      }
  28.449  
  28.450      @Override
  28.451 -    public void set(final Object key, final double value, final boolean strict) {
  28.452 +    public void set(final Object key, final double value, final int callSiteFlags) {
  28.453          final Object primitiveKey = JSType.toPrimitive(key, String.class);
  28.454          final int    index        = getArrayIndex(primitiveKey);
  28.455  
  28.456          if (isValidArrayIndex(index)) {
  28.457              if (getArray().has(index)) {
  28.458 -                setArray(getArray().set(index, value, strict));
  28.459 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.460              } else {
  28.461 -                doesNotHave(index, value, strict);
  28.462 +                doesNotHave(index, value, callSiteFlags);
  28.463              }
  28.464  
  28.465              return;
  28.466          }
  28.467  
  28.468          final String propName = JSType.toString(primitiveKey);
  28.469 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.470 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.471      }
  28.472  
  28.473      @Override
  28.474 -    public void set(final Object key, final Object value, final boolean strict) {
  28.475 +    public void set(final Object key, final Object value, final int callSiteFlags) {
  28.476          final Object primitiveKey = JSType.toPrimitive(key, String.class);
  28.477          final int    index        = getArrayIndex(primitiveKey);
  28.478  
  28.479          if (isValidArrayIndex(index)) {
  28.480              if (getArray().has(index)) {
  28.481 -                setArray(getArray().set(index, value, strict));
  28.482 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.483              } else {
  28.484 -                doesNotHave(index, value, strict);
  28.485 +                doesNotHave(index, value, callSiteFlags);
  28.486              }
  28.487  
  28.488              return;
  28.489          }
  28.490  
  28.491          final String propName = JSType.toString(primitiveKey);
  28.492 -        setObject(findProperty(propName, true), strict, propName, value);
  28.493 +        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  28.494      }
  28.495  
  28.496      @Override
  28.497 -    public void set(final double key, final int value, final boolean strict) {
  28.498 +    public void set(final double key, final int value, final int callSiteFlags) {
  28.499          final int index = getArrayIndex(key);
  28.500  
  28.501          if (isValidArrayIndex(index)) {
  28.502              if (getArray().has(index)) {
  28.503 -                setArray(getArray().set(index, value, strict));
  28.504 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.505              } else {
  28.506 -                doesNotHave(index, value, strict);
  28.507 +                doesNotHave(index, value, callSiteFlags);
  28.508              }
  28.509  
  28.510              return;
  28.511          }
  28.512  
  28.513          final String propName = JSType.toString(key);
  28.514 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.515 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.516      }
  28.517  
  28.518      @Override
  28.519 -    public void set(final double key, final long value, final boolean strict) {
  28.520 +    public void set(final double key, final long value, final int callSiteFlags) {
  28.521          final int index = getArrayIndex(key);
  28.522  
  28.523          if (isValidArrayIndex(index)) {
  28.524              if (getArray().has(index)) {
  28.525 -                setArray(getArray().set(index, value, strict));
  28.526 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.527              } else {
  28.528 -                doesNotHave(index, value, strict);
  28.529 +                doesNotHave(index, value, callSiteFlags);
  28.530              }
  28.531  
  28.532              return;
  28.533          }
  28.534  
  28.535          final String propName = JSType.toString(key);
  28.536 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.537 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.538      }
  28.539  
  28.540      @Override
  28.541 -    public void set(final double key, final double value, final boolean strict) {
  28.542 +    public void set(final double key, final double value, final int callSiteFlags) {
  28.543          final int index = getArrayIndex(key);
  28.544  
  28.545          if (isValidArrayIndex(index)) {
  28.546              if (getArray().has(index)) {
  28.547 -                setArray(getArray().set(index, value, strict));
  28.548 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.549              } else {
  28.550 -                doesNotHave(index, value, strict);
  28.551 +                doesNotHave(index, value, callSiteFlags);
  28.552              }
  28.553  
  28.554              return;
  28.555          }
  28.556  
  28.557          final String propName = JSType.toString(key);
  28.558 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.559 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.560      }
  28.561  
  28.562      @Override
  28.563 -    public void set(final double key, final Object value, final boolean strict) {
  28.564 +    public void set(final double key, final Object value, final int callSiteFlags) {
  28.565          final int index = getArrayIndex(key);
  28.566  
  28.567          if (isValidArrayIndex(index)) {
  28.568              if (getArray().has(index)) {
  28.569 -                setArray(getArray().set(index, value, strict));
  28.570 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.571              } else {
  28.572 -                doesNotHave(index, value, strict);
  28.573 +                doesNotHave(index, value, callSiteFlags);
  28.574              }
  28.575  
  28.576              return;
  28.577          }
  28.578  
  28.579          final String propName = JSType.toString(key);
  28.580 -        setObject(findProperty(propName, true), strict, propName, value);
  28.581 +        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  28.582      }
  28.583  
  28.584      @Override
  28.585 -    public void set(final long key, final int value, final boolean strict) {
  28.586 +    public void set(final long key, final int value, final int callSiteFlags) {
  28.587          final int index = getArrayIndex(key);
  28.588  
  28.589          if (isValidArrayIndex(index)) {
  28.590              if (getArray().has(index)) {
  28.591 -                setArray(getArray().set(index, value, strict));
  28.592 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.593              } else {
  28.594 -                doesNotHave(index, value, strict);
  28.595 +                doesNotHave(index, value, callSiteFlags);
  28.596              }
  28.597  
  28.598              return;
  28.599          }
  28.600  
  28.601          final String propName = JSType.toString(key);
  28.602 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.603 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.604      }
  28.605  
  28.606      @Override
  28.607 -    public void set(final long key, final long value, final boolean strict) {
  28.608 +    public void set(final long key, final long value, final int callSiteFlags) {
  28.609          final int index = getArrayIndex(key);
  28.610  
  28.611          if (isValidArrayIndex(index)) {
  28.612              if (getArray().has(index)) {
  28.613 -                setArray(getArray().set(index, value, strict));
  28.614 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.615              } else {
  28.616 -                doesNotHave(index, value, strict);
  28.617 +                doesNotHave(index, value, callSiteFlags);
  28.618              }
  28.619  
  28.620              return;
  28.621          }
  28.622  
  28.623          final String propName = JSType.toString(key);
  28.624 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.625 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.626      }
  28.627  
  28.628      @Override
  28.629 -    public void set(final long key, final double value, final boolean strict) {
  28.630 +    public void set(final long key, final double value, final int callSiteFlags) {
  28.631          final int index = getArrayIndex(key);
  28.632  
  28.633          if (isValidArrayIndex(index)) {
  28.634              if (getArray().has(index)) {
  28.635 -                setArray(getArray().set(index, value, strict));
  28.636 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.637              } else {
  28.638 -                doesNotHave(index, value, strict);
  28.639 +                doesNotHave(index, value, callSiteFlags);
  28.640              }
  28.641  
  28.642              return;
  28.643          }
  28.644  
  28.645          final String propName = JSType.toString(key);
  28.646 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.647 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.648      }
  28.649  
  28.650      @Override
  28.651 -    public void set(final long key, final Object value, final boolean strict) {
  28.652 +    public void set(final long key, final Object value, final int callSiteFlags) {
  28.653          final int index = getArrayIndex(key);
  28.654  
  28.655          if (isValidArrayIndex(index)) {
  28.656              if (getArray().has(index)) {
  28.657 -                setArray(getArray().set(index, value, strict));
  28.658 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.659              } else {
  28.660 -                doesNotHave(index, value, strict);
  28.661 +                doesNotHave(index, value, callSiteFlags);
  28.662              }
  28.663  
  28.664              return;
  28.665          }
  28.666  
  28.667          final String propName = JSType.toString(key);
  28.668 -        setObject(findProperty(propName, true), strict, propName, value);
  28.669 +        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  28.670      }
  28.671  
  28.672      @Override
  28.673 -    public void set(final int key, final int value, final boolean strict) {
  28.674 +    public void set(final int key, final int value, final int callSiteFlags) {
  28.675          final int index = getArrayIndex(key);
  28.676          if (isValidArrayIndex(index)) {
  28.677              if (getArray().has(index)) {
  28.678 -                setArray(getArray().set(index, value, strict));
  28.679 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.680              } else {
  28.681 -                doesNotHave(index, value, strict);
  28.682 +                doesNotHave(index, value, callSiteFlags);
  28.683              }
  28.684              return;
  28.685          }
  28.686  
  28.687          final String propName = JSType.toString(key);
  28.688 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.689 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.690      }
  28.691  
  28.692      @Override
  28.693 -    public void set(final int key, final long value, final boolean strict) {
  28.694 +    public void set(final int key, final long value, final int callSiteFlags) {
  28.695          final int index = getArrayIndex(key);
  28.696  
  28.697          if (isValidArrayIndex(index)) {
  28.698              if (getArray().has(index)) {
  28.699 -                setArray(getArray().set(index, value, strict));
  28.700 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.701              } else {
  28.702 -                doesNotHave(index, value, strict);
  28.703 +                doesNotHave(index, value, callSiteFlags);
  28.704              }
  28.705  
  28.706              return;
  28.707          }
  28.708  
  28.709          final String propName = JSType.toString(key);
  28.710 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.711 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.712      }
  28.713  
  28.714      @Override
  28.715 -    public void set(final int key, final double value, final boolean strict) {
  28.716 +    public void set(final int key, final double value, final int callSiteFlags) {
  28.717          final int index = getArrayIndex(key);
  28.718  
  28.719          if (isValidArrayIndex(index)) {
  28.720              if (getArray().has(index)) {
  28.721 -                setArray(getArray().set(index, value, strict));
  28.722 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.723              } else {
  28.724 -                doesNotHave(index, value, strict);
  28.725 +                doesNotHave(index, value, callSiteFlags);
  28.726              }
  28.727  
  28.728              return;
  28.729          }
  28.730  
  28.731          final String propName = JSType.toString(key);
  28.732 -        setObject(findProperty(propName, true), strict, propName, JSType.toObject(value));
  28.733 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  28.734      }
  28.735  
  28.736      @Override
  28.737 -    public void set(final int key, final Object value, final boolean strict) {
  28.738 +    public void set(final int key, final Object value, final int callSiteFlags) {
  28.739          final int index = getArrayIndex(key);
  28.740  
  28.741          if (isValidArrayIndex(index)) {
  28.742              if (getArray().has(index)) {
  28.743 -                setArray(getArray().set(index, value, strict));
  28.744 +                setArray(getArray().set(index, value, NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)));
  28.745              } else {
  28.746 -                doesNotHave(index, value, strict);
  28.747 +                doesNotHave(index, value, callSiteFlags);
  28.748              }
  28.749  
  28.750              return;
  28.751          }
  28.752  
  28.753          final String propName = JSType.toString(key);
  28.754 -        setObject(findProperty(propName, true), strict, propName, value);
  28.755 +        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  28.756      }
  28.757  
  28.758      @Override
    29.1 --- a/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Wed Sep 24 14:43:37 2014 -0700
    29.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Mon Oct 06 15:53:22 2014 -0700
    29.3 @@ -221,9 +221,9 @@
    29.4          final String err = errBuffer.toString();
    29.5  
    29.6          // Set globals for secondary results.
    29.7 -        global.set(OUT_NAME, out, false);
    29.8 -        global.set(ERR_NAME, err, false);
    29.9 -        global.set(EXIT_NAME, exit, false);
   29.10 +        global.set(OUT_NAME, out, 0);
   29.11 +        global.set(ERR_NAME, err, 0);
   29.12 +        global.set(EXIT_NAME, exit, 0);
   29.13  
   29.14          // Propagate exception if present.
   29.15          for (final IOException element : exception) {
    30.1 --- a/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Wed Sep 24 14:43:37 2014 -0700
    30.2 +++ b/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Mon Oct 06 15:53:22 2014 -0700
    30.3 @@ -205,7 +205,7 @@
    30.4  
    30.5          //slow setter, that calls ScriptObject.set with appropraite type and key name
    30.6          MethodHandle slowSetter = ScriptObject.SET_SLOW[getAccessorTypeIndex(type)];
    30.7 -        slowSetter = MH.insertArguments(slowSetter, 3, NashornCallSiteDescriptor.isStrict(desc));
    30.8 +        slowSetter = MH.insertArguments(slowSetter, 3, NashornCallSiteDescriptor.getFlags(desc));
    30.9          slowSetter = MH.insertArguments(slowSetter, 1, name);
   30.10          slowSetter = MH.asType(slowSetter, slowSetter.type().changeParameterType(0, Object.class));
   30.11  
    31.1 --- a/src/jdk/nashorn/internal/runtime/StoredScript.java	Wed Sep 24 14:43:37 2014 -0700
    31.2 +++ b/src/jdk/nashorn/internal/runtime/StoredScript.java	Mon Oct 06 15:53:22 2014 -0700
    31.3 @@ -27,6 +27,7 @@
    31.4  
    31.5  import java.io.Serializable;
    31.6  import java.util.Arrays;
    31.7 +import java.util.LinkedHashMap;
    31.8  import java.util.Map;
    31.9  
   31.10  /**
   31.11 @@ -83,7 +84,11 @@
   31.12       * @return map of class bytes
   31.13       */
   31.14      public Map<String, byte[]> getClassBytes() {
   31.15 -        return classBytes;
   31.16 +        final Map<String, byte[]> clonedMap = new LinkedHashMap<>();
   31.17 +        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
   31.18 +            clonedMap.put(entry.getKey(), entry.getValue().clone());
   31.19 +        }
   31.20 +        return clonedMap;
   31.21      }
   31.22  
   31.23      /**
   31.24 @@ -91,11 +96,19 @@
   31.25       * @return constants array
   31.26       */
   31.27      public Object[] getConstants() {
   31.28 -        return constants;
   31.29 +        return constants.clone();
   31.30      }
   31.31  
   31.32 -    Map<Integer, FunctionInitializer> getInitializers() {
   31.33 -        return initializers;
   31.34 +    /**
   31.35 +     * Returns the function initializers map.
   31.36 +     * @return The initializers map.
   31.37 +     */
   31.38 +    public Map<Integer, FunctionInitializer> getInitializers() {
   31.39 +        final Map<Integer, FunctionInitializer> clonedMap = new LinkedHashMap<>();
   31.40 +        for (final Map.Entry<Integer, FunctionInitializer> entry : initializers.entrySet()) {
   31.41 +            clonedMap.put(entry.getKey(), new FunctionInitializer(entry.getValue()));
   31.42 +        }
   31.43 +        return clonedMap;
   31.44      }
   31.45  
   31.46      @Override
    32.1 --- a/src/jdk/nashorn/internal/runtime/Undefined.java	Wed Sep 24 14:43:37 2014 -0700
    32.2 +++ b/src/jdk/nashorn/internal/runtime/Undefined.java	Mon Oct 06 15:53:22 2014 -0700
    32.3 @@ -34,6 +34,7 @@
    32.4  import jdk.internal.dynalink.linker.GuardedInvocation;
    32.5  import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
    32.6  import jdk.internal.dynalink.support.Guards;
    32.7 +import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
    32.8  
    32.9  /**
   32.10   * Unique instance of this class is used to represent JavaScript undefined.
   32.11 @@ -128,7 +129,7 @@
   32.12      }
   32.13  
   32.14      private static final MethodHandle GET_METHOD = findOwnMH("get", Object.class, Object.class);
   32.15 -    private static final MethodHandle SET_METHOD = MH.insertArguments(findOwnMH("set", void.class, Object.class, Object.class, boolean.class), 3, Boolean.TRUE);
   32.16 +    private static final MethodHandle SET_METHOD = MH.insertArguments(findOwnMH("set", void.class, Object.class, Object.class, int.class), 3, NashornCallSiteDescriptor.CALLSITE_STRICT);
   32.17  
   32.18      private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) {
   32.19          return new GuardedInvocation(MH.insertArguments(GET_METHOD, 1, desc.getNameToken(2)), UNDEFINED_GUARD).asType(desc);
   32.20 @@ -152,7 +153,7 @@
   32.21      }
   32.22  
   32.23      @Override
   32.24 -    public void set(final Object key, final Object value, final boolean strict) {
   32.25 +    public void set(final Object key, final Object value, final int flags) {
   32.26          throw typeError("cant.set.property.of.undefined", ScriptRuntime.safeToString(key));
   32.27      }
   32.28  
    33.1 --- a/src/jdk/nashorn/internal/runtime/WithObject.java	Wed Sep 24 14:43:37 2014 -0700
    33.2 +++ b/src/jdk/nashorn/internal/runtime/WithObject.java	Mon Oct 06 15:53:22 2014 -0700
    33.3 @@ -193,18 +193,20 @@
    33.4       *
    33.5       * @param key  Property key.
    33.6       * @param deep Whether the search should look up proto chain.
    33.7 -     * @param stopOnNonScope should a deep search stop on the first non-scope object?
    33.8       * @param start the object on which the lookup was originally initiated
    33.9       *
   33.10       * @return FindPropertyData or null if not found.
   33.11       */
   33.12      @Override
   33.13 -    FindProperty findProperty(final String key, final boolean deep, final boolean stopOnNonScope, final ScriptObject start) {
   33.14 -        final FindProperty exprProperty = expression.findProperty(key, deep, stopOnNonScope, start);
   33.15 +    FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
   33.16 +        // We call findProperty on 'expression' with 'expression' itself as start parameter.
   33.17 +        // This way in ScriptObject.setObject we can tell the property is from a 'with' expression
   33.18 +        // (as opposed from another non-scope object in the proto chain such as Object.prototype).
   33.19 +        final FindProperty exprProperty = expression.findProperty(key, true, expression);
   33.20          if (exprProperty != null) {
   33.21               return exprProperty;
   33.22          }
   33.23 -        return super.findProperty(key, deep, stopOnNonScope, start);
   33.24 +        return super.findProperty(key, deep, start);
   33.25      }
   33.26  
   33.27      @Override
    34.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Wed Sep 24 14:43:37 2014 -0700
    34.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Mon Oct 06 15:53:22 2014 -0700
    34.3 @@ -125,6 +125,15 @@
    34.4  
    34.5          @Override
    34.6          public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
    34.7 +            if (sourceType == ConsString.class) {
    34.8 +                if (String.class == targetType1 || CharSequence.class == targetType1) {
    34.9 +                    return Comparison.TYPE_1_BETTER;
   34.10 +                }
   34.11 +
   34.12 +                if (String.class == targetType2 || CharSequence.class == targetType2) {
   34.13 +                    return Comparison.TYPE_2_BETTER;
   34.14 +                }
   34.15 +            }
   34.16              return linkerServices.compareConversion(sourceType, targetType1, targetType2);
   34.17          }
   34.18      }
    35.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Wed Sep 24 14:43:37 2014 -0700
    35.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Mon Oct 06 15:53:22 2014 -0700
    35.3 @@ -131,11 +131,16 @@
    35.4              }
    35.5              return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc);
    35.6          case "setProp":
    35.7 -        case "setElem":
    35.8 +        case "setElem": {
    35.9 +            final boolean strict = NashornCallSiteDescriptor.isStrict(desc);
   35.10 +            if (strict) {
   35.11 +                throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self));
   35.12 +            }
   35.13              if (desc.getOperand() != null) {
   35.14                  return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc);
   35.15              }
   35.16              return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc);
   35.17 +        }
   35.18          default:
   35.19              break;
   35.20          }
    36.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java	Wed Sep 24 14:43:37 2014 -0700
    36.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java	Mon Oct 06 15:53:22 2014 -0700
    36.3 @@ -255,7 +255,7 @@
    36.4       * @return the Nashorn-specific flags for the call site, or 0 if the passed descriptor is not a Nashorn call site
    36.5       * descriptor.
    36.6       */
    36.7 -    private static int getFlags(final CallSiteDescriptor desc) {
    36.8 +    public static int getFlags(final CallSiteDescriptor desc) {
    36.9          return desc instanceof NashornCallSiteDescriptor ? ((NashornCallSiteDescriptor)desc).flags : 0;
   36.10      }
   36.11  
   36.12 @@ -343,6 +343,24 @@
   36.13      }
   36.14  
   36.15      /**
   36.16 +     * Returns true if {@code flags} has the {@link  #CALLSITE_STRICT} bit set.
   36.17 +     * @param flags the flags
   36.18 +     * @return true if the flag is set, false otherwise.
   36.19 +     */
   36.20 +    public static boolean isStrictFlag(final int flags) {
   36.21 +        return (flags & CALLSITE_STRICT) != 0;
   36.22 +    }
   36.23 +
   36.24 +    /**
   36.25 +     * Returns true if {@code flags} has the {@link  #CALLSITE_SCOPE} bit set.
   36.26 +     * @param flags the flags
   36.27 +     * @return true if the flag is set, false otherwise.
   36.28 +     */
   36.29 +    public static boolean isScopeFlag(final int flags) {
   36.30 +        return (flags & CALLSITE_SCOPE) != 0;
   36.31 +    }
   36.32 +
   36.33 +    /**
   36.34       * Get a program point from a descriptor (must be optimistic)
   36.35       * @param desc descriptor
   36.36       * @return program point
    37.1 --- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Wed Sep 24 14:43:37 2014 -0700
    37.2 +++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Mon Oct 06 15:53:22 2014 -0700
    37.3 @@ -92,7 +92,7 @@
    37.4  
    37.5  # other wrong usages of property
    37.6  type.error.property.has.no.setter=Cannot set property "{0}" of {1} that has only a getter
    37.7 -type.error.cant.set.proto.to.non.object=Cannot set Object {0}'s __proto__ to be a non-object like {1}
    37.8 +type.error.cant.set.proto.to.non.object=Cannot set Object {0}''s __proto__ to be a non-object like {1}
    37.9  type.error.no.such.function={1} has no such function "{0}"
   37.10  type.error.no.such.java.class=No such Java class: {0}
   37.11  type.error.no.such.java.constructor=No such Java constructor: {0}
   37.12 @@ -125,10 +125,10 @@
   37.13  type.error.cant.load.script=Cannot load script from {0}
   37.14  type.error.JSON.stringify.cyclic=JSON.stringify got a cyclic data structure
   37.15  type.error.cant.convert.string.to.char=Cannot convert string to character; its length must be exactly 1
   37.16 -type.error.cant.convert.number.to.char=Cannot convert number to character; it's out of 0-65535 range
   37.17 +type.error.cant.convert.number.to.char=Cannot convert number to character; it is out of 0-65535 range
   37.18  type.error.cant.convert.to.java.string=Cannot convert object of type {0} to a Java argument of string type
   37.19  type.error.cant.convert.to.java.number=Cannot convert object of type {0} to a Java argument of number type
   37.20 -type.error.cant.convert.to.javascript.array=Can only convert Java arrays and lists to JavaScript arrays. Can't convert object of type {0}.
   37.21 +type.error.cant.convert.to.javascript.array=Can only convert Java arrays and lists to JavaScript arrays. Cannot convert object of type {0}.
   37.22  type.error.extend.expects.at.least.one.argument=Java.extend needs at least one argument.
   37.23  type.error.extend.expects.at.least.one.type.argument=Java.extend needs at least one type argument.
   37.24  type.error.extend.expects.java.types=Java.extend needs Java types as its arguments.
   37.25 @@ -141,10 +141,10 @@
   37.26  type.error.extend.ERROR_FINAL_FINALIZER=Can not extend class because {0} has a final finalize method.
   37.27  type.error.no.constructor.matches.args=Can not construct {0} with the passed arguments; they do not match any of its constructor signatures.
   37.28  type.error.no.method.matches.args=Can not invoke method {0} with the passed arguments; they do not match any of its method signatures.
   37.29 -type.error.method.not.constructor=Java method {0} can't be used as a constructor.
   37.30 +type.error.method.not.constructor=Java method {0} cannot be used as a constructor.
   37.31  type.error.env.not.object=$ENV must be an Object.
   37.32  type.error.unsupported.java.to.type=Unsupported Java.to target type {0}.
   37.33 -type.error.constructor.requires.new=Constructor {0} requires 'new'.
   37.34 +type.error.constructor.requires.new=Constructor {0} requires "new".
   37.35  type.error.new.on.nonpublic.javatype=new cannot be used with non-public java type {0}.
   37.36  
   37.37  range.error.dataview.constructor.offset=Wrong offset or length in DataView constructor
    38.1 --- a/test/script/basic/JDK-8043232.js.EXPECTED	Wed Sep 24 14:43:37 2014 -0700
    38.2 +++ b/test/script/basic/JDK-8043232.js.EXPECTED	Mon Oct 06 15:53:22 2014 -0700
    38.3 @@ -6,9 +6,9 @@
    38.4  TypeError: Java constructor signature invalid: Object()xxxxx
    38.5  TypeError: Java constructor signature invalid: Object(
    38.6  TypeError: Java constructor signature invalid: Object)
    38.7 -TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.lang.System.getProperty] cant be used as a constructor.
    38.8 -TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.io.PrintStream.println] cant be used as a constructor.
    38.9 -TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] requires new.
   38.10 +TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.lang.System.getProperty] cannot be used as a constructor.
   38.11 +TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.io.PrintStream.println] cannot be used as a constructor.
   38.12 +TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] requires "new".
   38.13  TypeError: No such Java constructor: Runnable()
   38.14  TypeError: No such Java constructor: Runnable(int)
   38.15  java.lang.InstantiationException: java.io.InputStream
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/script/basic/JDK-8047764-strict.js	Mon Oct 06 15:53:22 2014 -0700
    39.3 @@ -0,0 +1,69 @@
    39.4 +/*
    39.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 + * 
    39.8 + * This code is free software; you can redistribute it and/or modify it
    39.9 + * under the terms of the GNU General Public License version 2 only, as
   39.10 + * published by the Free Software Foundation.
   39.11 + * 
   39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.15 + * version 2 for more details (a copy is included in the LICENSE file that
   39.16 + * accompanied this code).
   39.17 + * 
   39.18 + * You should have received a copy of the GNU General Public License version
   39.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.21 + * 
   39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.23 + * or visit www.oracle.com if you need additional information or have any
   39.24 + * questions.
   39.25 + */
   39.26 +
   39.27 +/**
   39.28 + * JDK-8047764: Indexed or polymorphic set on global affects Object.prototype
   39.29 + *
   39.30 + * @test
   39.31 + * @run
   39.32 + */
   39.33 +
   39.34 +// Same as JDK-8047764.js but running in strict mode
   39.35 +"use strict";
   39.36 +
   39.37 +// Test global set operation on properties defined in Object.prototype
   39.38 +
   39.39 +Object.defineProperty(Object.prototype, "prop1", { get: function() { return 1; }, set: function(v) { print("setting prop1: " + v); }});
   39.40 +Object.defineProperty(Object.prototype, "prop2", { value: 1, writable: false, configurable: false });
   39.41 +
   39.42 +try {
   39.43 +    prop1 = 1;
   39.44 +    print("prop 1: " + prop2);
   39.45 +} catch (e) {
   39.46 +    print(e.name);
   39.47 +}
   39.48 +
   39.49 +try {
   39.50 +    prop2 = 2;
   39.51 +    print("prop 2: " + prop2);
   39.52 +} catch (e) {
   39.53 +    print(e.name);
   39.54 +}
   39.55 +
   39.56 +// Make sure various ways of setting global toString don't affect Object.prototype.toString
   39.57 +
   39.58 +function checkToString() {
   39.59 +    print(global);
   39.60 +    print(Object.prototype);
   39.61 +    print(global.toString === Object.prototype.toString);
   39.62 +    print(objProtoToString === Object.prototype.toString);
   39.63 +}
   39.64 +
   39.65 +var global = this;
   39.66 +var objProtoToString = Object.prototype.toString;
   39.67 +global["toString"] = function() { return "global toString 1"; };
   39.68 +checkToString();
   39.69 +global.toString = function() { return "global toString 2"; };
   39.70 +checkToString();
   39.71 +toString = function() { return "global toString 3"; };
   39.72 +checkToString();
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/script/basic/JDK-8047764-strict.js.EXPECTED	Mon Oct 06 15:53:22 2014 -0700
    40.3 @@ -0,0 +1,15 @@
    40.4 +setting prop1: 1
    40.5 +prop 1: 1
    40.6 +TypeError
    40.7 +global toString 1
    40.8 +[object Object]
    40.9 +false
   40.10 +true
   40.11 +global toString 2
   40.12 +[object Object]
   40.13 +false
   40.14 +true
   40.15 +global toString 3
   40.16 +[object Object]
   40.17 +false
   40.18 +true
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/script/basic/JDK-8047764.js	Mon Oct 06 15:53:22 2014 -0700
    41.3 @@ -0,0 +1,94 @@
    41.4 +/*
    41.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 + * 
    41.8 + * This code is free software; you can redistribute it and/or modify it
    41.9 + * under the terms of the GNU General Public License version 2 only, as
   41.10 + * published by the Free Software Foundation.
   41.11 + * 
   41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.15 + * version 2 for more details (a copy is included in the LICENSE file that
   41.16 + * accompanied this code).
   41.17 + * 
   41.18 + * You should have received a copy of the GNU General Public License version
   41.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.21 + * 
   41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   41.23 + * or visit www.oracle.com if you need additional information or have any
   41.24 + * questions.
   41.25 + */
   41.26 +
   41.27 +/**
   41.28 + * JDK-8047764: Indexed or polymorphic set on global affects Object.prototype
   41.29 + *
   41.30 + * @test
   41.31 + * @run
   41.32 + */
   41.33 +
   41.34 +// Test global set operation on properties defined in Object.prototype
   41.35 +
   41.36 +Object.defineProperty(Object.prototype, "prop1", { get: function() { return 1; }, set: function(v) { print("setting prop1: " + v); }});
   41.37 +Object.defineProperty(Object.prototype, "prop2", { value: 1, writable: false, configurable: false });
   41.38 +
   41.39 +try {
   41.40 +    prop1 = 1;
   41.41 +    print("prop 1: " + prop2);
   41.42 +} catch (e) {
   41.43 +    print(e.name);
   41.44 +}
   41.45 +
   41.46 +try {
   41.47 +    prop2 = 2;
   41.48 +    print("prop 2: " + prop2);
   41.49 +} catch (e) {
   41.50 +    print(e.name);
   41.51 +}
   41.52 +
   41.53 +// Make sure various ways of setting global toString don't affect Object.prototype.toString
   41.54 +
   41.55 +function checkToString() {
   41.56 +    print(global);
   41.57 +    print(Object.prototype);
   41.58 +    print(global.toString === Object.prototype.toString);
   41.59 +    print(objProtoToString === Object.prototype.toString);
   41.60 +}
   41.61 +
   41.62 +var global = this;
   41.63 +var objProtoToString = Object.prototype.toString;
   41.64 +global["toString"] = function() { return "global toString 1"; };
   41.65 +checkToString();
   41.66 +global.toString = function() { return "global toString 2"; };
   41.67 +checkToString();
   41.68 +toString = function() { return "global toString 3"; };
   41.69 +checkToString();
   41.70 +
   41.71 +// Test setters on 'with' object
   41.72 +
   41.73 +var p = { prop3: 3, toString: function() { return "[object p]"; }};
   41.74 +Object.defineProperty(p, "prop4", { get: function() { print("get", this); return 4; }, set: function(v) { print("set", this, v); }});
   41.75 +var o = Object.create(p);
   41.76 +o.toString = function() { return "[object o]"; };
   41.77 +
   41.78 +with(o) {
   41.79 +    (function() {
   41.80 +        var m = 5;
   41.81 +        (function() {
   41.82 +            print(prop3);
   41.83 +            prop3 = m;
   41.84 +            print(prop3);
   41.85 +            print(prop4);
   41.86 +            prop4 = m;
   41.87 +            print(prop4);
   41.88 +        })();
   41.89 +    })();
   41.90 +}
   41.91 +
   41.92 +print(o.hasOwnProperty("prop3"));
   41.93 +print(o.prop3);
   41.94 +print(p.prop3);
   41.95 +print(o.hasOwnProperty("prop4"));
   41.96 +print(o.prop4);
   41.97 +print(p.prop4);
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/test/script/basic/JDK-8047764.js.EXPECTED	Mon Oct 06 15:53:22 2014 -0700
    42.3 @@ -0,0 +1,30 @@
    42.4 +setting prop1: 1
    42.5 +prop 1: 1
    42.6 +prop 2: 1
    42.7 +global toString 1
    42.8 +[object Object]
    42.9 +false
   42.10 +true
   42.11 +global toString 2
   42.12 +[object Object]
   42.13 +false
   42.14 +true
   42.15 +global toString 3
   42.16 +[object Object]
   42.17 +false
   42.18 +true
   42.19 +3
   42.20 +5
   42.21 +get [object o]
   42.22 +4
   42.23 +set [object o] 5
   42.24 +get [object o]
   42.25 +4
   42.26 +true
   42.27 +5
   42.28 +3
   42.29 +false
   42.30 +get [object o]
   42.31 +4
   42.32 +get [object p]
   42.33 +4
    43.1 --- a/test/script/basic/JDK-8049242.js.EXPECTED	Wed Sep 24 14:43:37 2014 -0700
    43.2 +++ b/test/script/basic/JDK-8049242.js.EXPECTED	Mon Oct 06 15:53:22 2014 -0700
    43.3 @@ -4,7 +4,7 @@
    43.4  TypeError: null is not a function
    43.5  TypeError: null is not a function
    43.6  TypeError: null is not a function
    43.7 -TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] requires new.
    43.8 +TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] requires "new".
    43.9  TypeError: null is not a function
   43.10  TypeError: null is not a function
   43.11  java.lang.InstantiationException: java.io.InputStream
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/test/script/basic/JDK-8056978.js	Mon Oct 06 15:53:22 2014 -0700
    44.3 @@ -0,0 +1,46 @@
    44.4 +/*
    44.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    44.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.7 + * 
    44.8 + * This code is free software; you can redistribute it and/or modify it
    44.9 + * under the terms of the GNU General Public License version 2 only, as
   44.10 + * published by the Free Software Foundation.
   44.11 + * 
   44.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   44.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   44.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   44.15 + * version 2 for more details (a copy is included in the LICENSE file that
   44.16 + * accompanied this code).
   44.17 + * 
   44.18 + * You should have received a copy of the GNU General Public License version
   44.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   44.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   44.21 + * 
   44.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   44.23 + * or visit www.oracle.com if you need additional information or have any
   44.24 + * questions.
   44.25 + */
   44.26 +
   44.27 +/**
   44.28 + * JDK-8056978: ClassCastException: cannot cast jdk.nashorn.internal.scripts.JO*
   44.29 + *
   44.30 + * @test
   44.31 + * @run
   44.32 + */
   44.33 +
   44.34 +var obj1 = {
   44.35 +    'name': 'test name',
   44.36 +    '1': '1',
   44.37 +    '2': '2',
   44.38 +    '3': '3',
   44.39 +    '4': '4',
   44.40 +    '5': '5'
   44.41 +};
   44.42 +
   44.43 +var obj2 = {
   44.44 +    'name': 'hello'
   44.45 +};
   44.46 +
   44.47 +print(obj2['name']);
   44.48 +print(obj2.name);
   44.49 +
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/test/script/basic/JDK-8056978.js.EXPECTED	Mon Oct 06 15:53:22 2014 -0700
    45.3 @@ -0,0 +1,2 @@
    45.4 +hello
    45.5 +hello
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/test/script/basic/JDK-8058422.js	Mon Oct 06 15:53:22 2014 -0700
    46.3 @@ -0,0 +1,55 @@
    46.4 +/*
    46.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.7 + * 
    46.8 + * This code is free software; you can redistribute it and/or modify it
    46.9 + * under the terms of the GNU General Public License version 2 only, as
   46.10 + * published by the Free Software Foundation.
   46.11 + * 
   46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   46.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   46.15 + * version 2 for more details (a copy is included in the LICENSE file that
   46.16 + * accompanied this code).
   46.17 + * 
   46.18 + * You should have received a copy of the GNU General Public License version
   46.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   46.21 + * 
   46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   46.23 + * or visit www.oracle.com if you need additional information or have any
   46.24 + * questions.
   46.25 + */
   46.26 +
   46.27 +/**
   46.28 + * JDK-8058422: Users should be able to overwrite "context" and "engine" variables
   46.29 + *
   46.30 + * @test
   46.31 + * @run
   46.32 + */
   46.33 +
   46.34 +var m = new javax.script.ScriptEngineManager();
   46.35 +var e = m.getEngineByName("nashorn");
   46.36 +e.put("foo", "hello");
   46.37 +var obj = e.eval("context.getAttribute('foo')");
   46.38 +if (obj != "hello") {
   46.39 +    fail("Expected 'obj' to be 'hello'");
   46.40 +}
   46.41 +
   46.42 +e.put("context", "bar");
   46.43 +if (e.eval("context") != "bar") {
   46.44 +    fail("Expected 'context' to be 'bar'");
   46.45 +}
   46.46 +
   46.47 +if (e.eval("foo") != "hello") {
   46.48 +    fail("Expected 'foo' to be 'hello'");
   46.49 +}
   46.50 +
   46.51 +if (e.eval("engine") != e) {
   46.52 +    fail("'engine' is not evaluaed to current engine");
   46.53 +}
   46.54 +
   46.55 +e.put("engine", "foobar");
   46.56 +if (e.eval("engine") != "foobar") {
   46.57 +    fail("'engine' is not evalued to 'foobar'");
   46.58 +}
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/test/script/basic/JDK-8058545.js	Mon Oct 06 15:53:22 2014 -0700
    47.3 @@ -0,0 +1,41 @@
    47.4 +/*
    47.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.7 + * 
    47.8 + * This code is free software; you can redistribute it and/or modify it
    47.9 + * under the terms of the GNU General Public License version 2 only, as
   47.10 + * published by the Free Software Foundation.
   47.11 + * 
   47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   47.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   47.15 + * version 2 for more details (a copy is included in the LICENSE file that
   47.16 + * accompanied this code).
   47.17 + * 
   47.18 + * You should have received a copy of the GNU General Public License version
   47.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   47.21 + * 
   47.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   47.23 + * or visit www.oracle.com if you need additional information or have any
   47.24 + * questions.
   47.25 + */
   47.26 +
   47.27 +/**
   47.28 + * JDK-8058545: With strict mode, bean property assignment of a non-existent property should result in TypeError
   47.29 + *
   47.30 + * @test
   47.31 + * @run
   47.32 + */
   47.33 +
   47.34 +'use strict';
   47.35 +var File = Java.type("java.io.File");
   47.36 +var f = new File(".");
   47.37 +try {
   47.38 +    f.foo = 33;
   47.39 +    fail("Should have thrown TypeError");
   47.40 +} catch (e) {
   47.41 +    if (! (e instanceof TypeError)) {
   47.42 +        fail("Expected TypeError, got " + e);
   47.43 +    }
   47.44 +}
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/test/script/basic/JDK-8058561.js	Mon Oct 06 15:53:22 2014 -0700
    48.3 @@ -0,0 +1,42 @@
    48.4 +/*
    48.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
    48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.7 + * 
    48.8 + * This code is free software; you can redistribute it and/or modify it
    48.9 + * under the terms of the GNU General Public License version 2 only, as
   48.10 + * published by the Free Software Foundation.
   48.11 + * 
   48.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   48.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   48.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   48.15 + * version 2 for more details (a copy is included in the LICENSE file that
   48.16 + * accompanied this code).
   48.17 + * 
   48.18 + * You should have received a copy of the GNU General Public License version
   48.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   48.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   48.21 + * 
   48.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   48.23 + * or visit www.oracle.com if you need additional information or have any
   48.24 + * questions.
   48.25 + */
   48.26 +
   48.27 +/**
   48.28 + * JDK-8058561: NPE in LocalVariableTypesCalculator
   48.29 + *
   48.30 + * @test
   48.31 + * @run
   48.32 + * @option --lazy-compilation=false
   48.33 + */
   48.34 +
   48.35 +// Just attempting to compile this caused the NPE
   48.36 +function func(x, y) {
   48.37 +  while(true) {
   48.38 +     switch (y[0]) {
   48.39 +       case "bar": 
   48.40 +           x = 'xxx';
   48.41 +           break;
   48.42 +     }
   48.43 +  }
   48.44 +  return x;
   48.45 +}
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/test/script/basic/JDK-8058615.js	Mon Oct 06 15:53:22 2014 -0700
    49.3 @@ -0,0 +1,36 @@
    49.4 +/*
    49.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    49.7 + * 
    49.8 + * This code is free software; you can redistribute it and/or modify it
    49.9 + * under the terms of the GNU General Public License version 2 only, as
   49.10 + * published by the Free Software Foundation.
   49.11 + * 
   49.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   49.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   49.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   49.15 + * version 2 for more details (a copy is included in the LICENSE file that
   49.16 + * accompanied this code).
   49.17 + * 
   49.18 + * You should have received a copy of the GNU General Public License version
   49.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   49.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   49.21 + * 
   49.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   49.23 + * or visit www.oracle.com if you need additional information or have any
   49.24 + * questions.
   49.25 + */
   49.26 +
   49.27 +/**
   49.28 + * JDK-8058615: Overload resolution ambiguity involving ConsString
   49.29 + *
   49.30 + * @test
   49.31 + * @run
   49.32 + */
   49.33 +
   49.34 +var strw = new java.io.StringWriter();
   49.35 +var bufw = new java.io.BufferedWriter(strw);
   49.36 +var s = "hello ";
   49.37 +bufw.write(s + "world");
   49.38 +bufw.close();
   49.39 +print(strw.toString());
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/test/script/basic/JDK-8058615.js.EXPECTED	Mon Oct 06 15:53:22 2014 -0700
    50.3 @@ -0,0 +1,1 @@
    50.4 +hello world
    51.1 --- a/test/src/jdk/nashorn/api/scripting/ScopeTest.java	Wed Sep 24 14:43:37 2014 -0700
    51.2 +++ b/test/src/jdk/nashorn/api/scripting/ScopeTest.java	Mon Oct 06 15:53:22 2014 -0700
    51.3 @@ -582,6 +582,60 @@
    51.4          assertEquals(e.eval("x", newCtxt), 2);
    51.5      }
    51.6  
    51.7 +    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
    51.8 +    @Test
    51.9 +    public static void contextOverwriteTest() throws ScriptException {
   51.10 +        final ScriptEngineManager m = new ScriptEngineManager();
   51.11 +        final ScriptEngine e = m.getEngineByName("nashorn");
   51.12 +        final Bindings b = new SimpleBindings();
   51.13 +        b.put("context", "hello");
   51.14 +        b.put("foo", 32);
   51.15 +        final ScriptContext newCtxt = new SimpleScriptContext();
   51.16 +        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
   51.17 +        e.setContext(newCtxt);
   51.18 +        assertEquals(e.eval("context"), "hello");
   51.19 +        assertEquals(((Number)e.eval("foo")).intValue(), 32);
   51.20 +    }
   51.21 +
   51.22 +    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
   51.23 +    @Test
   51.24 +    public static void contextOverwriteInScriptTest() throws ScriptException {
   51.25 +        final ScriptEngineManager m = new ScriptEngineManager();
   51.26 +        final ScriptEngine e = m.getEngineByName("nashorn");
   51.27 +        e.put("foo", 32);
   51.28 +
   51.29 +        assertEquals(((Number)e.eval("foo")).intValue(), 32);
   51.30 +        assertEquals(e.eval("context = 'bar'"), "bar");
   51.31 +        assertEquals(((Number)e.eval("foo")).intValue(), 32);
   51.32 +    }
   51.33 +
   51.34 +    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
   51.35 +    @Test
   51.36 +    public static void engineOverwriteTest() throws ScriptException {
   51.37 +        final ScriptEngineManager m = new ScriptEngineManager();
   51.38 +        final ScriptEngine e = m.getEngineByName("nashorn");
   51.39 +        final Bindings b = new SimpleBindings();
   51.40 +        b.put("engine", "hello");
   51.41 +        b.put("foo", 32);
   51.42 +        final ScriptContext newCtxt = new SimpleScriptContext();
   51.43 +        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
   51.44 +        e.setContext(newCtxt);
   51.45 +        assertEquals(e.eval("engine"), "hello");
   51.46 +        assertEquals(((Number)e.eval("foo")).intValue(), 32);
   51.47 +    }
   51.48 +
   51.49 +    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
   51.50 +    @Test
   51.51 +    public static void engineOverwriteInScriptTest() throws ScriptException {
   51.52 +        final ScriptEngineManager m = new ScriptEngineManager();
   51.53 +        final ScriptEngine e = m.getEngineByName("nashorn");
   51.54 +        e.put("foo", 32);
   51.55 +
   51.56 +        assertEquals(((Number)e.eval("foo")).intValue(), 32);
   51.57 +        assertEquals(e.eval("engine = 'bar'"), "bar");
   51.58 +        assertEquals(((Number)e.eval("foo")).intValue(), 32);
   51.59 +    }
   51.60 +
   51.61      // @bug 8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
   51.62      @Test
   51.63      public static void testMegamorphicGetInGlobal() throws Exception {

mercurial