simpler loop exit check (backwards is a loop exit, forwards is not)
authorshaver@mozilla.org
Sun, 20 Jul 2008 17:54:16 -0400
changeset 17774 d50e67202e36fadb0d5afc48e021ba11281d5fd3
parent 17773 3f22d73523c2444cc641cb299e28daad85484a37
child 17775 dcefd6872de80b0b3ee2f23af6d0104f37470548
child 17776 ace1904d319c80702a5f127264c9cbb269feba34
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherderautoland@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
simpler loop exit check (backwards is a loop exit, forwards is not)
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -1106,38 +1106,33 @@ js_StartRecorder(JSContext* cx, GuardRec
         return false;
     }
     return true;
 }
 
 static bool
 js_IsLoopExit(JSContext* cx, JSScript* script, jsbytecode* pc)
 {
-    /* figure out whether this side exit is exitting the loop and don't trace in that case */
-    jssrcnote* sn = js_GetSrcNote(script, pc);
-    JSSrcNoteType type = sn ? SN_TYPE(sn) : SRC_NULL;
-
     switch (*pc) {
+      case JSOP_LT:
+      case JSOP_GT:
+      case JSOP_LE:
+      case JSOP_GE:
+      case JSOP_NE:
+      case JSOP_EQ:
+        JS_ASSERT(js_CodeSpec[*pc].length == 1);
+        pc++;
+        /* FALL THROUGH */
       case JSOP_IFEQ:
-      case JSOP_IFEQX:
-        /* SRC_IF, SRC_IF_ELSE, and SRC_COND do not exit. */
-        return type != SRC_IF && type != SRC_IF_ELSE && type != SRC_COND;
-
       case JSOP_IFNE:
-      case JSOP_IFNEX:
-        /* This is the fall-through case of a loop condition, so we are exiting. */
-        return true;
-
-      case JSOP_GOTO:
-      case JSOP_GOTOX:
-        /* XXX break has no note but neither does goto around else */
-        return type == SRC_BREAK2LABEL || type == SRC_HIDDEN;
-
-      default:
-        return true;
+        ptrdiff_t offset = GET_JUMP_OFFSET(pc);
+        if (offset < 0)
+            return true;
+         break;
+      default:;
     }
     return false;
 }
 
 #define HOTLOOP 10
 #define HOTEXIT 0
 
 bool