Merge
authorlana
Thu, 26 Sep 2013 17:23:22 -0700
changeset 20228 95df1088d4af
parent 20208 9f8c14f717ca (current diff)
parent 20227 1141c4b6e435 (diff)
child 20229 d02dc5420df0
Merge
--- a/nashorn/make/build-benchmark.xml	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/make/build-benchmark.xml	Thu Sep 26 17:23:22 2013 -0700
@@ -329,7 +329,7 @@
           fork="true"
           dir=".">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs.octane}"/>
+      <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
       <arg value="${octane-test-sys-prop.test.js.framework}"/>
       <arg value="--"/>
       <arg value="${octane-tests}"/>
@@ -357,7 +357,7 @@
           classpath="${run.test.classpath}"
           fork="true"
           dir=".">
-      <jvmarg line="${run.test.jvmargs.octane}"/>
+      <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
       <arg value="${octane-test-sys-prop.test.js.framework}"/>
       <arg value="${octane-tests}"/>
       <arg value="--runtime"/>
@@ -391,7 +391,7 @@
           fork="true"
           dir=".">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
       <arg value="-timezone=PST"/>
       <arg value="--class-cache-size=50"/>
       <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
@@ -415,7 +415,7 @@
           classpath="${run.test.classpath}"
           fork="true"
           dir=".">
-      <jvmarg line="${run.test.jvmargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
       <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
       <arg value="${sunspider-tests}/"/>
     </java>
--- a/nashorn/make/build.xml	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/make/build.xml	Thu Sep 26 17:23:22 2013 -0700
@@ -66,6 +66,8 @@
 
     <echo message="run.test.jvmargs=${run.test.jvmargs}"/>
     <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
+    <echo message="run.test.xms=${run.test.xms}"/>
+    <echo message="run.test.xmx=${run.test.xmx}"/>
 
   </target>
 
@@ -320,7 +322,7 @@
     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
       <propertyset>
         <propertyref prefix="test-sys-prop."/>
         <mapper from="test-sys-prop.*" to="*" type="glob"/>
@@ -336,7 +338,7 @@
       <!-- use just build.test.classes.dir to avoid referring to TestNG -->
       <java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
       <syspropertyset>
           <propertyref prefix="test-sys-prop."/>
           <mapper type="glob" from="test-sys-prop.*" to="*"/>
@@ -352,7 +354,7 @@
     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
       <propertyset>
         <propertyref prefix="test262-test-sys-prop."/>
         <mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
@@ -369,7 +371,7 @@
     <!-- use just build.test.classes.dir to avoid referring to TestNG -->
     <java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
       <classpath>
           <pathelement path="${run.test.classpath}"/>
       </classpath>
@@ -387,7 +389,7 @@
       description="Run the shell with a sample script">
     <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
         <jvmarg line="${ext.class.path}"/>
-        <jvmarg line="${run.test.jvmargs}"/>
+        <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
         <arg value="-dump-on-error"/>
         <arg value="test.js"/>
     </java>
@@ -397,7 +399,7 @@
       description="Debug the shell with a sample script">
     <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
         <jvmarg line="${ext.class.path}"/>
-        <jvmarg line="${run.test.jvmargs}"/>
+        <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
         <arg value="--print-code"/>
         <arg value="--verify-code"/>
         <arg value="--print-symbols"/>
--- a/nashorn/make/project.properties	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/make/project.properties	Thu Sep 26 17:23:22 2013 -0700
@@ -216,13 +216,14 @@
 src.dir=src
 test.src.dir=test/src
 
+# -Xmx is used for all tests, -Xms only for octane benchmark
 run.test.xmx=3G
 run.test.xms=2G
 
 run.test.user.language=tr
 run.test.user.country=TR
 
-run.test.jvmargs.common=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} -XX:+HeapDumpOnOutOfMemoryError
+run.test.jvmargs.common=-server -XX:+TieredCompilation -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} -XX:+HeapDumpOnOutOfMemoryError
 
 #-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
 # -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
@@ -231,12 +232,12 @@
 run.test.jvmargs.main=${run.test.jvmargs.common} -ea
 
 #-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M  
-run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.common}
+run.test.jvmargs.octane.main=${run.test.jvmargs.common}
 
 run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
 
 # VM options for script tests with @fork option
-test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} ${run.test.jvmsecurityargs}
+test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}
 
 # path of rhino.jar for benchmarks
 rhino.jar=
--- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Thu Sep 26 17:23:22 2013 -0700
@@ -185,21 +185,12 @@
 
     @Override
     public Object eval(final Reader reader, final ScriptContext ctxt) throws ScriptException {
-        try {
-            if (reader instanceof URLReader) {
-                final URL url = ((URLReader)reader).getURL();
-                final Charset cs = ((URLReader)reader).getCharset();
-                return evalImpl(compileImpl(new Source(url.toString(), url, cs), ctxt), ctxt);
-            }
-            return evalImpl(Source.readFully(reader), ctxt);
-        } catch (final IOException e) {
-            throw new ScriptException(e);
-        }
+        return evalImpl(makeSource(reader, ctxt), ctxt);
     }
 
     @Override
     public Object eval(final String script, final ScriptContext ctxt) throws ScriptException {
-        return evalImpl(script.toCharArray(), ctxt);
+        return evalImpl(makeSource(script, ctxt), ctxt);
     }
 
     @Override
@@ -221,16 +212,12 @@
 
     @Override
     public CompiledScript compile(final Reader reader) throws ScriptException {
-        try {
-            return asCompiledScript(compileImpl(Source.readFully(reader), context));
-        } catch (final IOException e) {
-            throw new ScriptException(e);
-        }
+        return asCompiledScript(makeSource(reader, context));
     }
 
     @Override
     public CompiledScript compile(final String str) throws ScriptException {
-        return asCompiledScript(compileImpl(str.toCharArray(), context));
+        return asCompiledScript(makeSource(str, context));
     }
 
     // Invocable methods
@@ -292,6 +279,29 @@
 
     // Implementation only below this point
 
+    private static Source makeSource(final Reader reader, final ScriptContext ctxt) throws ScriptException {
+        try {
+            if (reader instanceof URLReader) {
+                final URL url = ((URLReader)reader).getURL();
+                final Charset cs = ((URLReader)reader).getCharset();
+                return new Source(url.toString(), url, cs);
+            } else {
+                return new Source(getScriptName(ctxt), Source.readFully(reader));
+            }
+        } catch (final IOException ioExp) {
+            throw new ScriptException(ioExp);
+        }
+    }
+
+    private static Source makeSource(final String src, final ScriptContext ctxt) {
+        return new Source(getScriptName(ctxt), src);
+    }
+
+    private static String getScriptName(final ScriptContext ctxt) {
+        final Object val = ctxt.getAttribute(ScriptEngine.FILENAME);
+        return (val != null) ? val.toString() : "<eval>";
+    }
+
     private <T> T getInterfaceInner(final Object thiz, final Class<T> clazz) {
         if (clazz == null || !clazz.isInterface()) {
             throw new IllegalArgumentException(getMessage("interface.class.expected"));
@@ -429,7 +439,7 @@
         // current ScriptContext exposed as "context"
         // "context" is non-writable from script - but script engine still
         // needs to set it and so save the context Property object
-        contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, null);
+        contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, ctxt);
         // current ScriptEngine instance exposed as "engine". We added @SuppressWarnings("LeakingThisInConstructor") as
         // NetBeans identifies this assignment as such a leak - this is a false positive as we're setting this property
         // in the Global of a Context we just created - both the Context and the Global were just created and can not be
@@ -509,8 +519,8 @@
         throw new IllegalArgumentException(getMessage("interface.on.non.script.object"));
     }
 
-    private Object evalImpl(final char[] buf, final ScriptContext ctxt) throws ScriptException {
-        return evalImpl(compileImpl(buf, ctxt), ctxt);
+    private Object evalImpl(final Source src, final ScriptContext ctxt) throws ScriptException {
+        return evalImpl(compileImpl(src, ctxt), ctxt);
     }
 
     private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt) throws ScriptException {
@@ -561,11 +571,20 @@
         }
     }
 
-    private CompiledScript asCompiledScript(final ScriptFunction script) {
+    private CompiledScript asCompiledScript(final Source source) throws ScriptException {
+        final ScriptFunction func = compileImpl(source, context);
         return new CompiledScript() {
             @Override
             public Object eval(final ScriptContext ctxt) throws ScriptException {
-                return evalImpl(script, ctxt);
+                final ScriptObject global = getNashornGlobalFrom(ctxt);
+                // Are we running the script in the correct global?
+                if (func.getScope() == global) {
+                    return evalImpl(func, ctxt, global);
+                } else {
+                    // ScriptContext with a different global. Compile again!
+                    // Note that we may still hit per-global compilation cache.
+                    return evalImpl(compileImpl(source, ctxt), ctxt, global);
+                }
             }
             @Override
             public ScriptEngine getEngine() {
@@ -574,12 +593,6 @@
         };
     }
 
-    private ScriptFunction compileImpl(final char[] buf, final ScriptContext ctxt) throws ScriptException {
-        final Object val = ctxt.getAttribute(ScriptEngine.FILENAME);
-        final String fileName = (val != null) ? val.toString() : "<eval>";
-        return compileImpl(new Source(fileName, buf), ctxt);
-    }
-
     private ScriptFunction compileImpl(final Source source, final ScriptContext ctxt) throws ScriptException {
         return compileImpl(source, getNashornGlobalFrom(ctxt));
     }
--- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java	Thu Sep 26 17:23:22 2013 -0700
@@ -807,9 +807,11 @@
                     type = Type.OBJECT;
                 }
 
-                type = Type.widest(type, newCaseNode.getTest().getType());
-                if (type.isBoolean()) {
+                final Type newCaseType = newCaseNode.getTest().getType();
+                if (newCaseType.isBoolean()) {
                     type = Type.OBJECT; //booleans and integers aren't assignment compatible
+                } else {
+                    type = Type.widest(type, newCaseType);
                 }
             }
 
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Sep 26 17:23:22 2013 -0700
@@ -852,7 +852,6 @@
         final Label  loopLabel = new Label("loop");
 
         final Expression init = forNode.getInit();
-        assert init instanceof IdentNode;
 
         load(modify);
         assert modify.getType().isObject();
@@ -2175,8 +2174,9 @@
             method.invoke(ScriptRuntime.OPEN_WITH);
             method.storeCompilerConstant(SCOPE);
         } else {
-            // We just loaded the expression for its side effect; discard it
-            method.pop();
+            // We just loaded the expression for its side effect and to check
+            // for null or undefined value.
+            globalCheckObjectCoercible();
         }
 
 
@@ -3258,6 +3258,10 @@
         return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class));
     }
 
+    private MethodEmitter globalCheckObjectCoercible() {
+        return method.invokestatic(GLOBAL_OBJECT, "checkObjectCoercible", methodDescriptor(void.class, Object.class));
+    }
+
     private MethodEmitter globalDirectEval() {
         return method.invokestatic(GLOBAL_OBJECT, "directEval",
                 methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class));
--- a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java	Thu Sep 26 17:23:22 2013 -0700
@@ -79,13 +79,12 @@
         if (visitor.enterWhileNode(this)) {
             if (isDoWhile()) {
                 return visitor.leaveWhileNode(
-                        setTest(lc, (Expression)test.accept(visitor)).
-                        setBody(lc, (Block)body.accept(visitor)));
+                        setBody(lc, (Block)body.accept(visitor)).
+                        setTest(lc, (Expression)test.accept(visitor)));
             }
             return visitor.leaveWhileNode(
-                    setBody(lc, (Block)body.accept(visitor)).
-                    setTest(lc, (Expression)test.accept(visitor)));
-
+                    setTest(lc, (Expression)test.accept(visitor)).
+                    setBody(lc, (Block)body.accept(visitor)));
         }
         return this;
     }
--- a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Thu Sep 26 17:23:22 2013 -0700
@@ -410,7 +410,8 @@
         comma();
 
         property("id");
-        if (functionNode.isAnonymous()) {
+        final FunctionNode.Kind kind = functionNode.getKind();
+        if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
             nullValue();
         } else {
             functionNode.getIdent().accept(this);
--- a/nashorn/src/jdk/nashorn/internal/objects/Global.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java	Thu Sep 26 17:23:22 2013 -0700
@@ -33,6 +33,7 @@
 import java.io.PrintWriter;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
+import java.lang.ref.ReferenceQueue;
 import java.lang.ref.SoftReference;
 import java.lang.reflect.Field;
 import java.util.Arrays;
@@ -691,17 +692,41 @@
      * Cache for compiled script classes.
      */
     @SuppressWarnings("serial")
-    private static class ClassCache extends LinkedHashMap<Source, SoftReference<Class<?>>> {
+    private static class ClassCache extends LinkedHashMap<Source, ClassReference> {
         private final int size;
+        private final ReferenceQueue<Class<?>> queue;
 
         ClassCache(int size) {
             super(size, 0.75f, true);
             this.size = size;
+            this.queue = new ReferenceQueue<>();
+        }
+
+        void cache(final Source source, final Class<?> clazz) {
+            put(source, new ClassReference(clazz, queue, source));
+        }
+
+        @Override
+        protected boolean removeEldestEntry(final Map.Entry<Source, ClassReference> eldest) {
+            return size() > size;
         }
 
         @Override
-        protected boolean removeEldestEntry(final Map.Entry<Source, SoftReference<Class<?>>> eldest) {
-            return size() >= size;
+        public ClassReference get(Object key) {
+            for (ClassReference ref; (ref = (ClassReference)queue.poll()) != null; ) {
+                remove(ref.source);
+            }
+            return super.get(key);
+        }
+
+    }
+
+    private static class ClassReference extends SoftReference<Class<?>> {
+        private final Source source;
+
+        ClassReference(final Class<?> clazz, final ReferenceQueue<Class<?>> queue, final Source source) {
+            super(clazz, queue);
+            this.source = source;
         }
     }
 
@@ -709,22 +734,14 @@
     @Override
     public Class<?> findCachedClass(final Source source) {
         assert classCache != null : "Class cache used without being initialized";
-        SoftReference<Class<?>> ref = classCache.get(source);
-        if (ref != null) {
-            final Class<?> clazz = ref.get();
-            if (clazz == null) {
-                classCache.remove(source);
-            }
-            return clazz;
-        }
-
-        return null;
+        ClassReference ref = classCache.get(source);
+        return ref != null ? ref.get() : null;
     }
 
     @Override
     public void cacheClass(final Source source, final Class<?> clazz) {
         assert classCache != null : "Class cache used without being initialized";
-        classCache.put(source, new SoftReference<Class<?>>(clazz));
+        classCache.cache(source, clazz);
     }
 
     private static <T> T getLazilyCreatedValue(final Object key, final Callable<T> creator, final Map<Object, T> map) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java	Thu Sep 26 17:23:22 2013 -0700
@@ -75,11 +75,11 @@
     private static final int FORMAT_LOCAL_TIME      = 5;
 
     // Constants defined in ECMA 15.9.1.10
-    private static final double hoursPerDay      = 24;
-    private static final double minutesPerHour   = 60;
-    private static final double secondsPerMinute = 60;
-    private static final double msPerSecond   = 1_000;
-    private static final double msPerMinute  = 60_000;
+    private static final int    hoursPerDay      = 24;
+    private static final int    minutesPerHour   = 60;
+    private static final int    secondsPerMinute = 60;
+    private static final int    msPerSecond   = 1_000;
+    private static final int    msPerMinute  = 60_000;
     private static final double msPerHour = 3_600_000;
     private static final double msPerDay = 86_400_000;
 
@@ -926,13 +926,13 @@
                 case FORMAT_DATE :
                 case FORMAT_LOCAL_DATE_TIME:
                     // EEE MMM dd yyyy
-                    sb.append(weekDays[(int) weekDay(t)])
+                    sb.append(weekDays[weekDay(t)])
                             .append(' ')
-                            .append(months[(int) monthFromTime(t)])
+                            .append(months[monthFromTime(t)])
                             .append(' ');
-                    zeroPad(sb, (int) dayFromTime(t), 2);
+                    zeroPad(sb, dayFromTime(t), 2);
                     sb.append(' ');
-                    zeroPad(sb, (int) yearFromTime(t), 4);
+                    zeroPad(sb, yearFromTime(t), 4);
                     if (format == FORMAT_DATE) {
                         break;
                     }
@@ -948,11 +948,11 @@
                     offset = (offset / 60) * 100 + offset % 60;
 
                     // HH:mm:ss GMT+HHmm
-                    zeroPad(sb, (int) hourFromTime(t), 2);
+                    zeroPad(sb, hourFromTime(t), 2);
                     sb.append(':');
-                    zeroPad(sb, (int) minFromTime(t), 2);
+                    zeroPad(sb, minFromTime(t), 2);
                     sb.append(':');
-                    zeroPad(sb, (int) secFromTime(t), 2);
+                    zeroPad(sb, secFromTime(t), 2);
                     sb.append(" GMT")
                             .append(offset < 0 ? '-' : '+');
                     zeroPad(sb, Math.abs(offset), 4);
@@ -963,20 +963,20 @@
 
                 case FORMAT_LOCAL_DATE:
                     // yyyy-MM-dd
-                    zeroPad(sb, (int) yearFromTime(t), 4);
+                    zeroPad(sb, yearFromTime(t), 4);
                     sb.append('-');
-                    zeroPad(sb, (int) monthFromTime(t) + 1, 2);
+                    zeroPad(sb, monthFromTime(t) + 1, 2);
                     sb.append('-');
-                    zeroPad(sb, (int) dayFromTime(t), 2);
+                    zeroPad(sb, dayFromTime(t), 2);
                     break;
 
                 case FORMAT_LOCAL_TIME:
                     // HH:mm:ss
-                    zeroPad(sb, (int) hourFromTime(t), 2);
+                    zeroPad(sb, hourFromTime(t), 2);
                     sb.append(':');
-                    zeroPad(sb, (int) minFromTime(t), 2);
+                    zeroPad(sb, minFromTime(t), 2);
                     sb.append(':');
-                    zeroPad(sb, (int) secFromTime(t), 2);
+                    zeroPad(sb, secFromTime(t), 2);
                     break;
 
                 default:
@@ -996,19 +996,19 @@
             final StringBuilder sb = new StringBuilder(29);
             final double t = nd.getTime();
             // EEE, dd MMM yyyy HH:mm:ss z
-            sb.append(weekDays[(int) weekDay(t)])
+            sb.append(weekDays[weekDay(t)])
                     .append(", ");
-            zeroPad(sb, (int) dayFromTime(t), 2);
+            zeroPad(sb, dayFromTime(t), 2);
             sb.append(' ')
-                    .append(months[(int) monthFromTime(t)])
+                    .append(months[monthFromTime(t)])
                     .append(' ');
-            zeroPad(sb, (int) yearFromTime(t), 4);
+            zeroPad(sb, yearFromTime(t), 4);
             sb.append(' ');
-            zeroPad(sb, (int) hourFromTime(t), 2);
+            zeroPad(sb, hourFromTime(t), 2);
             sb.append(':');
-            zeroPad(sb, (int) minFromTime(t), 2);
+            zeroPad(sb, minFromTime(t), 2);
             sb.append(':');
-            zeroPad(sb, (int) secFromTime(t), 2);
+            zeroPad(sb, secFromTime(t), 2);
             sb.append(" GMT");
             return sb.toString();
         }
@@ -1023,19 +1023,19 @@
             final StringBuilder sb = new StringBuilder(24);
             final double t = nd.getTime();
             // yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
-            zeroPad(sb, (int) yearFromTime(t), 4);
+            zeroPad(sb, yearFromTime(t), 4);
             sb.append('-');
-            zeroPad(sb, (int) monthFromTime(t) + 1, 2);
+            zeroPad(sb, monthFromTime(t) + 1, 2);
             sb.append('-');
-            zeroPad(sb, (int) dayFromTime(t), 2);
+            zeroPad(sb, dayFromTime(t), 2);
             sb.append('T');
-            zeroPad(sb, (int) hourFromTime(t), 2);
+            zeroPad(sb, hourFromTime(t), 2);
             sb.append(':');
-            zeroPad(sb, (int) minFromTime(t), 2);
+            zeroPad(sb, minFromTime(t), 2);
             sb.append(':');
-            zeroPad(sb, (int) secFromTime(t), 2);
+            zeroPad(sb, secFromTime(t), 2);
             sb.append('.');
-            zeroPad(sb, (int) msFromTime(t), 3);
+            zeroPad(sb, msFromTime(t), 3);
             sb.append("Z");
             return sb.toString();
         }
@@ -1072,29 +1072,30 @@
     }
 
     // ECMA 15.9.1.3 Year Number
-    private static double timeFromYear(final double y) {
+    private static double timeFromYear(final int y) {
         return dayFromYear(y) * msPerDay;
     }
 
-    private static double yearFromTime(final double t) {
-        double y = Math.floor(t / (msPerDay * 365.2425)) + 1970;
+    // ECMA 15.9.1.3 Year Number
+    private static int yearFromTime(final double t) {
+        int y = (int) Math.floor(t / (msPerDay * 365.2425)) + 1970;
         final double t2 = timeFromYear(y);
         if (t2 > t) {
             y--;
-        } else if (t2 + msPerDay * daysInYear((int) y) <= t) {
+        } else if (t2 + msPerDay * daysInYear(y) <= t) {
             y++;
         }
         return y;
     }
 
-    private static double dayWithinYear(final double t, final double year) {
-        return day(t) - dayFromYear(year);
+    private static int dayWithinYear(final double t, final int year) {
+        return (int) (day(t) - dayFromYear(year));
     }
 
-    private static double monthFromTime(final double t) {
-        final double year = yearFromTime(t);
-        final double day = dayWithinYear(t, year);
-        final int[] firstDay = firstDayInMonth[isLeapYear((int) year) ? 1 : 0];
+    private static int monthFromTime(final double t) {
+        final int year = yearFromTime(t);
+        final int day = dayWithinYear(t, year);
+        final int[] firstDay = firstDayInMonth[isLeapYear(year) ? 1 : 0];
         int month = 0;
 
         while (month < 11 && firstDay[month + 1] <= day) {
@@ -1103,10 +1104,10 @@
         return month;
     }
 
-    private static double dayFromTime(final double t)  {
-        final double year = yearFromTime(t);
-        final double day = dayWithinYear(t, year);
-        final int[] firstDay = firstDayInMonth[isLeapYear((int) year) ? 1 : 0];
+    private static int dayFromTime(final double t)  {
+        final int year = yearFromTime(t);
+        final int day = dayWithinYear(t, year);
+        final int[] firstDay = firstDayInMonth[isLeapYear(year) ? 1 : 0];
         int month = 0;
 
         while (month < 11 && firstDay[month + 1] <= day) {
@@ -1121,11 +1122,8 @@
         return firstDay[month];
     }
 
-    private static double weekDay(final double time) {
-        if (isNaN(time)) {
-            return NaN;
-        }
-        final double day = (day(time) + 4) % 7;
+    private static int weekDay(final double time) {
+        final int day = (int) (day(time) + 4) % 7;
         return day < 0 ? day + 7 : day;
     }
 
@@ -1140,26 +1138,26 @@
     }
 
     // ECMA 15.9.1.10 Hours, Minutes, Second, and Milliseconds
-    private static double hourFromTime(final double t) {
-        final double h = Math.floor(t / msPerHour) % hoursPerDay;
+    private static int hourFromTime(final double t) {
+        final int h = (int) (Math.floor(t / msPerHour) % hoursPerDay);
         return h < 0 ? h + hoursPerDay: h;
     }
-    private static double minFromTime(final double t) {
-        final double m = Math.floor(t / msPerMinute) % minutesPerHour;
+    private static int minFromTime(final double t) {
+        final int m = (int) (Math.floor(t / msPerMinute) % minutesPerHour);
         return m < 0 ? m + minutesPerHour : m;
     }
 
-    private static double secFromTime(final double t) {
-        final double s = Math.floor(t / msPerSecond) % secondsPerMinute;
+    private static int secFromTime(final double t) {
+        final int s = (int) (Math.floor(t / msPerSecond) % secondsPerMinute);
         return s < 0 ? s + secondsPerMinute : s;
     }
 
-    private static double msFromTime(final double t) {
-        final double m = t % msPerSecond;
+    private static int msFromTime(final double t) {
+        final int m = (int) (t % msPerSecond);
         return m < 0 ? m + msPerSecond : m;
     }
 
-    private static double valueFromTime(final int unit, final double t) {
+    private static int valueFromTime(final int unit, final double t) {
         switch (unit) {
             case YEAR: return yearFromTime(t);
             case MONTH: return monthFromTime(t);
@@ -1180,12 +1178,12 @@
     // ECMA 15.9.1.12 MakeDay (year, month, date)
     private static double makeDay(final double year, final double month, final double date) {
         final double y = year + Math.floor(month / 12);
-        double m = month % 12;
+        int m = (int) (month % 12);
         if (m < 0) {
             m += 12;
         }
-        double d = Math.floor(dayFromYear(y));
-        d += dayFromMonth((int) m, (int) y);
+        double d = dayFromYear(y);
+        d += dayFromMonth(m, (int) y);
 
         return d + date - 1;
     }
@@ -1257,13 +1255,13 @@
                     nullReturn = true;
                 }
 
-                if (! nullReturn) {
+                if (!nullReturn && !isNaN(time)) {
                     d[i - start] = valueFromTime(i, time);
                 }
             }
         }
 
-        return nullReturn? null : d;
+        return nullReturn ? null : d;
     }
 
     // ECMA 15.9.1.14 TimeClip (time)
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java	Thu Sep 26 17:23:22 2013 -0700
@@ -162,22 +162,27 @@
 
         String gap;
 
-        if (space instanceof Number || space instanceof NativeNumber) {
-            int indent;
-            if (space instanceof NativeNumber) {
-                indent = ((NativeNumber)space).intValue();
-            } else {
-                indent = ((Number)space).intValue();
-            }
+        // modifiable 'space' - parameter is final
+        Object modSpace = space;
+        if (modSpace instanceof NativeNumber) {
+            modSpace = JSType.toNumber(JSType.toPrimitive(modSpace, Number.class));
+        } else if (modSpace instanceof NativeString) {
+            modSpace = JSType.toString(JSType.toPrimitive(modSpace, String.class));
+        }
 
-            final StringBuilder sb = new StringBuilder();
-            for (int i = 0; i < Math.min(10, indent); i++) {
-                sb.append(' ');
+        if (modSpace instanceof Number) {
+            int indent = Math.min(10, JSType.toInteger(modSpace));
+            if (indent < 1) {
+                gap = "";
+            } else {
+                final StringBuilder sb = new StringBuilder();
+                for (int i = 0; i < indent; i++) {
+                    sb.append(' ');
+                }
+                gap = sb.toString();
             }
-            gap = sb.toString();
-
-        } else if (space instanceof String || space instanceof ConsString || space instanceof NativeString) {
-            final String str = (space instanceof String) ? (String)space : space.toString();
+        } else if (modSpace instanceof String || modSpace instanceof ConsString) {
+            final String str = modSpace.toString();
             gap = str.substring(0, Math.min(10, str.length()));
         } else {
             gap = "";
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java	Thu Sep 26 17:23:22 2013 -0700
@@ -191,23 +191,21 @@
     public static NativeRegExp newRegExp(final Object regexp, final Object flags) {
         String  patternString = "";
         String  flagString    = "";
-        boolean flagsDefined  = false;
-
-        if (flags != UNDEFINED) {
-            flagsDefined = true;
-            flagString = JSType.toString(flags);
-        }
 
         if (regexp != UNDEFINED) {
             if (regexp instanceof NativeRegExp) {
-                if (!flagsDefined) {
-                    return (NativeRegExp)regexp; // 15.10.3.1 - undefined flags and regexp as
+                if (flags != UNDEFINED) {
+                    throw typeError("regex.cant.supply.flags");
                 }
-                throw typeError("regex.cant.supply.flags");
+                return (NativeRegExp)regexp; // 15.10.3.1 - undefined flags and regexp as
             }
             patternString = JSType.toString(regexp);
         }
 
+        if (flags != UNDEFINED) {
+            flagString = JSType.toString(flags);
+        }
+
         return new NativeRegExp(patternString, flagString);
     }
 
@@ -697,8 +695,13 @@
                 appendReplacement(matcher, string, replacement, sb);
             }
 
+            thisIndex = matcher.end();
+            if (thisIndex == string.length() && matcher.start() == matcher.end()) {
+                // Avoid getting empty match at end of string twice
+                break;
+            }
+
             // ECMA 15.5.4.10 String.prototype.match(regexp)
-            thisIndex = matcher.end();
             if (thisIndex == previousLastIndex) {
                 setLastIndex(thisIndex + 1);
                 previousLastIndex = thisIndex + 1;
@@ -883,7 +886,7 @@
      * @return last index property as int
      */
     public int getLastIndex() {
-        return JSType.toInt32(lastIndex);
+        return JSType.toInteger(lastIndex);
     }
 
     /**
--- a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java	Thu Sep 26 17:23:22 2013 -0700
@@ -349,6 +349,10 @@
 
             case COMMARIGHT:
                 next();
+                // check for trailing comma - not allowed in JSON
+                if (type == RBRACKET) {
+                    throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+                }
                 break;
 
             default:
@@ -388,6 +392,10 @@
 
             case COMMARIGHT:
                 next();
+                // check for trailing comma - not allowed in JSON
+                if (type == RBRACE) {
+                    throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+                }
                 break;
 
             default:
--- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java	Thu Sep 26 17:23:22 2013 -0700
@@ -59,6 +59,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import jdk.internal.dynalink.support.NameCodec;
 import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.codegen.Namespace;
 import jdk.nashorn.internal.ir.AccessNode;
@@ -2108,7 +2109,7 @@
                 case "get":
                     final PropertyKey getIdent = propertyName();
                     final String getterName = getIdent.getPropertyName();
-                    final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName);
+                    final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + NameCodec.encode(getterName));
                     expect(LPAREN);
                     expect(RPAREN);
                     functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER);
@@ -2117,7 +2118,7 @@
                 case "set":
                     final PropertyKey setIdent = propertyName();
                     final String setterName = setIdent.getPropertyName();
-                    final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName);
+                    final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + NameCodec.encode(setterName));
                     expect(LPAREN);
                     final IdentNode argIdent = getIdent();
                     verifyStrictIdent(argIdent, "setter argument");
--- a/nashorn/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Thu Sep 26 17:23:22 2013 -0700
@@ -90,6 +90,7 @@
     public static double parseInt(final Object self, final Object string, final Object rad) {
         final String str    = JSType.trimLeft(JSType.toString(string));
         final int    length = str.length();
+        int          radix  = JSType.toInt32(rad);
 
         // empty string is not valid
         if (length == 0) {
@@ -113,7 +114,6 @@
         }
 
         boolean stripPrefix = true;
-        int     radix = JSType.toInt32(rad);
 
         if (radix != 0) {
             if (radix < 2 || radix > 36) {
@@ -211,7 +211,7 @@
             switch (ch) {
             case '.':
                 // dot allowed only once
-                if (dotSeen) {
+                if (exponentOffset != -1 || dotSeen) {
                     break loop;
                 }
                 dotSeen = true;
--- a/nashorn/src/jdk/nashorn/internal/runtime/Source.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Source.java	Thu Sep 26 17:23:22 2013 -0700
@@ -169,7 +169,7 @@
 
         final Source src = (Source)obj;
         // Only compare content as a last resort measure
-        return length == src.length && Objects.equals(name, src.name) && Arrays.equals(content, src.content);
+        return length == src.length && Objects.equals(url, src.url) && Objects.equals(name, src.name) && Arrays.equals(content, src.content);
     }
 
     @Override
--- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Thu Sep 26 17:23:22 2013 -0700
@@ -57,6 +57,7 @@
 parser.error.regex.unsupported.flag=Unsupported RegExp flag: {0}
 parser.error.regex.repeated.flag=Repeated RegExp flag: {0}
 parser.error.regex.syntax={0}
+parser.error.trailing.comma.in.json=Trailing comma is not allowed in JSON
 
 # strict mode error messages
 parser.error.strict.no.with="with" statement cannot be used in strict mode
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8024972.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8024972: for (LeftHandSideExpression in Expression) crashes the compiler
+ *
+ * @test
+ * @run
+ */
+
+var obj = {};
+
+var arr = [2, 45, -1, 445];
+for (obj.x in arr) {
+    print(obj.x + "->"+ arr[obj.x]);
+}
+
+var abc = { foo: 'bar', hello: 'world' };
+for (obj.x in abc) {
+    print(obj.x + "->" + abc[obj.x]);
+}
+
+for (obj.x in 0) {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8024972.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,6 @@
+0->2
+1->45
+2->-1
+3->445
+foo->bar
+hello->world
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025048-2.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025048: true as case label results in ClassCastException
+ *
+ * @test
+ * @run
+ */
+
+function func(x) {
+    switch(x) { 
+        case 8: break; case false:
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025048.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025048: true as case label results in ClassCastException
+ *
+ * @test
+ * @run
+ */
+
+function func(x) {
+    switch(x) { 
+        case 8: break; case true:
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025080.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025080: Object literal getter, setter function with number format property name results in ClassFormatError
+ *
+ * @test
+ * @run
+ */
+
+var obj = {
+    get 1e81() { print("1e81 getter"); },
+    set 1e81(x) { print("1e81 setter"); },
+    get 3.14e-2() { print("3.14e-2 getter");},
+    set 3.14e-2(x) { print("3.14e-2 setter"); }
+};
+
+obj[1e81];
+obj[1e81] = 23;
+
+obj[3.14e-2];
+obj[3.14e-2] = 42;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025080.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,4 @@
+1e81 getter
+1e81 setter
+3.14e-2 getter
+3.14e-2 setter
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025090.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025090: 'while' statement with 'test' using var before being declared in body results in VerifyError
+ *
+ * @test
+ * @run
+ */
+
+// The following used to result in VerifyError
+function f() {
+   while (x += 2) { var x = 44 }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025111.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025111: undefined or null 'with' expression in empty with block should throw TypeError
+ *
+ * @test
+ * @run
+ */
+
+function check(callback, arg) {
+    try {
+        callback(arg);
+        fail("should have thrown TypeError: " + callback + " on " + arg);
+    } catch (e) {
+        if (! (e instanceof TypeError)) {
+            fail("Expected TypeError, got " + e);
+        }
+    }
+}
+
+function func(obj) {
+    with(obj) {}
+}
+
+check(func);
+check(func, undefined);
+check(func, null);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025147.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025147: Trailing comma is not allowed in JSONArray and JSONObject
+ *
+ * @test
+ * @run
+ */
+
+function check(str) {
+    try {
+        JSON.parse(str);
+        fail("should have thrown SyntaxError for " + str);
+    } catch (e) {
+        print(e);
+    }
+}
+
+check("{ \"a\": 333, }");
+check("[ 4343, ]");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025147.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,6 @@
+SyntaxError: Invalid JSON: <json>:1:12 Trailing comma is not allowed in JSON
+{ "a": 333, }
+            ^
+SyntaxError: Invalid JSON: <json>:1:8 Trailing comma is not allowed in JSON
+[ 4343, ]
+        ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025149.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025149: JSON.stringify does not handle 'space' argument as per the spec.
+ *
+ * @test
+ * @run
+ */
+
+print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(Infinity)));
+
+print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(-Infinity)));
+
+try {
+    JSON.stringify({},[],
+    (n = new Number(0), n.valueOf = function() { throw ("inside n.valueOf") }, n));
+} catch (e) {
+    print(e);
+}
+
+try {
+    JSON.stringify({},[],
+    (s = new String(""), s.toString = function() { throw ("inside s.toString") }, s));
+} catch (e) {
+    print(e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025149.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,9 @@
+{
+          "foo": 23,
+          "bar": {
+                    "x": 22
+          }
+}
+{"foo":23,"bar":{"x":22}}
+inside n.valueOf
+inside s.toString
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025163.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025163: Date methods should not return -0
+ *
+ * @test
+ * @run
+ */
+
+print(1 / (new Date(0, 0, 1)).getYear());
+print(1 / (new Date(1969, 1, 2)).getDay());
+print(1 / (new Date(1969, 0, 1)).getHours());
+print(1 / (new Date(1969, 0, 1)).getHours());
+print(1 / (new Date(1969, 0, 1)).getMinutes());
+print(1 / (new Date(1969, 0, 1)).getSeconds());
+print(1 / (new Date(1969, 0, 1)).getMilliseconds());
+print(1 / (new Date(1969, 0, 1)).getMilliseconds());
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025163.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,8 @@
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025197.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025197: String replace method fails with regexp /$/gi
+ *
+ * @test
+ * @run
+ */
+
+print('dog'.replace(/$/gi, 's'));
+print('dog'.replace(/(?:g)$/gi, 's'));
+print('dog'.replace(/(?:a)$/gi, 's'));
+print('dog'.replace(/(?!g)$/gi, 's'));
+print('dog'.replace(/(?!a)$/gi, 's'));
+print('dog'.replace(/g?$/gi, 's'));
+print('dog'.replace(/.?$/gi, 's'));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025197.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,7 @@
+dogs
+dos
+dog
+dogs
+dogs
+doss
+doss
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025312.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025312: parseInt should convert 'radix' argument to ToInt32 even if empty string is parsed
+ *
+ * @test
+ * @run
+ */
+
+parseInt("", {
+    valueOf: function() {
+        print("inside valueOf of 'radix'");
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025312.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,1 @@
+inside valueOf of 'radix'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025325.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025325: parseFloat does not handle '.' in exponent part
+ *
+ * @test
+ * @run
+ */
+
+print(parseFloat("2e2."));
+print(parseFloat("2e2.3"));
+print(parseFloat("2e2.fdgdf"));
+print(parseFloat("2e2.   gdfgdf"));
+print(parseFloat("2e2.  "));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025325.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,5 @@
+200
+200
+200
+200
+200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025434.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025434: RegExp lastIndex can exceed int range
+ *
+ * @test
+ * @run
+ */
+
+var r = /a/g;
+
+r.lastIndex = 0x100000000;
+if (r.test("a")) {
+    throw new Error("Expected no match");
+}
+
+r.lastIndex = 0x100000000000000;
+if (r.test("a")) {
+    throw new Error("Expected no match");
+}
+
+r.lastIndex = -0x100000000;
+if (r.test("a")) {
+    throw new Error("Expected match");
+}
+
+r.lastIndex = -0x100000000000000;
+if (r.test("a")) {
+    throw new Error("Expected no match");
+}
+
+r.lastIndex = 1;
+if (r.test("a")) {
+    throw new Error("Expected no match");
+}
+
+r.lastIndex = -1;
+if (r.test("a")) {
+    throw new Error("Expected no match");
+}
+
+r.lastIndex = 0;
+if (!r.test("a")) {
+    throw new Error("Expected match");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025486.js	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8025486: RegExp constructor arguments are not evaluated in right order
+ *
+ * @test
+ * @run
+ */
+
+new RegExp({
+    toString: function() {
+        print("source");
+        return "a";
+    }
+}, {
+    toString: function() {
+        print("flags");
+        return "g";
+    }
+});
+
+try {
+    new RegExp(/asdf/, {
+        toString: function() {
+            fail("toString should not be called");
+        }
+    });
+    fail("expected TypeError");
+} catch (e) {
+    if (!(e instanceof TypeError)) {
+        fail("expected TypeError");
+    }
+    print(e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8025486.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -0,0 +1,3 @@
+source
+flags
+TypeError: Cannot supply flags when constructing one RegExp from another
--- a/nashorn/test/script/basic/parser/objectLitExpr.js.EXPECTED	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/test/script/basic/parser/objectLitExpr.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
@@ -126,10 +126,7 @@
                             },
                             "value": {
                                 "type": "FunctionExpression",
-                                "id": {
-                                    "type": "Identifier",
-                                    "name": "get x"
-                                },
+                                "id": null,
                                 "params": [],
                                 "defaults": [],
                                 "rest": null,
@@ -157,10 +154,7 @@
                             },
                             "value": {
                                 "type": "FunctionExpression",
-                                "id": {
-                                    "type": "Identifier",
-                                    "name": "get y"
-                                },
+                                "id": null,
                                 "params": [],
                                 "defaults": [],
                                 "rest": null,
--- a/nashorn/test/script/trusted/JDK-8008305.js	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/test/script/trusted/JDK-8008305.js	Thu Sep 26 17:23:22 2013 -0700
@@ -54,6 +54,6 @@
     fail("Expected SecurityException from script!");
 } catch (e) {
     if (! (e instanceof SecurityException)) {
-        faile("Expected SecurityException, but got " + e);
+        fail("Expected SecurityException, but got " + e);
     }
 }
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu Sep 26 10:43:59 2013 -0700
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu Sep 26 17:23:22 2013 -0700
@@ -37,10 +37,12 @@
 import java.util.concurrent.Callable;
 import javax.script.Compilable;
 import javax.script.CompiledScript;
+import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineFactory;
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
 import org.testng.annotations.Test;
 
 /**
@@ -231,6 +233,17 @@
     }
 
     @Test
+    public void compileAndEvalInDiffContextTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine engine = m.getEngineByName("js");
+        final Compilable compilable = (Compilable) engine;
+        final CompiledScript compiledScript = compilable.compile("foo");
+        final ScriptContext ctxt = new SimpleScriptContext();
+        ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
+        assertEquals(compiledScript.eval(ctxt), "hello");
+    }
+
+    @Test
     public void accessGlobalTest() {
         final ScriptEngineManager m = new ScriptEngineManager();
         final ScriptEngine e = m.getEngineByName("nashorn");