Bug 1364442 - Remove more locale-sensitive JSON output paths, r=jonco
authorSteve Fink <sfink@mozilla.com>
Fri, 12 May 2017 09:04:59 -0700
changeset 358447 ef32458f11b8d1d9e6b0eb5a5ee815dd4fcb653f
parent 358446 3e8a6417ebd4ce7b5af18ed7e33d15e20b9942e0
child 358448 8755d3eb143b65c66330f9f4d3c4473ef893545e
push id31825
push userkwierso@gmail.com
push dateMon, 15 May 2017 23:22:30 +0000
treeherdermozilla-central@3e166b683893 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1364442
milestone55.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 1364442 - Remove more locale-sensitive JSON output paths, r=jonco MozReview-Commit-ID: 1k3DIXGAW8s
js/src/gc/Nursery.cpp
js/src/jit/CacheIRSpewer.cpp
js/src/vm/JSONPrinter.cpp
js/src/vm/JSONPrinter.h
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -504,17 +504,17 @@ js::Nursery::renderProfileJSON(JSONPrint
 #define EXTRACT_NAME(name, text) #name,
     static const char* names[] = {
 FOR_EACH_NURSERY_PROFILE_TIME(EXTRACT_NAME)
 #undef EXTRACT_NAME
     "" };
 
     size_t i = 0;
     for (auto time : profileDurations_)
-        json.property(names[i++], time.ToMicroseconds());
+        json.property(names[i++], time, json.MICROSECONDS);
 
     json.endObject();
 }
 
 /* static */ void
 js::Nursery::printProfileHeader()
 {
     fprintf(stderr, "MinorGC:               Reason  PRate Size ");
--- a/js/src/jit/CacheIRSpewer.cpp
+++ b/js/src/jit/CacheIRSpewer.cpp
@@ -133,17 +133,17 @@ CacheIRSpewer::valueProperty(LockGuard<M
     const char* type = InformalValueTypeName(v);
     if (v.isInt32())
         type = "int32";
     j.property("type", type);
 
     if (v.isInt32()) {
         j.property("value", v.toInt32());
     } else if (v.isDouble()) {
-        j.property("value", v.toDouble());
+        j.floatProperty("value", v.toDouble(), 3);
     } else if (v.isString() || v.isSymbol()) {
         JSString* str = v.isString() ? v.toString() : v.toSymbol()->description();
         if (str && str->isLinear()) {
             j.beginStringProperty("value");
             QuoteString(output, &str->asLinear());
             j.endStringProperty();
         }
     } else if (v.isObject()) {
--- a/js/src/vm/JSONPrinter.cpp
+++ b/js/src/vm/JSONPrinter.cpp
@@ -163,26 +163,16 @@ void
 JSONPrinter::property(const char* name, size_t value)
 {
     propertyName(name);
     out_.printf("%" PRIuSIZE, value);
 }
 #endif
 
 void
-JSONPrinter::property(const char* name, double value)
-{
-    propertyName(name);
-    if (mozilla::IsFinite(value))
-        out_.printf("%f", value);
-    else
-        out_.printf("null");
-}
-
-void
 JSONPrinter::floatProperty(const char* name, double value, size_t precision)
 {
     if (!mozilla::IsFinite(value)) {
         propertyName(name);
         out_.printf("null");
         return;
     }
 
@@ -202,25 +192,32 @@ JSONPrinter::floatProperty(const char* n
     }
 
     property(name, str);
 }
 
 void
 JSONPrinter::property(const char* name, const mozilla::TimeDuration& dur, TimePrecision precision)
 {
+    if (precision == MICROSECONDS) {
+        property(name, static_cast<int64_t>(dur.ToMicroseconds()));
+        return;
+    }
+
     propertyName(name);
     lldiv_t split;
     switch (precision) {
       case SECONDS:
         split = lldiv(static_cast<int64_t>(dur.ToMilliseconds()), 1000);
         break;
       case MILLISECONDS:
         split = lldiv(static_cast<int64_t>(dur.ToMicroseconds()), 1000);
         break;
+      case MICROSECONDS:
+        MOZ_ASSERT_UNREACHABLE("");
     };
     out_.printf("%llu.%03llu", split.quot, split.rem);
 }
 
 void
 JSONPrinter::endObject()
 {
     indentLevel_--;
--- a/js/src/vm/JSONPrinter.h
+++ b/js/src/vm/JSONPrinter.h
@@ -52,23 +52,22 @@ class JSONPrinter
     void property(const char* name, int64_t value);
     void property(const char* name, uint64_t value);
 #ifdef XP_DARWIN
     // On OSX, size_t is long unsigned, uint32_t is unsigned, and uint64_t is
     // long long unsigned. Everywhere else, size_t matches either uint32_t or
     // uint64_t.
     void property(const char* name, size_t value);
 #endif
-    void property(const char* name, double value);
 
     void formatProperty(const char* name, const char* format, ...) MOZ_FORMAT_PRINTF(3, 4);
 
     // JSON requires decimals to be separated by periods, but the LC_NUMERIC
     // setting may cause printf to use commas in some locales.
-    enum TimePrecision { SECONDS, MILLISECONDS };
+    enum TimePrecision { SECONDS, MILLISECONDS, MICROSECONDS };
     void property(const char* name, const mozilla::TimeDuration& dur, TimePrecision precision);
 
     void floatProperty(const char* name, double value, size_t precision);
 
     void beginStringProperty(const char* name);
     void endStringProperty();
 
     void endObject();