8015961: Several small code-gardening fixes
authorattila
Wed, 05 Jun 2013 12:17:10 +0200
changeset 17982 03696682b6e5
parent 17981 9b8e085aa1fe
child 17983 4b1e3d565f9b
8015961: Several small code-gardening fixes Reviewed-by: lagergren, sundar
nashorn/src/jdk/nashorn/internal/codegen/Lower.java
nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java
nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java
nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java
nashorn/src/jdk/nashorn/internal/objects/NativeMath.java
nashorn/src/jdk/nashorn/internal/runtime/Context.java
nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java
nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java
--- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java	Wed Jun 05 12:17:10 2013 +0200
@@ -32,7 +32,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-
 import jdk.nashorn.internal.ir.BaseNode;
 import jdk.nashorn.internal.ir.BinaryNode;
 import jdk.nashorn.internal.ir.Block;
@@ -258,7 +257,7 @@
         return throwNode;
     }
 
-    private static Node ensureUniqueNamesIn(final LexicalContext lc, final Node node) {
+    private static Node ensureUniqueNamesIn(final Node node) {
         return node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
             @Override
             public Node leaveFunctionNode(final FunctionNode functionNode) {
@@ -273,10 +272,10 @@
         });
     }
 
-    private static List<Statement> copyFinally(final LexicalContext lc, final Block finallyBody) {
+    private static List<Statement> copyFinally(final Block finallyBody) {
         final List<Statement> newStatements = new ArrayList<>();
         for (final Statement statement : finallyBody.getStatements()) {
-            newStatements.add((Statement)ensureUniqueNamesIn(lc, statement));
+            newStatements.add((Statement)ensureUniqueNamesIn(statement));
             if (statement.hasTerminalFlags()) {
                 return newStatements;
             }
@@ -340,7 +339,7 @@
             @Override
             public Node leaveThrowNode(final ThrowNode throwNode) {
                 if (rethrows.contains(throwNode)) {
-                    final List<Statement> newStatements = copyFinally(lc, finallyBody);
+                    final List<Statement> newStatements = copyFinally(finallyBody);
                     if (!isTerminal(newStatements)) {
                         newStatements.add(throwNode);
                     }
@@ -374,7 +373,7 @@
                     resultNode = null;
                 }
 
-                newStatements.addAll(copyFinally(lc, finallyBody));
+                newStatements.addAll(copyFinally(finallyBody));
                 if (!isTerminal(newStatements)) {
                     newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode));
                 }
@@ -384,7 +383,7 @@
 
             private Node copy(final Statement endpoint, final Node targetNode) {
                 if (!insideTry.contains(targetNode)) {
-                    final List<Statement> newStatements = copyFinally(lc, finallyBody);
+                    final List<Statement> newStatements = copyFinally(finallyBody);
                     if (!isTerminal(newStatements)) {
                         newStatements.add(endpoint);
                     }
@@ -550,7 +549,7 @@
                 final FunctionNode currentFunction = lc.getCurrentFunction();
                 return callNode.setEvalArgs(
                     new CallNode.EvalArgs(
-                        ensureUniqueNamesIn(lc, args.get(0)).accept(this),
+                        ensureUniqueNamesIn(args.get(0)).accept(this),
                         compilerConstant(THIS),
                         evalLocation(callee),
                         currentFunction.isStrict()));
--- a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Wed Jun 05 12:17:10 2013 +0200
@@ -41,10 +41,10 @@
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.RuntimeNode;
 import jdk.nashorn.internal.ir.RuntimeNode.Request;
+import jdk.nashorn.internal.lookup.Lookup;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
-import jdk.nashorn.internal.lookup.Lookup;
-import jdk.nashorn.internal.lookup.MethodHandleFactory;
 
 /**
  * Optimistic call site that assumes its Object arguments to be of a boxed type.
@@ -333,6 +333,7 @@
      *
      * Do not call directly
      *
+     * @param name current name (with type) of runtime call at the call site
      * @return next wider specialization method for this RuntimeCallSite
      */
    public MethodHandle next(final String name) {
--- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java	Wed Jun 05 12:17:10 2013 +0200
@@ -30,7 +30,6 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import jdk.nashorn.internal.codegen.CompileUnit;
 import jdk.nashorn.internal.codegen.Compiler;
 import jdk.nashorn.internal.codegen.CompilerConstants;
@@ -385,7 +384,7 @@
      * @return function node or a new one if state was changed
      */
     public FunctionNode setState(final LexicalContext lc, final CompilationState state) {
-        if (this.compilationState.equals(state)) {
+        if (this.compilationState.contains(state)) {
             return this;
         }
         final EnumSet<CompilationState> newState = EnumSet.copyOf(this.compilationState);
--- a/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java	Wed Jun 05 12:17:10 2013 +0200
@@ -150,11 +150,11 @@
         if (this == obj) {
             return true;
         }
-        if (!(obj instanceof AccessorPropertyDescriptor)) {
+        if (!(obj instanceof GenericPropertyDescriptor)) {
             return false;
         }
 
-        final AccessorPropertyDescriptor other = (AccessorPropertyDescriptor)obj;
+        final GenericPropertyDescriptor other = (GenericPropertyDescriptor)obj;
         return ScriptRuntime.sameValue(configurable, other.configurable) &&
                ScriptRuntime.sameValue(enumerable, other.enumerable);
     }
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java	Wed Jun 05 12:17:10 2013 +0200
@@ -31,7 +31,6 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
 import jdk.nashorn.internal.objects.annotations.Where;
-import jdk.nashorn.internal.runtime.GlobalFunctions;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
--- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java	Wed Jun 05 12:17:10 2013 +0200
@@ -501,7 +501,7 @@
      *
      * @throws IOException if source cannot be found or loaded
      */
-    public Object loadWithNewGlobal(final Object from) throws IOException, RuntimeException {
+    public Object loadWithNewGlobal(final Object from) throws IOException {
         final ScriptObject oldGlobal = getGlobalTrusted();
         final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction<ScriptObject>() {
            @Override
--- a/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java	Wed Jun 05 12:17:10 2013 +0200
@@ -15,10 +15,11 @@
  * as dequeues, it's still slightly more efficient to be able to translate dequeue operations into pushes, pops, shifts,
  * and unshifts, than to blindly translate all list's add/remove operations into splices. Also, it is conceivable that a
  * custom script object that implements an Array-like API can have a background data representation that is optimized
- * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@pop} operate at the end of the array,
- * while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue {@link #push(Object)}
- * and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script operations respectively,
- * while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and {@code pop}.
+ * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@code pop} operate at the end of the
+ * array, while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue
+ * {@link #push(Object)} and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script
+ * operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and
+ * {@code pop}.
  */
 public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
     // These add to the back and front of the list
--- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java	Wed Jun 05 10:44:32 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java	Wed Jun 05 12:17:10 2013 +0200
@@ -23,23 +23,23 @@
 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup;
 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase;
 
-import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode;
+import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode;
 import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode;
-import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.CCSTATE;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.CCVALTYPE;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType;
+import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType;
 
 class Parser extends Lexer {