8023017: SUB missing for widest op == number for BinaryNode
Reviewed-by: sundar, jlaskey
--- a/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Fri Aug 16 18:51:53 2013 +0200
@@ -317,7 +317,8 @@
final String className = getClassName(fieldCount);
final String superName = className(ScriptObject.class);
final ClassEmitter classEmitter = newClassEmitter(className, superName);
- final List<String> initFields = addFields(classEmitter, fieldCount);
+
+ addFields(classEmitter, fieldCount);
final MethodEmitter init = newInitMethod(classEmitter);
init.returnVoid();
--- a/nashorn/src/jdk/nashorn/internal/codegen/ObjectCreator.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/ObjectCreator.java Fri Aug 16 18:51:53 2013 +0200
@@ -45,9 +45,11 @@
/** Code generator */
protected final CodeGenerator codegen;
- private final boolean isScope;
- private final boolean hasArguments;
- protected PropertyMap propertyMap;
+ /** Property map */
+ protected PropertyMap propertyMap;
+
+ private final boolean isScope;
+ private final boolean hasArguments;
/**
* Constructor
--- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java Fri Aug 16 18:51:53 2013 +0200
@@ -99,6 +99,7 @@
case DIV:
case MOD:
case MUL:
+ case SUB:
case ASSIGN_DIV:
case ASSIGN_MOD:
case ASSIGN_MUL:
--- a/nashorn/src/jdk/nashorn/internal/ir/BreakableNode.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/ir/BreakableNode.java Fri Aug 16 18:51:53 2013 +0200
@@ -33,6 +33,14 @@
* a {@code break} statement
*/
public interface BreakableNode extends LexicalContextNode {
+ /**
+ * Ensure that any labels in this breakable node are unique so
+ * that new jumps won't go to old parts of the tree. Used for
+ * example for cloning finally blocks
+ *
+ * @param lc the lexical context
+ * @return node after labels have been made unique
+ */
public abstract Node ensureUniqueLabels(final LexicalContext lc);
/**
--- a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java Fri Aug 16 18:51:53 2013 +0200
@@ -161,13 +161,13 @@
* converting to object, for example if the symbol is used as the left hand side of an
* assignment such as in the code below.</p>
*
- * <pre>{@code
+ * <pre>
* try {
* return 2;
* } finally {
* return 3;
* }
- * }</pre>
+ * }
*
* @return true if can have callsite type
*/
--- a/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java Fri Aug 16 18:51:53 2013 +0200
@@ -44,8 +44,14 @@
Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor);
// Would be a default method on Java 8
+ /**
+ * Helper class for accept for items of this lexical context, delegates to the
+ * subclass accept and makes sure that the node is on the context before accepting
+ * and gets popped after accepting (and that the stack is consistent in that the
+ * node has been replaced with the possible new node resulting in visitation)
+ */
static class Acceptor {
- static Node accept(LexicalContextNode node, final NodeVisitor<? extends LexicalContext> visitor) {
+ static Node accept(final LexicalContextNode node, final NodeVisitor<? extends LexicalContext> visitor) {
final LexicalContext lc = visitor.getLexicalContext();
lc.push(node);
final LexicalContextNode newNode = (LexicalContextNode)node.accept(lc, visitor);
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java Fri Aug 16 18:51:53 2013 +0200
@@ -266,9 +266,8 @@
final ScriptObject proto = global.getObjectPrototype();
if (isStrict) {
return new NativeStrictArguments(arguments, numParams, proto, global.getStrictArgumentsMap());
- } else {
- return new NativeArguments(arguments, callee, numParams, proto, global.getArgumentsMap());
}
+ return new NativeArguments(arguments, callee, numParams, proto, global.getArgumentsMap());
}
/**
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java Fri Aug 16 18:51:53 2013 +0200
@@ -638,9 +638,9 @@
if (isScriptArray || obj instanceof Iterable || (obj != null && obj.getClass().isArray())) {
final Iterator<Object> iter = arrayLikeIterator(obj, true);
if (iter.hasNext()) {
- for(int i = 0; iter.hasNext(); ++i) {
+ for (int i = 0; iter.hasNext(); ++i) {
final Object value = iter.next();
- if(value == ScriptRuntime.UNDEFINED && isScriptObject && !((ScriptObject)obj).has(i)) {
+ if (value == ScriptRuntime.UNDEFINED && isScriptObject && !((ScriptObject)obj).has(i)) {
// TODO: eventually rewrite arrayLikeIterator to use a three-state enum for handling
// UNDEFINED instead of an "includeUndefined" boolean with states SKIP, INCLUDE,
// RETURN_EMPTY. Until then, this is how we'll make sure that empty elements don't make it
--- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java Fri Aug 16 18:51:53 2013 +0200
@@ -160,10 +160,10 @@
if (this.scripting) {
this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
@Override
- public void lineInfo(final int line, final int linePosition) {
+ public void lineInfo(final int receiverLine, final int receiverLinePosition) {
// update the parser maintained line information
- Parser.this.line = line;
- Parser.this.linePosition = linePosition;
+ Parser.this.line = receiverLine;
+ Parser.this.linePosition = receiverLinePosition;
}
};
} else {
--- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java Fri Aug 16 18:51:53 2013 +0200
@@ -48,6 +48,7 @@
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.util.Map;
+
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.util.CheckClassAdapter;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
@@ -888,6 +889,7 @@
return script;
}
+ @SuppressWarnings("static-method")
private ScriptLoader createNewLoader() {
return AccessController.doPrivileged(
new PrivilegedAction<ScriptLoader>() {
--- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Fri Aug 16 18:51:53 2013 +0200
@@ -47,7 +47,7 @@
* This is a subclass that represents a script function that may be regenerated,
* for example with specialization based on call site types, or lazily generated.
* The common denominator is that it can get new invokers during its lifespan,
- * unlike {@link FinalScriptFunctionData}
+ * unlike {@code FinalScriptFunctionData}
*/
public final class RecompilableScriptFunctionData extends ScriptFunctionData {
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java Fri Aug 16 18:51:53 2013 +0200
@@ -553,19 +553,18 @@
private static MethodHandle bindToNameIfNeeded(final MethodHandle methodHandle, final String bindName) {
if (bindName == null) {
return methodHandle;
- } else {
- // if it is vararg method, we need to extend argument array with
- // a new zeroth element that is set to bindName value.
- final MethodType methodType = methodHandle.type();
- final int parameterCount = methodType.parameterCount();
- final boolean isVarArg = parameterCount > 0 && methodType.parameterType(parameterCount - 1).isArray();
+ }
- if (isVarArg) {
- return MH.filterArguments(methodHandle, 1, MH.insertArguments(ADD_ZEROTH_ELEMENT, 1, bindName));
- } else {
- return MH.insertArguments(methodHandle, 1, bindName);
- }
+ // if it is vararg method, we need to extend argument array with
+ // a new zeroth element that is set to bindName value.
+ final MethodType methodType = methodHandle.type();
+ final int parameterCount = methodType.parameterCount();
+ final boolean isVarArg = parameterCount > 0 && methodType.parameterType(parameterCount - 1).isArray();
+
+ if (isVarArg) {
+ return MH.filterArguments(methodHandle, 1, MH.insertArguments(ADD_ZEROTH_ELEMENT, 1, bindName));
}
+ return MH.insertArguments(methodHandle, 1, bindName);
}
/**
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Aug 16 18:51:53 2013 +0200
@@ -2012,9 +2012,10 @@
final boolean scopeAccess = isScope() && NashornCallSiteDescriptor.isScope(desc);
if (find != null) {
- final Object value = getObjectValue(find);
- ScriptFunction func = null;
- MethodHandle methodHandle = null;
+ final Object value = getObjectValue(find);
+ ScriptFunction func = null;
+ MethodHandle methodHandle = null;
+
if (value instanceof ScriptFunction) {
func = (ScriptFunction)value;
methodHandle = getCallMethodHandle(func, desc.getMethodType(), name);
@@ -3219,6 +3220,11 @@
return property;
}
+ /**
+ * Write a value to a spill slot
+ * @param slot the slot index
+ * @param value the value
+ */
protected final void setSpill(final int slot, final Object value) {
if (spill == null) {
// create new spill.
@@ -3233,6 +3239,11 @@
spill[slot] = value;
}
+ /**
+ * Get a value from a spill slot
+ * @param slot the slot index
+ * @return the value in the spill slot with the given index
+ */
protected Object getSpill(final int slot) {
return spill != null && slot < spill.length ? spill[slot] : null;
}
--- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java Fri Aug 16 18:51:53 2013 +0200
@@ -132,7 +132,7 @@
}
if (obj instanceof List) {
- return new JavaListIterator((List)obj, includeUndefined);
+ return new JavaListIterator((List<?>)obj, includeUndefined);
}
if (obj != null && obj.getClass().isArray()) {
@@ -165,7 +165,7 @@
}
if (obj instanceof List) {
- return new ReverseJavaListIterator((List)obj, includeUndefined);
+ return new ReverseJavaListIterator((List<?>)obj, includeUndefined);
}
if (obj != null && obj.getClass().isArray()) {
--- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Fri Aug 16 18:51:53 2013 +0200
@@ -98,9 +98,8 @@
final int length = (int) length();
if (type == Double.class) {
return new NumberArrayData(LongArrayData.toDoubleArray(array, length), length);
- } else {
- return new ObjectArrayData(LongArrayData.toObjectArray(array, length), length);
}
+ return new ObjectArrayData(LongArrayData.toObjectArray(array, length), length);
}
@Override
--- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Fri Aug 16 18:51:53 2013 +0200
@@ -60,7 +60,7 @@
@Override
public ArrayData copy() {
- return new SparseArrayData(underlying.copy(), length(), new TreeMap<Long, Object>(sparseMap));
+ return new SparseArrayData(underlying.copy(), length(), new TreeMap<>(sparseMap));
}
@Override
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/BoundDynamicMethod.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/BoundDynamicMethod.java Fri Aug 16 18:51:53 2013 +0200
@@ -29,7 +29,7 @@
/**
* Represents a Dynalink dynamic method bound to a receiver. Note that objects of this class are just the tuples of
- * a method and a bound this, without any behavior. All the behavior is defined in the {@link BoundDynamicMethodLinker}.
+ * a method and a bound this, without any behavior. All the behavior is defined in the {@code BoundDynamicMethodLinker}.
*/
final class BoundDynamicMethod {
private final Object dynamicMethod;
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/BoundDynamicMethodLinker.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/BoundDynamicMethodLinker.java Fri Aug 16 18:51:53 2013 +0200
@@ -37,7 +37,7 @@
import jdk.internal.dynalink.support.Guards;
/**
- * Links {@link BoundDynamicMethod} objects. Passes through to Dynalink's BeansLinker for linking a dynamic method
+ * Links {@code BoundDynamicMethod} objects. Passes through to Dynalink's BeansLinker for linking a dynamic method
* (they only respond to "dyn:call"), and modifies the returned invocation to deal with the receiver binding.
*/
final class BoundDynamicMethodLinker implements TypeBasedGuardingDynamicLinker {
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java Fri Aug 16 13:42:44 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java Fri Aug 16 18:51:53 2013 +0200
@@ -114,9 +114,8 @@
if(name.equals(className)) {
assert classBytes != null : "what? already cleared .class bytes!!";
return defineClass(name, classBytes, 0, classBytes.length, GENERATED_PROTECTION_DOMAIN);
- } else {
- throw new ClassNotFoundException(name);
}
+ throw new ClassNotFoundException(name);
}
};
}