Bug 610815 - TM: print more info for guards in LIR dumps. r=bz.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 10 Nov 2010 14:23:37 -0800
changeset 57765 5d993887eca608e1defc469b7262d7912dfcf611
parent 57764 67a69685dc564c8c660b844487083983dd9125c1
child 57766 c498f1a7eb3bc4948f5d17b3d455d357b2e84b26
child 57767 0e57e014bc91b83d4bb66a6270c62b2fbdc9b8a0
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbz
bugs610815
milestone2.0b8pre
Bug 610815 - TM: print more info for guards in LIR dumps. r=bz.
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -102,16 +102,36 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <string.h>
 #include <elf.h>
 #endif
 
+#ifdef DEBUG
+namespace js {
+static const char*
+getExitName(ExitType type)
+{
+    static const char* exitNames[] =
+    {
+    #define MAKE_EXIT_STRING(x) #x,
+    JS_TM_EXITCODES(MAKE_EXIT_STRING)
+    #undef MAKE_EXIT_STRING
+    NULL
+    };
+
+    JS_ASSERT(type < TOTAL_EXIT_TYPES);
+
+    return exitNames[type];
+}
+}
+#endif /* DEBUG */
+
 namespace nanojit {
 using namespace js;
 using namespace js::gc;
 using namespace js::tjit;
 
 /* Implement embedder-specific nanojit members. */
 
 void*
@@ -146,49 +166,63 @@ nanojit::Allocator::postReset() {
 int
 StackFilter::getTop(LIns* guard)
 {
     VMSideExit* e = (VMSideExit*)guard->record()->exit;
     return e->sp_adj;
 }
 
 #if defined NJ_VERBOSE
+static void
+formatGuardExit(InsBuf *buf, LIns *ins)
+{
+    VMSideExit *x = (VMSideExit *)ins->record()->exit;
+    RefBuf b1;
+    if (LogController.lcbits & LC_FragProfile)
+        VMPI_snprintf(b1.buf, b1.len, " (GuardID=%03d)", ins->record()->profGuardID);
+    else
+        b1.buf[0] = '\0';
+    VMPI_snprintf(buf->buf, buf->len,
+                  " -> exit=%p pc=%p imacpc=%p sp%+ld rp%+ld %s%s",
+                  (void *)x,
+                  (void *)x->pc,
+                  (void *)x->imacpc,
+                  (long int)x->sp_adj,
+                  (long int)x->rp_adj,
+                  getExitName(x->exitType),
+                  b1.buf);
+}
+
 void
 LInsPrinter::formatGuard(InsBuf *buf, LIns *ins)
 {
     RefBuf b1, b2;
-    VMSideExit *x = (VMSideExit *)ins->record()->exit;
+    InsBuf b3;
+    formatGuardExit(&b3, ins);
     VMPI_snprintf(buf->buf, buf->len,
-            "%s: %s %s -> pc=%p imacpc=%p sp%+ld rp%+ld (GuardID=%03d)",
-            formatRef(&b1, ins),
-            lirNames[ins->opcode()],
-            ins->oprnd1() ? formatRef(&b2, ins->oprnd1()) : "",
-            (void *)x->pc,
-            (void *)x->imacpc,
-            (long int)x->sp_adj,
-            (long int)x->rp_adj,
-            ins->record()->profGuardID);
+                  "%s: %s %s%s",
+                  formatRef(&b1, ins),
+                  lirNames[ins->opcode()],
+                  ins->oprnd1() ? formatRef(&b2, ins->oprnd1()) : "",
+                  b3.buf);
 }
 
 void
 LInsPrinter::formatGuardXov(InsBuf *buf, LIns *ins)
 {
     RefBuf b1, b2, b3;
-    VMSideExit *x = (VMSideExit *)ins->record()->exit;
+    InsBuf b4;
+    formatGuardExit(&b4, ins);
     VMPI_snprintf(buf->buf, buf->len,
-            "%s = %s %s, %s -> pc=%p imacpc=%p sp%+ld rp%+ld (GuardID=%03d)",
-            formatRef(&b1, ins),
-            lirNames[ins->opcode()],
-            formatRef(&b2, ins->oprnd1()),
-            formatRef(&b3, ins->oprnd2()),
-            (void *)x->pc,
-            (void *)x->imacpc,
-            (long int)x->sp_adj,
-            (long int)x->rp_adj,
-            ins->record()->profGuardID);
+                  "%s = %s %s, %s%s",
+                  formatRef(&b1, ins),
+                  lirNames[ins->opcode()],
+                  formatRef(&b2, ins->oprnd1()),
+                  formatRef(&b3, ins->oprnd2()),
+                  b4.buf);
 }
 
 const char*
 nanojit::LInsPrinter::accNames[] = {
     "state",        // (1 <<  0) == ACCSET_STATE
     "sp",           // (1 <<  1) == ACCSET_STACK
     "rp",           // (1 <<  2) == ACCSET_RSTACK
     "cx",           // (1 <<  3) == ACCSET_CX
@@ -801,32 +835,16 @@ FragProfiling_showResults(TraceMonitor* 
     tm->profTab = NULL;
 }
 
 #endif
 
 /* ----------------------------------------------------------------- */
 
 #ifdef DEBUG
-static const char*
-getExitName(ExitType type)
-{
-    static const char* exitNames[] =
-    {
-    #define MAKE_EXIT_STRING(x) #x,
-    JS_TM_EXITCODES(MAKE_EXIT_STRING)
-    #undef MAKE_EXIT_STRING
-    NULL
-    };
-
-    JS_ASSERT(type < TOTAL_EXIT_TYPES);
-
-    return exitNames[type];
-}
-
 static JSBool FASTCALL
 PrintOnTrace(char* format, uint32 argc, double *argv)
 {
     union {
         struct {
             uint32 lo;
             uint32 hi;
         } i;