changeset 99:3245e174fe3a

8008351: Avoid using String.replace(String, String) in codegen Reviewed-by: sundar, attila
author hannesw
date Mon, 18 Feb 2013 10:36:18 +0100
parents d5f74bd2dc20
children f8221ce53c2e b6798a83dbd4
files src/jdk/nashorn/internal/codegen/Condition.java src/jdk/nashorn/internal/codegen/RuntimeCallSite.java src/jdk/nashorn/internal/ir/RuntimeNode.java
diffstat 3 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/codegen/Condition.java	Mon Feb 18 14:41:58 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/Condition.java	Mon Feb 18 10:36:18 2013 +0100
@@ -39,7 +39,6 @@
 import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLE;
 import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLT;
 import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPNE;
-import jdk.nashorn.internal.ir.RuntimeNode;
 
 /**
  * Condition enum used for all kinds of jumps, regardless of type
@@ -52,15 +51,6 @@
     GE,
     GT;
 
-    static Condition forRuntimeRequest(final RuntimeNode.Request request) {
-        try {
-            final String reqString = request.toString().replace("_STRICT", "");
-            return Condition.valueOf(reqString);
-        } catch (final IllegalArgumentException e) {
-            return null;
-        }
-    }
-
     static int toUnary(final Condition c) {
         switch (c) {
         case EQ:
@@ -81,10 +71,6 @@
         }
     }
 
-    static int toBinary(final Condition c) {
-        return toBinary(c, false);
-    }
-
     static int toBinary(final Condition c, final boolean isObject) {
         switch (c) {
         case EQ:
--- a/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Feb 18 14:41:58 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Feb 18 10:36:18 2013 +0100
@@ -279,7 +279,7 @@
                 // number and boolean are never strictly equal, e.g. 0 !== false
                 mh = MH.dropArguments(MH.constant(boolean.class, request == Request.NE_STRICT), 0, type().parameterArray());
             } else {
-                mh = METHODS.get(request.name().replace("_STRICT", "") + primitiveType.getSimpleName());
+                mh = METHODS.get(request.nonStrictName() + primitiveType.getSimpleName());
                 // unbox objects
 
                 for (int i = 0; i < type().parameterCount(); i++) {
--- a/src/jdk/nashorn/internal/ir/RuntimeNode.java	Mon Feb 18 14:41:58 2013 +0530
+++ b/src/jdk/nashorn/internal/ir/RuntimeNode.java	Mon Feb 18 10:36:18 2013 +0100
@@ -145,6 +145,22 @@
         }
 
         /**
+         * Get the non-strict name for this request.
+         *
+         * @return the name without _STRICT suffix
+         */
+        public String nonStrictName() {
+            switch(this) {
+            case NE_STRICT:
+                return NE.name();
+            case EQ_STRICT:
+                return EQ.name();
+            default:
+                return name();
+            }
+        }
+
+        /**
          * Is this an EQ or EQ_STRICT?
          *
          * @param request a request