Mercurial > hg > release > icedtea8-forest-3.0 > nashorn
changeset 1355:bf44ade6c2c2 jdk8u60-b16
Merge
author | lana |
---|---|
date | Thu, 14 May 2015 20:13:03 -0700 |
parents | 2caf11badeef (current diff) 201b37681668 (diff) |
children | ff7052ce0f6b 55c1eef5c4fc |
files | src/jdk/nashorn/internal/codegen/Emitter.java |
diffstat | 56 files changed, 1999 insertions(+), 257 deletions(-) [+] |
line wrap: on
line diff
--- a/make/build.xml Wed May 13 12:50:12 2015 -0700 +++ b/make/build.xml Thu May 14 20:13:03 2015 -0700 @@ -189,7 +189,7 @@ <mkdir dir="${fxshell.classes.dir}"/> <javac srcdir="${fxshell.dir}" destdir="${fxshell.classes.dir}" - classpath="${dist.jar}:${javac.classpath}" + classpath="${dist.jar}${path.separator}${javac.classpath}" debug="${javac.debug}" encoding="${javac.encoding}" includeantruntime="false">
--- a/make/project.properties Wed May 13 12:50:12 2015 -0700 +++ b/make/project.properties Thu May 14 20:13:03 2015 -0700 @@ -105,8 +105,8 @@ javac.classpath=\ ${build.classes.dir} javac.test.classpath=\ - ${build.classes.dir}:\ - ${build.test.classes.dir}:\ + ${build.classes.dir}${path.separator}\ + ${build.test.classes.dir}${path.separator}\ ${file.reference.testng.jar} meta.inf.dir=${src.dir}/META-INF @@ -253,8 +253,8 @@ testjfx-test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${testjfx.run.test.classpath} run.test.classpath=\ - ${file.reference.testng.jar}:\ - ${nashorn.internal.tests.jar}:\ + ${file.reference.testng.jar}${path.separator}\ + ${nashorn.internal.tests.jar}${path.separator}\ ${nashorn.api.tests.jar} src.dir=src @@ -330,6 +330,8 @@ # VM options for script tests with @fork option test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath} +# VM options for no-security script tests with @fork option - same as above but without jvmsecurityargs +test-sys-prop-no-security.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${run.test.classpath} # path of rhino.jar for benchmarks rhino.dir=
--- a/samples/browser_dom.js Wed May 13 12:50:12 2015 -0700 +++ b/samples/browser_dom.js Thu May 14 20:13:03 2015 -0700 @@ -1,4 +1,4 @@ -#// Usage: jjs -fx browser.js +#// Usage: jjs -fx browser_dom.js /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. @@ -32,7 +32,7 @@ */ if (!$OPTIONS._fx) { - print("Usage: jjs -fx browser.js"); + print("Usage: jjs -fx browser_dom.js"); exit(1); } @@ -74,10 +74,10 @@ var btn = document.createElement("button"); var n = 0; // attach a button handler - nashorn function! - btn.onclick = new EventListener(function() { + btn.onclick = function() { n++; print("You clicked " + n + " time(s)"); print("you clicked OK " + wv.engine.executeScript("okCount")); - }); + }; // attach text to button var t = document.createTextNode("Click Me!"); btn.appendChild(t);
--- a/src/jdk/nashorn/internal/codegen/AssignSymbols.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/AssignSymbols.java Thu May 14 20:13:03 2015 -0700 @@ -135,15 +135,11 @@ functionNode.compilerConstant(SCOPE).setNeedsSlot(false); } // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol. - if(!functionNode.isDeclared() && !functionNode.usesSelfSymbol() && !functionNode.isAnonymous()) { + if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) { final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName()); - if(selfSymbol != null) { - if(selfSymbol.isFunctionSelf()) { - selfSymbol.setNeedsSlot(false); - selfSymbol.clearFlag(Symbol.IS_VAR); - } - } else { - assert functionNode.isProgram(); + if(selfSymbol != null && selfSymbol.isFunctionSelf()) { + selfSymbol.setNeedsSlot(false); + selfSymbol.clearFlag(Symbol.IS_VAR); } } return functionNode; @@ -490,20 +486,31 @@ final Block body = lc.getCurrentBlock(); initFunctionWideVariables(functionNode, body); + acceptDeclarations(functionNode, body); + defineFunctionSelfSymbol(functionNode, body); + } - if (!functionNode.isProgram() && !functionNode.isDeclared() && !functionNode.isAnonymous()) { - // It's neither declared nor program - it's a function expression then; assign it a self-symbol unless it's - // anonymous. - final String name = functionNode.getIdent().getName(); - assert name != null; - assert body.getExistingSymbol(name) == null; - defineSymbol(body, name, functionNode, IS_VAR | IS_FUNCTION_SELF | HAS_OBJECT_VALUE); - if(functionNode.allVarsInScope()) { // basically, has deep eval - lc.setFlag(functionNode, FunctionNode.USES_SELF_SYMBOL); - } + private void defineFunctionSelfSymbol(final FunctionNode functionNode, final Block body) { + // Function self-symbol is only declared as a local variable for named function expressions. Declared functions + // don't need it as they are local variables in their declaring scope. + if (!functionNode.isNamedFunctionExpression()) { + return; } - acceptDeclarations(functionNode, body); + final String name = functionNode.getIdent().getName(); + assert name != null; // As it's a named function expression. + + if (body.getExistingSymbol(name) != null) { + // Body already has a declaration for the name. It's either a parameter "function x(x)" or a + // top-level variable "function x() { ... var x; ... }". + return; + } + + defineSymbol(body, name, functionNode, IS_VAR | IS_FUNCTION_SELF | HAS_OBJECT_VALUE); + if(functionNode.allVarsInScope()) { // basically, has deep eval + // We must conservatively presume that eval'd code can dynamically use the function symbol. + lc.setFlag(functionNode, FunctionNode.USES_SELF_SYMBOL); + } } @Override
--- a/src/jdk/nashorn/internal/codegen/BranchOptimizer.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/BranchOptimizer.java Thu May 14 20:13:03 2015 -0700 @@ -31,6 +31,7 @@ import static jdk.nashorn.internal.codegen.Condition.LE; import static jdk.nashorn.internal.codegen.Condition.LT; import static jdk.nashorn.internal.codegen.Condition.NE; +import static jdk.nashorn.internal.parser.TokenType.NOT; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Expression; @@ -57,21 +58,11 @@ } private void branchOptimizer(final UnaryNode unaryNode, final Label label, final boolean state) { - final Expression rhs = unaryNode.getExpression(); - - switch (unaryNode.tokenType()) { - case NOT: - branchOptimizer(rhs, label, !state); - return; - default: - if (unaryNode.getType().isBoolean()) { - branchOptimizer(rhs, label, state); - return; - } - break; + if (unaryNode.isTokenType(NOT)) { + branchOptimizer(unaryNode.getExpression(), label, !state); + } else { + loadTestAndJump(unaryNode, label, state); } - - loadTestAndJump(unaryNode, label, state); } private void branchOptimizer(final BinaryNode binaryNode, final Label label, final boolean state) {
--- a/src/jdk/nashorn/internal/codegen/ClassEmitter.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/ClassEmitter.java Thu May 14 20:13:03 2015 -0700 @@ -101,13 +101,10 @@ * bytecodes that have been written. This is enabled by setting the * environment "nashorn.codegen.debug" to true, or --log=codegen:{@literal <level>} * <p> - * A ClassEmitter implements an Emitter - i.e. it needs to have - * well defined start and end calls for whatever it is generating. Assertions - * detect if this is not true * * @see Compiler */ -public class ClassEmitter implements Emitter { +public class ClassEmitter { /** Default flags for class generation - public class */ private static final EnumSet<Flag> DEFAULT_METHOD_FLAGS = EnumSet.of(Flag.PUBLIC); @@ -397,18 +394,14 @@ /** * Call at beginning of class emission - * @see Emitter */ - @Override public void begin() { classStarted = true; } /** * Call at end of class emission - * @see Emitter */ - @Override public void end() { assert classStarted : "class not started for " + unitClassName;
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Thu May 14 20:13:03 2015 -0700 @@ -174,8 +174,7 @@ * This quickly became apparent when the code generator was generalized to work * with all types, and not just numbers or objects. * <p> - * The CodeGenerator visits nodes only once, tags them as resolved and emits - * bytecode for them. + * The CodeGenerator visits nodes only once and emits bytecode for them. */ @Logger(name="codegen") final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContext> implements Loggable { @@ -1275,7 +1274,7 @@ return true; } - private boolean useOptimisticTypes() { + boolean useOptimisticTypes() { return !lc.inSplitNode() && compiler.useOptimisticTypes(); } @@ -1714,11 +1713,7 @@ @Override public boolean enterEmptyNode(final EmptyNode emptyNode) { - if(!method.isReachable()) { - return false; - } - enterStatement(emptyNode); - + // Don't even record the line number, it's irrelevant as there's no code. return false; } @@ -2647,8 +2642,6 @@ } enterStatement(returnNode); - method.registerReturn(); - final Type returnType = lc.getCurrentFunction().getReturnType(); final Expression expression = returnNode.getExpression();
--- a/src/jdk/nashorn/internal/codegen/Emitter.java Wed May 13 12:50:12 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package jdk.nashorn.internal.codegen; - -/** - * Interface for anything that interacts with a low level bytecode - * generation module, for example ASM. - * <p> - * This is pretty generic, i.e. it can be a ClassEmitter, MethodEmitter - * or potentially even more fine grained stuff. - * - */ -public interface Emitter { - - /** - * Register the start of emission for this CodeEmitter - */ - public void begin(); - - /** - * Register the end of emission for this CodeEmitter. - * This is typically required before generated code can - * be requested from it - */ - public void end(); -}
--- a/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java Thu May 14 20:13:03 2015 -0700 @@ -127,6 +127,8 @@ method.invoke(constructorNoLookup(className, PropertyMap.class)); } + helpOptimisticRecognizeDuplicateIdentity(method); + // Set values. final Iterator<MapTuple<T>> iter = tuples.iterator(); @@ -136,6 +138,7 @@ //if we didn't load, we need an array property if (tuple.symbol != null && tuple.value != null) { final int index = getArrayIndex(tuple.key); + method.dup(); if (!isValidArrayIndex(index)) { putField(method, tuple.key, tuple.symbol.getFieldIndex(), tuple); } else { @@ -164,8 +167,6 @@ * @param tuple Tuple to store. */ private void putField(final MethodEmitter method, final String key, final int fieldIndex, final MapTuple<T> tuple) { - method.dup(); - final Type fieldType = codegen.useDualFields() && tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT; final String fieldClass = getClassName(); final String fieldName = getFieldName(fieldIndex, fieldType); @@ -187,7 +188,6 @@ * @param tuple Tuple to store. */ private void putSlot(final MethodEmitter method, final long index, final MapTuple<T> tuple) { - method.dup(); if (JSType.isRepresentableAsInt(index)) { method.load((int)index); } else {
--- a/src/jdk/nashorn/internal/codegen/Label.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/Label.java Thu May 14 20:13:03 2015 -0700 @@ -333,7 +333,7 @@ * @param slot the slot written to * @param onlySymbolLiveValue if true, this is the symbol's only live value, and other values of the symbol * should be marked dead - * @param Type the type written to the slot + * @param type the type written to the slot */ void onLocalStore(final Type type, final int slot, final boolean onlySymbolLiveValue) { if(onlySymbolLiveValue) {
--- a/src/jdk/nashorn/internal/codegen/MethodEmitter.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/MethodEmitter.java Thu May 14 20:13:03 2015 -0700 @@ -124,7 +124,7 @@ * all generated bytecode and labels to stderr, for easier debugging, * including bytecode stack contents */ -public class MethodEmitter implements Emitter { +public class MethodEmitter { /** The ASM MethodVisitor we are plugged into */ private final MethodVisitor method; @@ -137,9 +137,6 @@ /** Current type stack for current evaluation */ private Label.Stack stack; - /** Check whether this emitter ever has a function return point */ - private boolean hasReturn; - private boolean preventUndefinedLoad; /** @@ -208,9 +205,7 @@ /** * Begin a method - * @see Emitter */ - @Override public void begin() { classEmitter.beginMethod(this); newStack(); @@ -219,9 +214,7 @@ /** * End a method - * @see Emitter */ - @Override public void end() { method.visitMaxs(0, 0); method.visitEnd(); @@ -1588,7 +1581,7 @@ /** * Abstraction for performing a conditional jump of any type * - * @see MethodEmitter.Condition + * @see Condition * * @param cond the condition to test * @param trueLabel the destination label is condition is true @@ -1616,15 +1609,6 @@ } } - MethodEmitter registerReturn() { - setHasReturn(); - return this; - } - - void setHasReturn() { - this.hasReturn = true; - } - /** * Perform a non void return, popping the type from the stack * @@ -2195,6 +2179,10 @@ * @return the method emitter */ MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod, final boolean isIndex) { + if (name.length() > LARGE_STRING_THRESHOLD) { // use getIndex for extremely long names + return load(name).dynamicGetIndex(valueType, flags, isMethod); + } + debug("dynamic_get", name, valueType, getProgramPoint(flags)); Type type = valueType; @@ -2220,8 +2208,13 @@ * @param isIndex is this an index operation? */ void dynamicSet(final String name, final int flags, final boolean isIndex) { - assert !isOptimistic(flags); - debug("dynamic_set", name, peekType()); + if (name.length() > LARGE_STRING_THRESHOLD) { // use setIndex for extremely long names + load(name).swap().dynamicSetIndex(flags); + return; + } + + assert !isOptimistic(flags); + debug("dynamic_set", name, peekType()); Type type = peekType(); if (type.isObject() || type.isBoolean()) { //promote strings to objects etc @@ -2716,10 +2709,6 @@ this.functionNode = functionNode; } - boolean hasReturn() { - return hasReturn; - } - /** * Invoke to enforce assertions preventing load from a local variable slot that's known to not have been written to. * Used by CodeGenerator, as it strictly enforces tracking of stores. Simpler uses of MethodEmitter, e.g. those
--- a/src/jdk/nashorn/internal/codegen/Namespace.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/Namespace.java Thu May 14 20:13:03 2015 -0700 @@ -25,6 +25,8 @@ package jdk.nashorn.internal.codegen; +import static jdk.nashorn.internal.codegen.MethodEmitter.LARGE_STRING_THRESHOLD; + import java.util.HashMap; /** @@ -66,27 +68,28 @@ } /** - * Create a uniqueName name in the namespace in the form base$n where n varies - * . + * Create a uniqueName name in the namespace in the form base$n where n varies. + * Also truncates very long names that would otherwise break ASM. + * * @param base Base of name. Base will be returned if uniqueName. - * * @return Generated uniqueName name. */ public String uniqueName(final String base) { + final String truncatedBase = base.length() > LARGE_STRING_THRESHOLD ? base.substring(0, LARGE_STRING_THRESHOLD) : base; for (Namespace namespace = this; namespace != null; namespace = namespace.getParent()) { final HashMap<String, Integer> namespaceDirectory = namespace.directory; - final Integer counter = namespaceDirectory.get(base); + final Integer counter = namespaceDirectory.get(truncatedBase); if (counter != null) { final int count = counter + 1; - namespaceDirectory.put(base, count); - return base + '-' + count; + namespaceDirectory.put(truncatedBase, count); + return truncatedBase + '-' + count; } } - directory.put(base, 0); + directory.put(truncatedBase, 0); - return base; + return truncatedBase; } @Override
--- a/src/jdk/nashorn/internal/codegen/ObjectCreator.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/ObjectCreator.java Thu May 14 20:13:03 2015 -0700 @@ -146,4 +146,28 @@ return loadTuple(method, tuple, true); } + /** + * If using optimistic typing, let the code generator realize that the newly created object on the stack + * when DUP-ed will be the same value. Basically: {NEW, DUP, INVOKESPECIAL init, DUP} will leave a stack + * load specification {unknown, unknown} on stack (that is "there's two values on the stack, but neither + * comes from a known local load"). If there's an optimistic operation in the literal initializer, + * OptimisticOperation.storeStack will allocate two temporary locals for it and store them as + * {ASTORE 4, ASTORE 3}. If we instead do {NEW, DUP, INVOKESPECIAL init, ASTORE 3, ALOAD 3, DUP} we end up + * with stack load specification {ALOAD 3, ALOAD 3} (as DUP can track that the value it duplicated came + * from a local load), so if/when a continuation needs to be recreated from it, it'll be + * able to emit ALOAD 3, ALOAD 3 to recreate the stack. If we didn't do this, deoptimization within an + * object literal initialization could in rare cases cause an incompatible change in the shape of the + * local variable table for the temporaries, e.g. in the following snippet where a variable is reassigned + * to a wider type in an object initializer: + * <code>var m = 1; var obj = {p0: m, p1: m = "foo", p2: m}</code> + * @param method the current method emitter. + */ + void helpOptimisticRecognizeDuplicateIdentity(final MethodEmitter method) { + if (codegen.useOptimisticTypes()) { + final Type objectType = method.peekType(); + final int tempSlot = method.defineTemporaryLocalVariable(objectType.getSlots()); + method.storeHidden(objectType, tempSlot); + method.load(objectType, tempSlot); + } + } }
--- a/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java Thu May 14 20:13:03 2015 -0700 @@ -130,45 +130,24 @@ pos++; } - //assert postsetValues.isEmpty() : "test me " + postsetValues; - // create object and invoke constructor method._new(objectClass).dup(); codegen.loadConstant(propertyMap); - //load primitive values to j spill array + // load primitive value spill array if (dualFields) { codegen.loadConstant(jpresetValues); - for (final int i : postsetValues) { - final MapTuple<Expression> tuple = tuples.get(i); - final Property property = propertyMap.findProperty(tuple.key); - if (property != null && tuple.isPrimitive()) { - method.dup(); - method.load(property.getSlot()); - loadTuple(method, tuple); - method.arraystore(); - } - } } else { method.loadNull(); } - - //load object values to o spill array + // load object value spill array codegen.loadConstant(opresetValues); - for (final int i : postsetValues) { - final MapTuple<Expression> tuple = tuples.get(i); - final Property property = propertyMap.findProperty(tuple.key); - if (property != null && (!dualFields || !tuple.isPrimitive())) { - method.dup(); - method.load(property.getSlot()); - loadTuple(method, tuple); - method.arraystore(); - } - } - //instantiate the script object with spill objects + // instantiate the script object with spill objects method.invoke(constructorNoLookup(objectClass, PropertyMap.class, long[].class, Object[].class)); + helpOptimisticRecognizeDuplicateIdentity(method); + // Set prefix array data if any if (arrayData.length() > 0) { method.dup(); @@ -176,7 +155,7 @@ method.invoke(virtualCallNoLookup(ScriptObject.class, "setArray", void.class, ArrayData.class)); } - // set postfix + // set postfix values for (final int i : postsetValues) { final MapTuple<Expression> tuple = tuples.get(i); final Property property = propertyMap.findProperty(tuple.key); @@ -188,6 +167,10 @@ //method.println("putting " + tuple + " into arraydata"); loadTuple(method, tuple); method.dynamicSetIndex(callSiteFlags); + } else { + method.dup(); + loadTuple(method, tuple); + method.dynamicSet(property.getKey(), codegen.getCallSiteFlags(), false); } } }
--- a/src/jdk/nashorn/internal/ir/FunctionNode.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/ir/FunctionNode.java Thu May 14 20:13:03 2015 -0700 @@ -1141,6 +1141,15 @@ return getFlag(USES_SELF_SYMBOL); } + /** + * Returns true if this is a named function expression (that is, it isn't a declared function, it isn't an + * anonymous function expression, and it isn't a program). + * @return true if this is a named function expression + */ + public boolean isNamedFunctionExpression() { + return !getFlag(IS_PROGRAM | IS_ANONYMOUS | IS_DECLARED); + } + @Override public Type getType() { return FUNCTION_TYPE;
--- a/src/jdk/nashorn/internal/objects/NativeArray.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Thu May 14 20:13:03 2015 -0700 @@ -272,7 +272,7 @@ final PropertyDescriptor newLenDesc = desc; // Step 3c and 3d - get new length and convert to long - final long newLen = NativeArray.validLength(newLenDesc.getValue(), true); + final long newLen = NativeArray.validLength(newLenDesc.getValue()); // Step 3e newLenDesc.setValue(newLen); @@ -345,8 +345,8 @@ final PropertyDescriptor oldLenDesc = (PropertyDescriptor) super.getOwnPropertyDescriptor("length"); // Step 2 - // get old length and convert to long - final long oldLen = NativeArray.validLength(oldLenDesc.getValue(), true); + // get old length and convert to long. Always a Long/Uint32 but we take the safe road. + final long oldLen = JSType.toUint32(oldLenDesc.getValue()); // Step 3 if ("length".equals(key)) { @@ -468,7 +468,7 @@ @Setter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE) public static void length(final Object self, final Object length) { if (isArray(self)) { - ((ScriptObject)self).setLength(validLength(length, true)); + ((ScriptObject)self).setLength(validLength(length)); } } @@ -492,18 +492,13 @@ length(self, length); // Same as instance setter but we can't make nasgen use the same method for prototype } - static long validLength(final Object length, final boolean reject) { + static long validLength(final Object length) { + // ES5 15.4.5.1, steps 3.c and 3.d require two ToNumber conversions here final double doubleLength = JSType.toNumber(length); - if (!Double.isNaN(doubleLength) && JSType.isRepresentableAsLong(doubleLength)) { - final long len = (long) doubleLength; - if (len >= 0 && len <= JSType.MAX_UINT) { - return len; - } - } - if (reject) { + if (doubleLength != JSType.toUint32(length)) { throw rangeError("inappropriate.array.length", ScriptRuntime.safeToString(length)); } - return -1; + return (long) doubleLength; } /** @@ -1233,31 +1228,41 @@ final List<Object> list = Arrays.asList(array); final Object cmpThis = cmp == null || cmp.isStrict() ? ScriptRuntime.UNDEFINED : Global.instance(); - Collections.sort(list, new Comparator<Object>() { - private final MethodHandle call_cmp = getCALL_CMP(); - @Override - public int compare(final Object x, final Object y) { - if (x == ScriptRuntime.UNDEFINED && y == ScriptRuntime.UNDEFINED) { - return 0; - } else if (x == ScriptRuntime.UNDEFINED) { - return 1; - } else if (y == ScriptRuntime.UNDEFINED) { - return -1; - } + try { + Collections.sort(list, new Comparator<Object>() { + private final MethodHandle call_cmp = getCALL_CMP(); + @Override + public int compare(final Object x, final Object y) { + if (x == ScriptRuntime.UNDEFINED && y == ScriptRuntime.UNDEFINED) { + return 0; + } else if (x == ScriptRuntime.UNDEFINED) { + return 1; + } else if (y == ScriptRuntime.UNDEFINED) { + return -1; + } - if (cmp != null) { - try { - return (int)Math.signum((double)call_cmp.invokeExact(cmp, cmpThis, x, y)); - } catch (final RuntimeException | Error e) { - throw e; - } catch (final Throwable t) { - throw new RuntimeException(t); + if (cmp != null) { + try { + return (int)Math.signum((double)call_cmp.invokeExact(cmp, cmpThis, x, y)); + } catch (final RuntimeException | Error e) { + throw e; + } catch (final Throwable t) { + throw new RuntimeException(t); + } } - } - return JSType.toString(x).compareTo(JSType.toString(y)); - } - }); + return JSType.toString(x).compareTo(JSType.toString(y)); + } + }); + } catch (final IllegalArgumentException iae) { + // Collections.sort throws IllegalArgumentException when + // Comparison method violates its general contract + + // See ECMA spec 15.4.4.11 Array.prototype.sort (comparefn). + // If "comparefn" is not undefined and is not a consistent + // comparison function for the elements of this array, the + // behaviour of sort is implementation-defined. + } return list.toArray(new Object[array.length]); }
--- a/src/jdk/nashorn/internal/objects/NativeObject.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/objects/NativeObject.java Thu May 14 20:13:03 2015 -0700 @@ -499,7 +499,7 @@ final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); - final ScriptObject sobj = (ScriptObject)self; + final ScriptObject sobj = (ScriptObject)obj; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj);
--- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Thu May 14 20:13:03 2015 -0700 @@ -88,7 +88,7 @@ @Setter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE) public static void length(final Object self, final Object length) { if (self instanceof ScriptObject) { - ((ScriptObject)self).setLength(NativeArray.validLength(length, true)); + ((ScriptObject)self).setLength(NativeArray.validLength(length)); } } }
--- a/src/jdk/nashorn/internal/runtime/CodeStore.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/CodeStore.java Thu May 14 20:13:03 2015 -0700 @@ -189,7 +189,7 @@ * @param paramTypes parameter types * @return a string representing the function */ - public static String getCacheKey(final int functionId, final Type[] paramTypes) { + public static String getCacheKey(final Object functionId, final Type[] paramTypes) { final StringBuilder b = new StringBuilder().append(functionId); if(paramTypes != null && paramTypes.length > 0) { b.append('-'); @@ -275,7 +275,7 @@ @Override public StoredScript load(final Source source, final String functionKey) { - if (source.getLength() < minSize) { + if (belowThreshold(source)) { return null; }
--- a/src/jdk/nashorn/internal/runtime/Context.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/Context.java Thu May 14 20:13:03 2015 -0700 @@ -737,7 +737,7 @@ final ScriptFunction func = getProgramFunction(clazz, scope); Object evalThis; if (directEval) { - evalThis = callThis instanceof ScriptObject || strictFlag ? callThis : global; + evalThis = (callThis != UNDEFINED && callThis != null) || strictFlag ? callThis : global; } else { evalThis = global; } @@ -1228,16 +1228,21 @@ StoredScript storedScript = null; FunctionNode functionNode = null; - // We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation - // just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData. - final boolean useCodeStore = codeStore != null && !env._parse_only && !env._optimistic_types; - final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null; + // Don't use code store if optimistic types is enabled but lazy compilation is not. + // This would store a full script compilation with many wrong optimistic assumptions that would + // do more harm than good on later runs with both optimistic types and lazy compilation enabled. + final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation); + final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null; if (useCodeStore) { storedScript = codeStore.load(source, cacheKey); } if (storedScript == null) { + if (env._dest_dir != null) { + source.dump(env._dest_dir); + } + functionNode = new Parser(env, source, errMan, strict, getLogger(Parser.class)).parse(); if (errMan.hasErrors()) {
--- a/src/jdk/nashorn/internal/runtime/ErrorManager.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/ErrorManager.java Thu May 14 20:13:03 2015 -0700 @@ -113,7 +113,7 @@ // Pointer to column. for (int i = 0; i < column; i++) { - if (sourceLine.charAt(i) == '\t') { + if (i < sourceLine.length() && sourceLine.charAt(i) == '\t') { sb.append('\t'); } else { sb.append(' ');
--- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Thu May 14 20:13:03 2015 -0700 @@ -491,7 +491,7 @@ log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType); } - final boolean persistentCache = usePersistentCodeCache() && persist; + final boolean persistentCache = persist && usePersistentCodeCache(); String cacheKey = null; if (persistentCache) { final TypeMap typeMap = typeMap(actualCallSiteType); @@ -518,8 +518,7 @@ } boolean usePersistentCodeCache() { - final ScriptEnvironment env = installer.getOwner(); - return env._persistent_cache && env._optimistic_types; + return installer != null && installer.getOwner()._persistent_cache; } private MethodType explicitParams(final MethodType callSiteType) {
--- a/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java Thu May 14 20:13:03 2015 -0700 @@ -73,7 +73,7 @@ /** Generate line number table in class files */ public final boolean _debug_lines; - /** Package to which generated class files are added */ + /** Directory in which source files and generated class files are dumped */ public final String _dest_dir; /** Display stack trace upon error, default is false */
--- a/src/jdk/nashorn/internal/runtime/Source.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/Source.java Thu May 14 20:13:03 2015 -0700 @@ -28,9 +28,11 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOError; import java.io.IOException; import java.io.InputStream; +import java.io.PrintWriter; import java.io.Reader; import java.lang.ref.WeakReference; import java.net.MalformedURLException; @@ -44,6 +46,7 @@ import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.time.LocalDateTime; import java.util.Arrays; import java.util.Base64; import java.util.Objects; @@ -965,4 +968,39 @@ public DebugLogger getLogger() { return initLogger(Context.getContextTrusted()); } + + private File dumpFile(final String dir) { + final URL u = getURL(); + final StringBuilder buf = new StringBuilder(); + // make it unique by prefixing current date & time + buf.append(LocalDateTime.now().toString()); + buf.append('_'); + if (u != null) { + // make it a safe file name + buf.append(u.toString() + .replace('/', '_') + .replace('\\', '_')); + } else { + buf.append(getName()); + } + + return new File(dir, buf.toString()); + } + + void dump(final String dir) { + final File file = dumpFile(dir); + try (final FileOutputStream fos = new FileOutputStream(file)) { + final PrintWriter pw = new PrintWriter(fos); + pw.print(data.toString()); + pw.flush(); + } catch (final IOException ioExp) { + debug("Skipping source dump for " + + name + + ": " + + ECMAErrors.getMessage( + "io.error.cant.write", + dir.toString() + + " : " + ioExp.toString())); + } + } }
--- a/src/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java Thu May 14 20:13:03 2015 -0700 @@ -112,20 +112,21 @@ private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception { final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); final int c = desc.getNameTokenCount(); + GuardedInvocation inv; + try { + inv = nashornBeansLinker.getGuardedInvocation(request, linkerServices); + } catch (Throwable th) { + inv = null; + } switch (operator) { case "getProp": case "getElem": case "getMethod": - if (c > 2) { - return findGetMethod(desc); - } - // For indexed get, we want GuardedInvocation from beans linker and pass it. - // BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access. - return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices)); + return c > 2? findGetMethod(desc, inv) : findGetIndexMethod(inv); case "setProp": case "setElem": - return c > 2 ? findSetMethod(desc) : findSetIndexMethod(); + return c > 2? findSetMethod(desc, inv) : findSetIndexMethod(); case "call": return findCallMethod(desc); default: @@ -133,7 +134,10 @@ } } - private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) { + private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) { + if (inv != null) { + return inv; + } final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name); return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); @@ -144,7 +148,10 @@ return inv.replaceMethods(getter, inv.getGuard()); } - private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc) { + private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) { + if (inv != null) { + return inv; + } final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, desc.getNameToken(2)); return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); }
--- a/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Thu May 14 20:13:03 2015 -0700 @@ -86,6 +86,9 @@ final String operator = desc.getFirstOperator(); switch (operator) { case "new": + if(BeansLinker.isDynamicConstructor(self)) { + throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self)); + } if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); }
--- a/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java Thu May 14 20:13:03 2015 -0700 @@ -26,17 +26,23 @@ package jdk.nashorn.internal.runtime.linker; import static jdk.nashorn.internal.lookup.Lookup.MH; +import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; + import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.invoke.SwitchPoint; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; +import jdk.internal.dynalink.support.CallSiteDescriptorFactory; import jdk.internal.dynalink.support.Guards; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.FindProperty; import jdk.nashorn.internal.runtime.GlobalConstants; +import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; +import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.UserAccessorProperty; /** @@ -46,6 +52,11 @@ */ public final class PrimitiveLookup { + /** Method handle to link setters on primitive base. See ES5 8.7.2. */ + private static final MethodHandle PRIMITIVE_SETTER = findOwnMH("primitiveSetter", + MH.type(void.class, ScriptObject.class, Object.class, Object.class, boolean.class, Object.class)); + + private PrimitiveLookup() { } @@ -87,40 +98,58 @@ final ScriptObject wrappedReceiver, final MethodHandle wrapFilter, final MethodHandle protoFilter) { final CallSiteDescriptor desc = request.getCallSiteDescriptor(); + final String name; + final FindProperty find; - //checks whether the property name is hard-coded in the call-site (i.e. a getProp vs a getElem, or setProp vs setElem) - //if it is we can make assumptions on the property: that if it is not defined on primitive wrapper itself it never will be. - //so in that case we can skip creation of primitive wrapper and start our search with the prototype. if (desc.getNameTokenCount() > 2) { - final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); - final FindProperty find = wrappedReceiver.findProperty(name, true); + name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); + find = wrappedReceiver.findProperty(name, true); + } else { + name = null; + find = null; + } - if (find == null) { - // Give up early, give chance to BeanLinker and NashornBottomLinker to deal with it. - return null; - } + final String firstOp = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); - final SwitchPoint sp = find.getProperty().getBuiltinSwitchPoint(); //can use this instead of proto filter - if (sp instanceof Context.BuiltinSwitchPoint && !sp.hasBeenInvalidated()) { - return new GuardedInvocation(GlobalConstants.staticConstantGetter(find.getObjectValue()), guard, sp, null); - } + switch (firstOp) { + case "getProp": + case "getElem": + case "getMethod": + //checks whether the property name is hard-coded in the call-site (i.e. a getProp vs a getElem, or setProp vs setElem) + //if it is we can make assumptions on the property: that if it is not defined on primitive wrapper itself it never will be. + //so in that case we can skip creation of primitive wrapper and start our search with the prototype. + if (name != null) { + if (find == null) { + // Give up early, give chance to BeanLinker and NashornBottomLinker to deal with it. + return null; + } - if (find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { - // If property is found in the prototype object bind the method handle directly to - // the proto filter instead of going through wrapper instantiation below. - final ScriptObject proto = wrappedReceiver.getProto(); - final GuardedInvocation link = proto.lookup(desc, request); + final SwitchPoint sp = find.getProperty().getBuiltinSwitchPoint(); //can use this instead of proto filter + if (sp instanceof Context.BuiltinSwitchPoint && !sp.hasBeenInvalidated()) { + return new GuardedInvocation(GlobalConstants.staticConstantGetter(find.getObjectValue()), guard, sp, null); + } - if (link != null) { - final MethodHandle invocation = link.getInvocation(); //this contains the builtin switchpoint + if (find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { + // If property is found in the prototype object bind the method handle directly to + // the proto filter instead of going through wrapper instantiation below. + final ScriptObject proto = wrappedReceiver.getProto(); + final GuardedInvocation link = proto.lookup(desc, request); - final MethodHandle adaptedInvocation = MH.asType(invocation, invocation.type().changeParameterType(0, Object.class)); - final MethodHandle method = MH.filterArguments(adaptedInvocation, 0, protoFilter); - final MethodHandle protoGuard = MH.filterArguments(link.getGuard(), 0, protoFilter); - - return new GuardedInvocation(method, NashornGuards.combineGuards(guard, protoGuard)); + if (link != null) { + final MethodHandle invocation = link.getInvocation(); //this contains the builtin switchpoint + final MethodHandle adaptedInvocation = MH.asType(invocation, invocation.type().changeParameterType(0, Object.class)); + final MethodHandle method = MH.filterArguments(adaptedInvocation, 0, protoFilter); + final MethodHandle protoGuard = MH.filterArguments(link.getGuard(), 0, protoFilter); + return new GuardedInvocation(method, NashornGuards.combineGuards(guard, protoGuard)); + } } } + break; + case "setProp": + case "setElem": + return getPrimitiveSetter(name, guard, wrapFilter, NashornCallSiteDescriptor.isStrict(desc)); + default: + break; } final GuardedInvocation link = wrappedReceiver.lookup(desc, request); @@ -138,4 +167,41 @@ return null; } + + private static GuardedInvocation getPrimitiveSetter(final String name, final MethodHandle guard, + final MethodHandle wrapFilter, final boolean isStrict) { + MethodHandle filter = MH.asType(wrapFilter, wrapFilter.type().changeReturnType(ScriptObject.class)); + final MethodHandle target; + + if (name == null) { + filter = MH.dropArguments(filter, 1, Object.class, Object.class); + target = MH.insertArguments(PRIMITIVE_SETTER, 3, isStrict); + } else { + filter = MH.dropArguments(filter, 1, Object.class); + target = MH.insertArguments(PRIMITIVE_SETTER, 2, name, isStrict); + } + + return new GuardedInvocation(MH.foldArguments(target, filter), guard); + } + + + @SuppressWarnings("unused") + private static void primitiveSetter(final ScriptObject wrappedSelf, final Object self, final Object key, + final boolean strict, final Object value) { + // See ES5.1 8.7.2 PutValue (V, W) + final String name = JSType.toString(key); + final FindProperty find = wrappedSelf.findProperty(name, true); + if (find == null || !(find.getProperty() instanceof UserAccessorProperty) || !find.getProperty().isWritable()) { + if (strict) { + throw typeError("property.not.writable", name, ScriptRuntime.safeToString(self)); + } + return; + } + // property found and is a UserAccessorProperty + find.setValue(value, strict); + } + + private static MethodHandle findOwnMH(final String name, final MethodType type) { + return MH.findStatic(MethodHandles.lookup(), PrimitiveLookup.class, name, type); + } }
--- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties Thu May 14 20:13:03 2015 -0700 @@ -144,6 +144,7 @@ type.error.extend.ERROR_OTHER=Can not extend/implement {0} because of {1} type.error.no.constructor.matches.args=Can not construct {0} with the passed arguments; they do not match any of its constructor signatures. type.error.no.method.matches.args=Can not invoke method {0} with the passed arguments; they do not match any of its method signatures. +type.error.no.constructor.matches.args=Can not create new object with constructor {0} with the passed arguments; they do not match any of its method signatures. type.error.method.not.constructor=Java method {0} cannot be used as a constructor. type.error.env.not.object=$ENV must be an Object. type.error.unsupported.java.to.type=Unsupported Java.to target type {0}.
--- a/src/jdk/nashorn/internal/runtime/resources/Options.properties Wed May 13 12:50:12 2015 -0700 +++ b/src/jdk/nashorn/internal/runtime/resources/Options.properties Thu May 14 20:13:03 2015 -0700 @@ -114,7 +114,7 @@ short_name="-d", \ is_undocumented=true, \ params="<path>", \ - desc="specify a destination directory to dump class files.", \ + desc="specify a destination directory to dump source and class files.", \ type=String \ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8047365.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010, 2014, 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-8047365: Very long function names break codegen + * + * @test + * @run + */ + +// string of length 131071, twice the limit of UTF8 strings in ASM +var longId = Array(0x20000).join("a"); +print(longId.length); + +eval("function " + longId + "(){ print('hello world'); }"); +eval("print(typeof " + longId + ")"); +eval("print(" + longId + ".name === longId)"); +eval("print(/a+/.exec(" + longId + ".toString())[0] === longId)"); +eval(longId + "()");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8047365.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,5 @@ +131071 +function +true +true +hello world
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066214.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014, 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-8066214: Fuzzing bug: Object.prototype.toLocaleString(0) + * + * @test + * @run + */ + +function test(func) { + print(func.call(0)); + print(func.call("abc")); + print(func.call(true)); + try { + print(func.call(undefined)); + } catch (e) { + print(e); + } + try { + print(func.call(null)); + } catch (e) { + print(e); + } +} + +test(Object.prototype.toLocaleString); +test(Object.prototype.toString); +test(Object.prototype.valueOf);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066214.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,15 @@ +0 +abc +true +TypeError: undefined is not an Object +TypeError: null is not an Object +[object Number] +[object String] +[object Boolean] +[object Undefined] +[object Null] +0 +abc +true +TypeError: undefined is not an Object +TypeError: null is not an Object
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066215.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 2014, 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-8066215: Fuzzing bug: length valueOf bug + * + * @test + * @run + */ + +function defineLength(arr, length) { + Object.defineProperty(arr, "length", { + value: { + valueOf: function() { + print("value retrieved: " + length); + return length; + } + } + }); + print("done: " + arr.length + ", " + typeof arr.length); +} + +var a = []; +defineLength(a, 3); +defineLength(a, 6); +defineLength(a, 3);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066215.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,9 @@ +value retrieved: 3 +value retrieved: 3 +done: 3, number +value retrieved: 6 +value retrieved: 6 +done: 6, number +value retrieved: 3 +value retrieved: 3 +done: 3, number
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066222.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 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-8066222: too strong assertion on function expression names + * + * @test + * @run + */ + +// Has to print "SUCCESS" +(function x (x){print(x)})("SUCCESS"); + +// Has to print "undefined" and "1", not the function source in any case. +(function x(){print(x); var x=1; print(x)})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066222.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,3 @@ +SUCCESS +undefined +1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066226.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014, 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-8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory + * + * @test + * @run + */ + +Object.defineProperty(Object.prototype, "accessor", { + set: function(value) { + print("Setting accessor on " + this + " to " + value); + } +}); + +Object.defineProperty(Object.prototype, "getterOnly", { + get: function() { + return 1; + } +}); + +function set(o) { + print("set(" + o + ")"); + o.foo = 1; + o.constructor = 1; + o.accessor = 1; + o.getterOnly = 1; + print(); +} + +function setStrict(o) { + "use strict"; + print("setStrict(" + o + ")") + try { + o.foo = 1; + } catch (e) { + print(e); + } + try { + o.constructor = 1; + } catch (e) { + print(e); + } + try { + o.accessor = 1; + } catch (e) { + print(e); + } + try { + o.getterOnly = 1; + } catch (e) { + print(e); + } + print(); +} + +function setAttr(o, id) { + print("setAttr(" + o + ", " + id + ")") + o[id] = 1; + print(); +} + +function setAttrStrict(o, id) { + "use strict"; + print("setAttrStrict(" + o + ", " + id + ")") + try { + o[id] = 1; + } catch (e) { + print(e); + } + print(); +} + +set(1); +set("str"); +set(true); +set({}); +set([]); + +setStrict(1); +setStrict("str"); +setStrict(true); +setStrict({}); +setStrict([]); + +setAttr(1, "foo"); +setAttr(1, "constructor"); +setAttr(1, "accessor"); +setAttr(1, "getterOnly"); +setAttr("str", "foo"); +setAttr("str", "constructor"); +setAttr("str", "accessor"); +setAttr("str", "getterOnly"); +setAttr(true, "foo"); +setAttr(true, "constructor"); +setAttr(true, "accessor"); +setAttr(true, "getterOnly"); + +setAttrStrict(1, "foo"); +setAttrStrict(1, "constructor"); +setAttrStrict(1, "accessor"); +setAttrStrict(1, "getterOnly"); +setAttrStrict("str", "foo"); +setAttrStrict("str", "constructor"); +setAttrStrict("str", "accessor"); +setAttrStrict("str", "getterOnly"); +setAttrStrict(true, "foo"); +setAttrStrict(true, "constructor"); +setAttrStrict(true, "accessor"); +setAttrStrict(true, "getterOnly");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8066226.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,104 @@ +set(1) +Setting accessor on 1 to 1 + +set(str) +Setting accessor on str to 1 + +set(true) +Setting accessor on true to 1 + +set([object Object]) +Setting accessor on [object Object] to 1 + +set() +Setting accessor on to 1 + +setStrict(1) +TypeError: "foo" is not a writable property of 1 +TypeError: "constructor" is not a writable property of 1 +Setting accessor on 1 to 1 +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter + +setStrict(str) +TypeError: "foo" is not a writable property of str +TypeError: "constructor" is not a writable property of str +Setting accessor on str to 1 +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter + +setStrict(true) +TypeError: "foo" is not a writable property of true +TypeError: "constructor" is not a writable property of true +Setting accessor on true to 1 +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter + +setStrict([object Object]) +Setting accessor on [object Object] to 1 +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter + +setStrict() +Setting accessor on to 1 +TypeError: Cannot set property "getterOnly" of [object Array] that has only a getter + +setAttr(1, foo) + +setAttr(1, constructor) + +setAttr(1, accessor) +Setting accessor on 1 to 1 + +setAttr(1, getterOnly) + +setAttr(str, foo) + +setAttr(str, constructor) + +setAttr(str, accessor) +Setting accessor on str to 1 + +setAttr(str, getterOnly) + +setAttr(true, foo) + +setAttr(true, constructor) + +setAttr(true, accessor) +Setting accessor on true to 1 + +setAttr(true, getterOnly) + +setAttrStrict(1, foo) +TypeError: "foo" is not a writable property of 1 + +setAttrStrict(1, constructor) +TypeError: "constructor" is not a writable property of 1 + +setAttrStrict(1, accessor) +Setting accessor on 1 to 1 + +setAttrStrict(1, getterOnly) +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter + +setAttrStrict(str, foo) +TypeError: "foo" is not a writable property of str + +setAttrStrict(str, constructor) +TypeError: "constructor" is not a writable property of str + +setAttrStrict(str, accessor) +Setting accessor on str to 1 + +setAttrStrict(str, getterOnly) +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter + +setAttrStrict(true, foo) +TypeError: "foo" is not a writable property of true + +setAttrStrict(true, constructor) +TypeError: "constructor" is not a writable property of true + +setAttrStrict(true, accessor) +Setting accessor on true to 1 + +setAttrStrict(true, getterOnly) +TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8068985.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 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-8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object + * + * @test + * @run + */ + +function func(arg) { + (function() { print(eval('this')); }).call(arg); +} + +// primitives +func(undefined); +func(null); +func(34.23); +func("hello"); +func(false); + +// script objects +func(this); +func({}); +func({ toString: function() { return "foo" } }); + +// java objects +func(new java.util.Vector()); +var m = new java.util.HashMap(); +m.put("foo", "bar"); +func(m);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8068985.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,10 @@ +[object global] +[object global] +34.23 +hello +false +[object global] +[object Object] +foo +[] +{foo=bar}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8075090.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2015 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-8075090: Add tests for the basic failure of try/finally compilation + * + * @test + * @run + */ + +(function() { + var finallyExpected = false; + try { + for(var i = 0; i < 2; ++i) { + if(i == 1) { + continue; + } + } + finallyExpected = true; + } finally { + Assert.assertTrue(finallyExpected); + } +})(); + +(function() { + var finallyExpected = false; + try { + for(var i = 0; i < 2; ++i) { + if(i == 1) { + break; + } + } + finallyExpected = true; + } finally { + Assert.assertTrue(finallyExpected); + } +})(); + +(function() { + var finallyExpected = false; + try { + L1: { + if ((function(){return true})()) { + break L1; + } + Assert.fail(); // unreachable + } + finallyExpected = true; + } finally { + Assert.assertTrue(finallyExpected); + } +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_1a.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010, 2014, 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-8078612: Persistent code cache should support more configurations + * + * @test + * @runif external.prototype + * @option -pcc + * @option --lazy-compilation=false + * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache + * @fork + */ + +load(__DIR__ + 'prototype.js');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_1a.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,1 @@ +parsed and compiled ok prototype.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_1b.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010, 2014, 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-8078612: Persistent code cache should support more configurations + * + * @test + * @runif external.prototype + * @option -pcc + * @option --lazy-compilation=false + * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache + * @fork + */ + +load(__DIR__ + 'prototype.js');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_1b.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,1 @@ +parsed and compiled ok prototype.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_2a.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010, 2014, 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-8078612: Persistent code cache should support more configurations + * + * @test + * @runif external.yui + * @option -pcc + * @option --lazy-compilation=false + * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache + * @fork + */ + +load(__DIR__ + 'yui.js');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_2a.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,2 @@ +parsed and compiled ok yui-min.js +parsed and compiled ok yui.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_2b.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010, 2014, 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-8078612: Persistent code cache should support more configurations + * + * @test + * @runif external.yui + * @option -pcc + * @option --lazy-compilation=false + * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache + * @fork + */ + +load(__DIR__ + 'yui.js');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8078612_eager_2b.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,2 @@ +parsed and compiled ok yui-min.js +parsed and compiled ok yui.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8079269.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2015 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-8079269: Optimistic rewrite in object literal causes ArrayIndexOutOfBoundsException + * + * @test + * @run + */ + +// m must be in scope so it's accessed with optimistic getters on scope +var m = 1; + +(function() { + return { + p0: m, + p1: m = "foo", + p2: m + } +})(); + +var n = 1; + +// Test the spill object creator too +(function() { + return { + p0: n, + p1: n = "foo", + p2: n, + p3: n, + p4: n, + p5: n, + p6: n, + p7: n, + p8: n, + p9: n, + p10: n, + p11: n, + p12: n, + p13: n, + p14: n, + p15: n, + p16: n, + p17: n, + p18: n, + p19: n, + p20: n, + p21: n, + p22: n, + p23: n, + p24: n, + p25: n, + p26: n, + p27: n, + p28: n, + p29: n, + p30: n, + p31: n, + p32: n, + p33: n, + p34: n, + p35: n, + p36: n, + p37: n, + p38: n, + p39: n, + p40: n, + p41: n, + p42: n, + p43: n, + p44: n, + p45: n, + p46: n, + p47: n, + p48: n, + p49: n, + p50: n, + p51: n, + p52: n, + p53: n, + p54: n, + p55: n, + p56: n, + p57: n, + p58: n, + p59: n, + p60: n, + p61: n, + p62: n, + p63: n, + p64: n, + p65: n, + p66: n, + p67: n, + p68: n, + p69: n, + p70: n, + p71: n, + p72: n, + p73: n, + p74: n, + p75: n, + p76: n, + p77: n, + p78: n, + p79: n, + p80: n, + p81: n, + p82: n, + p83: n, + p84: n, + p85: n, + p86: n, + p87: n, + p88: n, + p89: n, + p90: n, + p91: n, + p92: n, + p93: n, + p94: n, + p95: n, + p96: n, + p97: n, + p98: n, + p99: n, + p100: n, + p101: n, + p102: n, + p103: n, + p104: n, + p105: n, + p106: n, + p107: n, + p108: n, + p109: n, + p110: n, + p111: n, + p112: n, + p113: n, + p114: n, + p115: n, + p116: n, + p117: n, + p118: n, + p119: n, + p120: n, + p121: n, + p122: n, + p123: n, + p124: n, + p125: n, + p126: n, + p127: n, + p128: n, + p129: n, + p130: n, + p131: n, + p132: n, + p133: n, + p134: n, + p135: n, + p136: n, + p137: n, + p138: n, + p139: n, + p140: n, + p141: n, + p142: n, + p143: n, + p144: n, + p145: n, + p146: n, + p147: n, + p148: n, + p149: n, + p150: n, + p151: n, + p152: n, + p153: n, + p154: n, + p155: n, + p156: n, + p157: n, + p158: n, + p159: n, + p160: n, + p161: n, + p162: n, + p163: n, + p164: n, + p165: n, + p166: n, + p167: n, + p168: n, + p169: n, + p170: n, + p171: n, + p172: n, + p173: n, + p174: n, + p175: n, + p176: n, + p177: n, + p178: n, + p179: n, + p180: n, + p181: n, + p182: n, + p183: n, + p184: n, + p185: n, + p186: n, + p187: n, + p188: n, + p189: n, + p190: n, + p191: n, + p192: n, + p193: n, + p194: n, + p195: n, + p196: n, + p197: n, + p198: n, + p199: n, + p200: n, + p201: n, + p202: n, + p203: n, + p204: n, + p205: n, + p206: n, + p207: n, + p208: n, + p209: n, + p210: n, + p211: n, + p212: n, + p213: n, + p214: n, + p215: n, + p216: n, + p217: n, + p218: n, + p219: n, + p220: n, + p221: n, + p222: n, + p223: n, + p224: n, + p225: n, + p226: n, + p227: n, + p228: n, + p229: n, + p230: n, + p231: n, + p232: n, + p233: n, + p234: n, + p235: n, + p236: n, + p237: n, + p238: n, + p239: n, + p240: n, + p241: n, + p242: n, + p243: n, + p244: n, + p245: n, + p246: n, + p247: n, + p248: n, + p249: n, + p250: n, + p251: n, + p252: n, + p253: n, + p254: n, + p255: n, + p256: n, + p257: n, + p258: n, + p259: n + } +})(); + +// No output; as long as it completes without +// ArrayIndexOutOfBoundsException in the OSR continuation handler, it's +// a success.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8079470.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015 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-8079470: Misleading error message when explicit signature constructor is called with wrong arguments + * + * @test + * @run + */ + + +var File = Java.type("java.io.File"); +try { + var f = new File['(String,String)'](); +} catch (e) { + print(e); +} + +var Color = java.awt["Color(int,int,int)"] +try { + var c = new Color(255, 255) +} catch (e) { + print(e); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8079470.js.EXPECTED Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,2 @@ +TypeError: Can not create new object with constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod File java.io.File.java.io.File(String,String)] with the passed arguments; they do not match any of its method signatures. +TypeError: Can not create new object with constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] with the passed arguments; they do not match any of its method signatures.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8080182.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015 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-8080182: Array.prototype.sort throws IAE on inconsistent comparison + * + * @test + * @run + */ + +function Random() { + this.toString = function() { + return (Math.random() * 100).toString(); + } +} + +for (var i = 0; i < 100; ++i) { + var arr = []; + + for (var j = 0; j < 64; ++j) { + arr[j] = new Random(); + } + + // no IllegalArgumentException expected! + arr.sort(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/nosecurity/JDK-8078049.js Thu May 14 20:13:03 2015 -0700 @@ -0,0 +1,553 @@ +/* + * Copyright (c) 2015, 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-8078049: Nashorn crashes when attempting to start the new tsc.js compiler for TypeScript + * + * @test + * @run + * @fork + * @option -Dnashorn.debug=true + */ + +var m = 1; + +var fields = { + p0: { code: 0, category: m }, + p1: { code: 1, category: m }, + p2: { code: 2, category: m } +}; + +var spill = { + p0: { code: 0, category: m }, + p1: { code: 1, category: m }, + p2: { code: 2, category: m }, + p3: { code: 3, category: m }, + p4: { code: 4, category: m }, + p5: { code: 5, category: m }, + p6: { code: 6, category: m }, + p7: { code: 7, category: m }, + p8: { code: 8, category: m }, + p9: { code: 9, category: m }, + p10: { code: 10, category: m }, + p11: { code: 11, category: m }, + p12: { code: 12, category: m }, + p13: { code: 13, category: m }, + p14: { code: 14, category: m }, + p15: { code: 15, category: m }, + p16: { code: 16, category: m }, + p17: { code: 17, category: m }, + p18: { code: 18, category: m }, + p19: { code: 19, category: m }, + p20: { code: 20, category: m }, + p21: { code: 21, category: m }, + p22: { code: 22, category: m }, + p23: { code: 23, category: m }, + p24: { code: 24, category: m }, + p25: { code: 25, category: m }, + p26: { code: 26, category: m }, + p27: { code: 27, category: m }, + p28: { code: 28, category: m }, + p29: { code: 29, category: m }, + p30: { code: 30, category: m }, + p31: { code: 31, category: m }, + p32: { code: 32, category: m }, + p33: { code: 33, category: m }, + p34: { code: 34, category: m }, + p35: { code: 35, category: m }, + p36: { code: 36, category: m }, + p37: { code: 37, category: m }, + p38: { code: 38, category: m }, + p39: { code: 39, category: m }, + p40: { code: 40, category: m }, + p41: { code: 41, category: m }, + p42: { code: 42, category: m }, + p43: { code: 43, category: m }, + p44: { code: 44, category: m }, + p45: { code: 45, category: m }, + p46: { code: 46, category: m }, + p47: { code: 47, category: m }, + p48: { code: 48, category: m }, + p49: { code: 49, category: m }, + p50: { code: 50, category: m }, + p51: { code: 51, category: m }, + p52: { code: 52, category: m }, + p53: { code: 53, category: m }, + p54: { code: 54, category: m }, + p55: { code: 55, category: m }, + p56: { code: 56, category: m }, + p57: { code: 57, category: m }, + p58: { code: 58, category: m }, + p59: { code: 59, category: m }, + p60: { code: 60, category: m }, + p61: { code: 61, category: m }, + p62: { code: 62, category: m }, + p63: { code: 63, category: m }, + p64: { code: 64, category: m }, + p65: { code: 65, category: m }, + p66: { code: 66, category: m }, + p67: { code: 67, category: m }, + p68: { code: 68, category: m }, + p69: { code: 69, category: m }, + p70: { code: 70, category: m }, + p71: { code: 71, category: m }, + p72: { code: 72, category: m }, + p73: { code: 73, category: m }, + p74: { code: 74, category: m }, + p75: { code: 75, category: m }, + p76: { code: 76, category: m }, + p77: { code: 77, category: m }, + p78: { code: 78, category: m }, + p79: { code: 79, category: m }, + p80: { code: 80, category: m }, + p81: { code: 81, category: m }, + p82: { code: 82, category: m }, + p83: { code: 83, category: m }, + p84: { code: 84, category: m }, + p85: { code: 85, category: m }, + p86: { code: 86, category: m }, + p87: { code: 87, category: m }, + p88: { code: 88, category: m }, + p89: { code: 89, category: m }, + p90: { code: 90, category: m }, + p91: { code: 91, category: m }, + p92: { code: 92, category: m }, + p93: { code: 93, category: m }, + p94: { code: 94, category: m }, + p95: { code: 95, category: m }, + p96: { code: 96, category: m }, + p97: { code: 97, category: m }, + p98: { code: 98, category: m }, + p99: { code: 99, category: m }, + p100: { code: 100, category: m }, + p101: { code: 101, category: m }, + p102: { code: 102, category: m }, + p103: { code: 103, category: m }, + p104: { code: 104, category: m }, + p105: { code: 105, category: m }, + p106: { code: 106, category: m }, + p107: { code: 107, category: m }, + p108: { code: 108, category: m }, + p109: { code: 109, category: m }, + p110: { code: 110, category: m }, + p111: { code: 111, category: m }, + p112: { code: 112, category: m }, + p113: { code: 113, category: m }, + p114: { code: 114, category: m }, + p115: { code: 115, category: m }, + p116: { code: 116, category: m }, + p117: { code: 117, category: m }, + p118: { code: 118, category: m }, + p119: { code: 119, category: m }, + p120: { code: 120, category: m }, + p121: { code: 121, category: m }, + p122: { code: 122, category: m }, + p123: { code: 123, category: m }, + p124: { code: 124, category: m }, + p125: { code: 125, category: m }, + p126: { code: 126, category: m }, + p127: { code: 127, category: m }, + p128: { code: 128, category: m }, + p129: { code: 129, category: m }, + p130: { code: 130, category: m }, + p131: { code: 131, category: m }, + p132: { code: 132, category: m }, + p133: { code: 133, category: m }, + p134: { code: 134, category: m }, + p135: { code: 135, category: m }, + p136: { code: 136, category: m }, + p137: { code: 137, category: m }, + p138: { code: 138, category: m }, + p139: { code: 139, category: m }, + p140: { code: 140, category: m }, + p141: { code: 141, category: m }, + p142: { code: 142, category: m }, + p143: { code: 143, category: m }, + p144: { code: 144, category: m }, + p145: { code: 145, category: m }, + p146: { code: 146, category: m }, + p147: { code: 147, category: m }, + p148: { code: 148, category: m }, + p149: { code: 149, category: m }, + p150: { code: 150, category: m }, + p151: { code: 151, category: m }, + p152: { code: 152, category: m }, + p153: { code: 153, category: m }, + p154: { code: 154, category: m }, + p155: { code: 155, category: m }, + p156: { code: 156, category: m }, + p157: { code: 157, category: m }, + p158: { code: 158, category: m }, + p159: { code: 159, category: m }, + p160: { code: 160, category: m }, + p161: { code: 161, category: m }, + p162: { code: 162, category: m }, + p163: { code: 163, category: m }, + p164: { code: 164, category: m }, + p165: { code: 165, category: m }, + p166: { code: 166, category: m }, + p167: { code: 167, category: m }, + p168: { code: 168, category: m }, + p169: { code: 169, category: m }, + p170: { code: 170, category: m }, + p171: { code: 171, category: m }, + p172: { code: 172, category: m }, + p173: { code: 173, category: m }, + p174: { code: 174, category: m }, + p175: { code: 175, category: m }, + p176: { code: 176, category: m }, + p177: { code: 177, category: m }, + p178: { code: 178, category: m }, + p179: { code: 179, category: m }, + p180: { code: 180, category: m }, + p181: { code: 181, category: m }, + p182: { code: 182, category: m }, + p183: { code: 183, category: m }, + p184: { code: 184, category: m }, + p185: { code: 185, category: m }, + p186: { code: 186, category: m }, + p187: { code: 187, category: m }, + p188: { code: 188, category: m }, + p189: { code: 189, category: m }, + p190: { code: 190, category: m }, + p191: { code: 191, category: m }, + p192: { code: 192, category: m }, + p193: { code: 193, category: m }, + p194: { code: 194, category: m }, + p195: { code: 195, category: m }, + p196: { code: 196, category: m }, + p197: { code: 197, category: m }, + p198: { code: 198, category: m }, + p199: { code: 199, category: m }, + p200: { code: 200, category: m }, + p201: { code: 201, category: m }, + p202: { code: 202, category: m }, + p203: { code: 203, category: m }, + p204: { code: 204, category: m }, + p205: { code: 205, category: m }, + p206: { code: 206, category: m }, + p207: { code: 207, category: m }, + p208: { code: 208, category: m }, + p209: { code: 209, category: m }, + p210: { code: 210, category: m }, + p211: { code: 211, category: m }, + p212: { code: 212, category: m }, + p213: { code: 213, category: m }, + p214: { code: 214, category: m }, + p215: { code: 215, category: m }, + p216: { code: 216, category: m }, + p217: { code: 217, category: m }, + p218: { code: 218, category: m }, + p219: { code: 219, category: m }, + p220: { code: 220, category: m }, + p221: { code: 221, category: m }, + p222: { code: 222, category: m }, + p223: { code: 223, category: m }, + p224: { code: 224, category: m }, + p225: { code: 225, category: m }, + p226: { code: 226, category: m }, + p227: { code: 227, category: m }, + p228: { code: 228, category: m }, + p229: { code: 229, category: m }, + p230: { code: 230, category: m }, + p231: { code: 231, category: m }, + p232: { code: 232, category: m }, + p233: { code: 233, category: m }, + p234: { code: 234, category: m }, + p235: { code: 235, category: m }, + p236: { code: 236, category: m }, + p237: { code: 237, category: m }, + p238: { code: 238, category: m }, + p239: { code: 239, category: m }, + p240: { code: 240, category: m }, + p241: { code: 241, category: m }, + p242: { code: 242, category: m }, + p243: { code: 243, category: m }, + p244: { code: 244, category: m }, + p245: { code: 245, category: m }, + p246: { code: 246, category: m }, + p247: { code: 247, category: m }, + p248: { code: 248, category: m }, + p249: { code: 249, category: m }, + p250: { code: 250, category: m }, + p251: { code: 251, category: m }, + p252: { code: 252, category: m }, + p253: { code: 253, category: m }, + p254: { code: 254, category: m }, + p255: { code: 255, category: m }, + p256: { code: 256, category: m }, + p257: { code: 257, category: m }, + p258: { code: 258, category: m }, + p259: { code: 259, category: m }, + p260: { code: 260, category: m }, + p261: { code: 261, category: m }, + p262: { code: 262, category: m }, + p263: { code: 263, category: m }, + p264: { code: 264, category: m }, + p265: { code: 265, category: m }, + p266: { code: 266, category: m }, + p267: { code: 267, category: m }, + p268: { code: 268, category: m }, + p269: { code: 269, category: m }, + p270: { code: 270, category: m }, + p271: { code: 271, category: m }, + p272: { code: 272, category: m }, + p273: { code: 273, category: m }, + p274: { code: 274, category: m }, + p275: { code: 275, category: m }, + p276: { code: 276, category: m }, + p277: { code: 277, category: m }, + p278: { code: 278, category: m }, + p279: { code: 279, category: m }, + p280: { code: 280, category: m }, + p281: { code: 281, category: m }, + p282: { code: 282, category: m }, + p283: { code: 283, category: m }, + p284: { code: 284, category: m }, + p285: { code: 285, category: m }, + p286: { code: 286, category: m }, + p287: { code: 287, category: m }, + p288: { code: 288, category: m }, + p289: { code: 289, category: m }, + p290: { code: 290, category: m }, + p291: { code: 291, category: m }, + p292: { code: 292, category: m }, + p293: { code: 293, category: m }, + p294: { code: 294, category: m }, + p295: { code: 295, category: m }, + p296: { code: 296, category: m }, + p297: { code: 297, category: m }, + p298: { code: 298, category: m }, + p299: { code: 299, category: m }, + p300: { code: 300, category: m }, + p301: { code: 301, category: m }, + p302: { code: 302, category: m }, + p303: { code: 303, category: m }, + p304: { code: 304, category: m }, + p305: { code: 305, category: m }, + p306: { code: 306, category: m }, + p307: { code: 307, category: m }, + p308: { code: 308, category: m }, + p309: { code: 309, category: m }, + p310: { code: 310, category: m }, + p311: { code: 311, category: m }, + p312: { code: 312, category: m }, + p313: { code: 313, category: m }, + p314: { code: 314, category: m }, + p315: { code: 315, category: m }, + p316: { code: 316, category: m }, + p317: { code: 317, category: m }, + p318: { code: 318, category: m }, + p319: { code: 319, category: m }, + p320: { code: 320, category: m }, + p321: { code: 321, category: m }, + p322: { code: 322, category: m }, + p323: { code: 323, category: m }, + p324: { code: 324, category: m }, + p325: { code: 325, category: m }, + p326: { code: 326, category: m }, + p327: { code: 327, category: m }, + p328: { code: 328, category: m }, + p329: { code: 329, category: m }, + p330: { code: 330, category: m }, + p331: { code: 331, category: m }, + p332: { code: 332, category: m }, + p333: { code: 333, category: m }, + p334: { code: 334, category: m }, + p335: { code: 335, category: m }, + p336: { code: 336, category: m }, + p337: { code: 337, category: m }, + p338: { code: 338, category: m }, + p339: { code: 339, category: m }, + p340: { code: 340, category: m }, + p341: { code: 341, category: m }, + p342: { code: 342, category: m }, + p343: { code: 343, category: m }, + p344: { code: 344, category: m }, + p345: { code: 345, category: m }, + p346: { code: 346, category: m }, + p347: { code: 347, category: m }, + p348: { code: 348, category: m }, + p349: { code: 349, category: m }, + p350: { code: 350, category: m }, + p351: { code: 351, category: m }, + p352: { code: 352, category: m }, + p353: { code: 353, category: m }, + p354: { code: 354, category: m }, + p355: { code: 355, category: m }, + p356: { code: 356, category: m }, + p357: { code: 357, category: m }, + p358: { code: 358, category: m }, + p359: { code: 359, category: m }, + p360: { code: 360, category: m }, + p361: { code: 361, category: m }, + p362: { code: 362, category: m }, + p363: { code: 363, category: m }, + p364: { code: 364, category: m }, + p365: { code: 365, category: m }, + p366: { code: 366, category: m }, + p367: { code: 367, category: m }, + p368: { code: 368, category: m }, + p369: { code: 369, category: m }, + p370: { code: 370, category: m }, + p371: { code: 371, category: m }, + p372: { code: 372, category: m }, + p373: { code: 373, category: m }, + p374: { code: 374, category: m }, + p375: { code: 375, category: m }, + p376: { code: 376, category: m }, + p377: { code: 377, category: m }, + p378: { code: 378, category: m }, + p379: { code: 379, category: m }, + p380: { code: 380, category: m }, + p381: { code: 381, category: m }, + p382: { code: 382, category: m }, + p383: { code: 383, category: m }, + p384: { code: 384, category: m }, + p385: { code: 385, category: m }, + p386: { code: 386, category: m }, + p387: { code: 387, category: m }, + p388: { code: 388, category: m }, + p389: { code: 389, category: m }, + p390: { code: 390, category: m }, + p391: { code: 391, category: m }, + p392: { code: 392, category: m }, + p393: { code: 393, category: m }, + p394: { code: 394, category: m }, + p395: { code: 395, category: m }, + p396: { code: 396, category: m }, + p397: { code: 397, category: m }, + p398: { code: 398, category: m }, + p399: { code: 399, category: m }, + p400: { code: 400, category: m }, + p401: { code: 401, category: m }, + p402: { code: 402, category: m }, + p403: { code: 403, category: m }, + p404: { code: 404, category: m }, + p405: { code: 405, category: m }, + p406: { code: 406, category: m }, + p407: { code: 407, category: m }, + p408: { code: 408, category: m }, + p409: { code: 409, category: m }, + p410: { code: 410, category: m }, + p411: { code: 411, category: m }, + p412: { code: 412, category: m }, + p413: { code: 413, category: m }, + p414: { code: 414, category: m }, + p415: { code: 415, category: m }, + p416: { code: 416, category: m }, + p417: { code: 417, category: m }, + p418: { code: 418, category: m }, + p419: { code: 419, category: m }, + p420: { code: 420, category: m }, + p421: { code: 421, category: m }, + p422: { code: 422, category: m }, + p423: { code: 423, category: m }, + p424: { code: 424, category: m }, + p425: { code: 425, category: m }, + p426: { code: 426, category: m }, + p427: { code: 427, category: m }, + p428: { code: 428, category: m }, + p429: { code: 429, category: m }, + p430: { code: 430, category: m }, + p431: { code: 431, category: m }, + p432: { code: 432, category: m }, + p433: { code: 433, category: m }, + p434: { code: 434, category: m }, + p435: { code: 435, category: m }, + p436: { code: 436, category: m }, + p437: { code: 437, category: m }, + p438: { code: 438, category: m }, + p439: { code: 439, category: m }, + p440: { code: 440, category: m }, + p441: { code: 441, category: m }, + p442: { code: 442, category: m }, + p443: { code: 443, category: m }, + p444: { code: 444, category: m }, + p445: { code: 445, category: m }, + p446: { code: 446, category: m }, + p447: { code: 447, category: m }, + p448: { code: 448, category: m }, + p449: { code: 449, category: m }, + p450: { code: 450, category: m }, + p451: { code: 451, category: m }, + p452: { code: 452, category: m }, + p453: { code: 453, category: m }, + p454: { code: 454, category: m }, + p455: { code: 455, category: m }, + p456: { code: 456, category: m }, + p457: { code: 457, category: m }, + p458: { code: 458, category: m }, + p459: { code: 459, category: m }, + p460: { code: 460, category: m }, + p461: { code: 461, category: m }, + p462: { code: 462, category: m }, + p463: { code: 463, category: m }, + p464: { code: 464, category: m }, + p465: { code: 465, category: m }, + p466: { code: 466, category: m }, + p467: { code: 467, category: m }, + p468: { code: 468, category: m }, + p469: { code: 469, category: m }, + p470: { code: 470, category: m }, + p471: { code: 471, category: m }, + p472: { code: 472, category: m }, + p473: { code: 473, category: m }, + p474: { code: 474, category: m }, + p475: { code: 475, category: m }, + p476: { code: 476, category: m }, + p477: { code: 477, category: m }, + p478: { code: 478, category: m }, + p479: { code: 479, category: m }, + p480: { code: 480, category: m }, + p481: { code: 481, category: m }, + p482: { code: 482, category: m }, + p483: { code: 483, category: m }, + p484: { code: 484, category: m }, + p485: { code: 485, category: m }, + p486: { code: 486, category: m }, + p487: { code: 487, category: m }, + p488: { code: 488, category: m }, + p489: { code: 489, category: m }, + p490: { code: 490, category: m }, + p491: { code: 491, category: m }, + p492: { code: 492, category: m }, + p493: { code: 493, category: m }, + p494: { code: 494, category: m }, + p495: { code: 495, category: m }, + p496: { code: 496, category: m }, + p497: { code: 497, category: m }, + p498: { code: 498, category: m }, + p499: { code: 499, category: m } +}; + +var AccessorProperty = Java.type("jdk.nashorn.internal.runtime.AccessorProperty"); +var SpillProperty = Java.type("jdk.nashorn.internal.runtime.SpillProperty"); + +Assert.assertTrue(Object.keys(fields).length === 3); +Assert.assertTrue(Debug.map(fields).findProperty("p0").getClass() === AccessorProperty.class); +Assert.assertTrue(Debug.map(fields).findProperty("p2").getClass() === AccessorProperty.class); + +Assert.assertTrue(Object.keys(spill).length === 500); +Assert.assertTrue(Debug.map(spill).findProperty("p0").getClass() === SpillProperty.class); +Assert.assertTrue(Debug.map(spill).findProperty("p499").getClass() === SpillProperty.class);
--- a/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java Wed May 13 12:50:12 2015 -0700 +++ b/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java Thu May 14 20:13:03 2015 -0700 @@ -162,7 +162,7 @@ e.eval(code3);// less than minimum size for storing // adding code1 and code2. final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath); - checkCompiledScripts(stream, 2); + checkCompiledScripts(stream, 4); } private static Path getCodeCachePath(final boolean optimistic) {