Wed, 05 Jun 2013 12:17:10 +0200
8015961: Several small code-gardening fixes
Reviewed-by: lagergren, sundar
1.1 --- a/src/jdk/nashorn/internal/codegen/Lower.java Wed Jun 05 10:44:32 2013 +0200 1.2 +++ b/src/jdk/nashorn/internal/codegen/Lower.java Wed Jun 05 12:17:10 2013 +0200 1.3 @@ -32,7 +32,6 @@ 1.4 import java.util.ArrayList; 1.5 import java.util.Arrays; 1.6 import java.util.List; 1.7 - 1.8 import jdk.nashorn.internal.ir.BaseNode; 1.9 import jdk.nashorn.internal.ir.BinaryNode; 1.10 import jdk.nashorn.internal.ir.Block; 1.11 @@ -258,7 +257,7 @@ 1.12 return throwNode; 1.13 } 1.14 1.15 - private static Node ensureUniqueNamesIn(final LexicalContext lc, final Node node) { 1.16 + private static Node ensureUniqueNamesIn(final Node node) { 1.17 return node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 1.18 @Override 1.19 public Node leaveFunctionNode(final FunctionNode functionNode) { 1.20 @@ -273,10 +272,10 @@ 1.21 }); 1.22 } 1.23 1.24 - private static List<Statement> copyFinally(final LexicalContext lc, final Block finallyBody) { 1.25 + private static List<Statement> copyFinally(final Block finallyBody) { 1.26 final List<Statement> newStatements = new ArrayList<>(); 1.27 for (final Statement statement : finallyBody.getStatements()) { 1.28 - newStatements.add((Statement)ensureUniqueNamesIn(lc, statement)); 1.29 + newStatements.add((Statement)ensureUniqueNamesIn(statement)); 1.30 if (statement.hasTerminalFlags()) { 1.31 return newStatements; 1.32 } 1.33 @@ -340,7 +339,7 @@ 1.34 @Override 1.35 public Node leaveThrowNode(final ThrowNode throwNode) { 1.36 if (rethrows.contains(throwNode)) { 1.37 - final List<Statement> newStatements = copyFinally(lc, finallyBody); 1.38 + final List<Statement> newStatements = copyFinally(finallyBody); 1.39 if (!isTerminal(newStatements)) { 1.40 newStatements.add(throwNode); 1.41 } 1.42 @@ -374,7 +373,7 @@ 1.43 resultNode = null; 1.44 } 1.45 1.46 - newStatements.addAll(copyFinally(lc, finallyBody)); 1.47 + newStatements.addAll(copyFinally(finallyBody)); 1.48 if (!isTerminal(newStatements)) { 1.49 newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode)); 1.50 } 1.51 @@ -384,7 +383,7 @@ 1.52 1.53 private Node copy(final Statement endpoint, final Node targetNode) { 1.54 if (!insideTry.contains(targetNode)) { 1.55 - final List<Statement> newStatements = copyFinally(lc, finallyBody); 1.56 + final List<Statement> newStatements = copyFinally(finallyBody); 1.57 if (!isTerminal(newStatements)) { 1.58 newStatements.add(endpoint); 1.59 } 1.60 @@ -550,7 +549,7 @@ 1.61 final FunctionNode currentFunction = lc.getCurrentFunction(); 1.62 return callNode.setEvalArgs( 1.63 new CallNode.EvalArgs( 1.64 - ensureUniqueNamesIn(lc, args.get(0)).accept(this), 1.65 + ensureUniqueNamesIn(args.get(0)).accept(this), 1.66 compilerConstant(THIS), 1.67 evalLocation(callee), 1.68 currentFunction.isStrict()));
2.1 --- a/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java Wed Jun 05 10:44:32 2013 +0200 2.2 +++ b/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java Wed Jun 05 12:17:10 2013 +0200 2.3 @@ -41,10 +41,10 @@ 2.4 import jdk.nashorn.internal.codegen.types.Type; 2.5 import jdk.nashorn.internal.ir.RuntimeNode; 2.6 import jdk.nashorn.internal.ir.RuntimeNode.Request; 2.7 +import jdk.nashorn.internal.lookup.Lookup; 2.8 +import jdk.nashorn.internal.lookup.MethodHandleFactory; 2.9 import jdk.nashorn.internal.runtime.ScriptRuntime; 2.10 import jdk.nashorn.internal.runtime.linker.Bootstrap; 2.11 -import jdk.nashorn.internal.lookup.Lookup; 2.12 -import jdk.nashorn.internal.lookup.MethodHandleFactory; 2.13 2.14 /** 2.15 * Optimistic call site that assumes its Object arguments to be of a boxed type. 2.16 @@ -333,6 +333,7 @@ 2.17 * 2.18 * Do not call directly 2.19 * 2.20 + * @param name current name (with type) of runtime call at the call site 2.21 * @return next wider specialization method for this RuntimeCallSite 2.22 */ 2.23 public MethodHandle next(final String name) {
3.1 --- a/src/jdk/nashorn/internal/ir/FunctionNode.java Wed Jun 05 10:44:32 2013 +0200 3.2 +++ b/src/jdk/nashorn/internal/ir/FunctionNode.java Wed Jun 05 12:17:10 2013 +0200 3.3 @@ -30,7 +30,6 @@ 3.4 import java.util.HashSet; 3.5 import java.util.List; 3.6 import java.util.Set; 3.7 - 3.8 import jdk.nashorn.internal.codegen.CompileUnit; 3.9 import jdk.nashorn.internal.codegen.Compiler; 3.10 import jdk.nashorn.internal.codegen.CompilerConstants; 3.11 @@ -385,7 +384,7 @@ 3.12 * @return function node or a new one if state was changed 3.13 */ 3.14 public FunctionNode setState(final LexicalContext lc, final CompilationState state) { 3.15 - if (this.compilationState.equals(state)) { 3.16 + if (this.compilationState.contains(state)) { 3.17 return this; 3.18 } 3.19 final EnumSet<CompilationState> newState = EnumSet.copyOf(this.compilationState);
4.1 --- a/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Wed Jun 05 10:44:32 2013 +0200 4.2 +++ b/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Wed Jun 05 12:17:10 2013 +0200 4.3 @@ -150,11 +150,11 @@ 4.4 if (this == obj) { 4.5 return true; 4.6 } 4.7 - if (!(obj instanceof AccessorPropertyDescriptor)) { 4.8 + if (!(obj instanceof GenericPropertyDescriptor)) { 4.9 return false; 4.10 } 4.11 4.12 - final AccessorPropertyDescriptor other = (AccessorPropertyDescriptor)obj; 4.13 + final GenericPropertyDescriptor other = (GenericPropertyDescriptor)obj; 4.14 return ScriptRuntime.sameValue(configurable, other.configurable) && 4.15 ScriptRuntime.sameValue(enumerable, other.enumerable); 4.16 }
5.1 --- a/src/jdk/nashorn/internal/objects/NativeMath.java Wed Jun 05 10:44:32 2013 +0200 5.2 +++ b/src/jdk/nashorn/internal/objects/NativeMath.java Wed Jun 05 12:17:10 2013 +0200 5.3 @@ -31,7 +31,6 @@ 5.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 5.5 import jdk.nashorn.internal.objects.annotations.SpecializedFunction; 5.6 import jdk.nashorn.internal.objects.annotations.Where; 5.7 -import jdk.nashorn.internal.runtime.GlobalFunctions; 5.8 import jdk.nashorn.internal.runtime.JSType; 5.9 import jdk.nashorn.internal.runtime.ScriptObject; 5.10
6.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Wed Jun 05 10:44:32 2013 +0200 6.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Wed Jun 05 12:17:10 2013 +0200 6.3 @@ -501,7 +501,7 @@ 6.4 * 6.5 * @throws IOException if source cannot be found or loaded 6.6 */ 6.7 - public Object loadWithNewGlobal(final Object from) throws IOException, RuntimeException { 6.8 + public Object loadWithNewGlobal(final Object from) throws IOException { 6.9 final ScriptObject oldGlobal = getGlobalTrusted(); 6.10 final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction<ScriptObject>() { 6.11 @Override
7.1 --- a/src/jdk/nashorn/internal/runtime/ListAdapter.java Wed Jun 05 10:44:32 2013 +0200 7.2 +++ b/src/jdk/nashorn/internal/runtime/ListAdapter.java Wed Jun 05 12:17:10 2013 +0200 7.3 @@ -15,10 +15,11 @@ 7.4 * as dequeues, it's still slightly more efficient to be able to translate dequeue operations into pushes, pops, shifts, 7.5 * and unshifts, than to blindly translate all list's add/remove operations into splices. Also, it is conceivable that a 7.6 * custom script object that implements an Array-like API can have a background data representation that is optimized 7.7 - * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@pop} operate at the end of the array, 7.8 - * while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue {@link #push(Object)} 7.9 - * and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script operations respectively, 7.10 - * while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and {@code pop}. 7.11 + * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@code pop} operate at the end of the 7.12 + * array, while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue 7.13 + * {@link #push(Object)} and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script 7.14 + * operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and 7.15 + * {@code pop}. 7.16 */ 7.17 public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> { 7.18 // These add to the back and front of the list
8.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Wed Jun 05 10:44:32 2013 +0200 8.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Wed Jun 05 12:17:10 2013 +0200 8.3 @@ -23,23 +23,23 @@ 8.4 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; 8.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; 8.6 8.7 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 8.8 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 8.9 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode; 8.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 8.11 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 8.12 +import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg; 8.13 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 8.14 import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 8.15 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 8.16 import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode; 8.17 import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode; 8.18 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg; 8.19 import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; 8.20 import jdk.nashorn.internal.runtime.regexp.joni.constants.CCSTATE; 8.21 import jdk.nashorn.internal.runtime.regexp.joni.constants.CCVALTYPE; 8.22 import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType; 8.23 import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType; 8.24 import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType; 8.25 +import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 8.26 8.27 class Parser extends Lexer { 8.28