Bug 1266835 - Request names from the rootlist in JS::ubi::dumpPaths and clean up formatting of dumped paths. r=jimb
authorNick Fitzgerald <fitzgen@gmail.com>
Fri, 22 Apr 2016 16:26:49 -0700
changeset 332592 46d7944da8164967f132428b6d59f32311fac94e
parent 332591 94ec70bf8c2297109611568159521fd8dfb3a98c
child 332593 c69d01fb9aaae166a5d2055bfb75f622f58adb4d
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs1266835
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1266835 - Request names from the rootlist in JS::ubi::dumpPaths and clean up formatting of dumped paths. r=jimb
js/src/jsstr.cpp
js/src/jsstr.h
js/src/vm/UbiNodeShortestPaths.cpp
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -3080,16 +3080,26 @@ js_strcmp(const char16_t* lhs, const cha
         if (*lhs != *rhs)
             return int32_t(*lhs) - int32_t(*rhs);
         if (*lhs == 0)
             return 0;
         ++lhs, ++rhs;
     }
 }
 
+int32_t
+js_fputs(const char16_t* s, FILE* f)
+{
+    while (*s != 0) {
+        if (fputwc(wchar_t(*s), f) == WEOF)
+            return WEOF;
+    }
+    return 1;
+}
+
 UniqueChars
 js::DuplicateString(js::ExclusiveContext* cx, const char* s)
 {
     size_t n = strlen(s) + 1;
     auto ret = cx->make_pod_array<char>(n);
     if (!ret)
         return ret;
     PodCopy(ret.get(), s, n);
--- a/js/src/jsstr.h
+++ b/js/src/jsstr.h
@@ -5,16 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jsstr_h
 #define jsstr_h
 
 #include "mozilla/HashFunctions.h"
 #include "mozilla/PodOperations.h"
 
+#include <stdio.h>
+
 #include "jsutil.h"
 #include "NamespaceImports.h"
 
 #include "gc/Rooting.h"
 #include "js/RootingAPI.h"
 #include "js/UniquePtr.h"
 #include "vm/Printer.h"
 #include "vm/Unicode.h"
@@ -106,16 +108,19 @@ extern const CharT*
 js_strchr_limit(const CharT* s, char16_t c, const CharT* limit);
 
 static MOZ_ALWAYS_INLINE void
 js_strncpy(char16_t* dst, const char16_t* src, size_t nelem)
 {
     return mozilla::PodCopy(dst, src, nelem);
 }
 
+extern int32_t
+js_fputs(const char16_t* s, FILE* f);
+
 namespace js {
 
 /* Initialize the String class, returning its prototype object. */
 extern JSObject*
 InitStringClass(JSContext* cx, HandleObject obj);
 
 /*
  * Convert a value to a printable C string.
--- a/js/src/vm/UbiNodeShortestPaths.cpp
+++ b/js/src/vm/UbiNodeShortestPaths.cpp
@@ -33,46 +33,52 @@ BackEdge::clone() const
 #ifdef DEBUG
 JS_PUBLIC_API(void)
 dumpPaths(JSRuntime* rt, Node node, uint32_t maxNumPaths /* = 10 */)
 {
     mozilla::Maybe<AutoCheckCannotGC> nogc;
 
     JS::ubi::RootList rootList(rt, nogc);
     MOZ_ASSERT(rootList.init());
+    rootList.wantNames = true;
 
     NodeSet targets;
     bool ok = targets.init() && targets.putNew(node);
     MOZ_ASSERT(ok);
 
     auto paths = ShortestPaths::Create(rt, nogc.ref(), maxNumPaths, &rootList, mozilla::Move(targets));
     MOZ_ASSERT(paths.isSome());
 
     int i = 0;
     ok = paths->forEachPath(node, [&](Path& path) {
         fprintf(stderr, "Path %d:\n", i++);
         for (auto backEdge : path) {
-            fprintf(stderr, "    predecessor = %p\n", (void*) backEdge->predecessor().identifier());
+            fprintf(stderr, "    %p ", (void*) backEdge->predecessor().identifier());
+
+            js_fputs(backEdge->predecessor().typeName(), stderr);
+            fprintf(stderr, "\n");
+
             fprintf(stderr, "            |\n");
             fprintf(stderr, "            |\n");
             fprintf(stderr, "        '");
 
             const char16_t* name = backEdge->name().get();
             if (!name)
                 name = (const char16_t*) MOZ_UTF16("<no edge name>");
-            auto len = js_strlen(name);
-            for (size_t i = 0; i < len; i++)
-                fprintf(stderr, "%c", char(name[i]));
+            js_fputs(name, stderr);
             fprintf(stderr, "'\n");
 
             fprintf(stderr, "            |\n");
             fprintf(stderr, "            V\n");
         }
 
-        fprintf(stderr, "    target = %p\n\n\n", (void*) node.identifier());
+        fprintf(stderr, "    %p ", (void*) node.identifier());
+        js_fputs(node.typeName(), stderr);
+        fprintf(stderr, "\n\n");
+
         return true;
     });
     MOZ_ASSERT(ok);
 }
 #endif
 
 } // namespace ubi
 } // namespace JS