Commit 51c5d913 authored by alph's avatar alph Committed by Commit bot

[tracing] Use locale independent writer for FP values.

BUG=5820
LOG=N

Review-Url: https://codereview.chromium.org/2628463002
Cr-Commit-Position: refs/heads/master@{#42256}
parent 9856ca24
......@@ -5,6 +5,7 @@
#include "src/tracing/traced-value.h"
#include "src/base/platform/platform.h"
#include "src/conversions.h"
namespace v8 {
namespace tracing {
......@@ -80,7 +81,8 @@ void TracedValue::SetInteger(const char* name, int value) {
void TracedValue::SetDouble(const char* name, double value) {
DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict);
WriteName(name);
data_ += std::to_string(value);
i::EmbeddedVector<char, 100> buffer;
data_ += DoubleToCString(value, buffer);
}
void TracedValue::SetBoolean(const char* name, bool value) {
......@@ -120,7 +122,8 @@ void TracedValue::AppendInteger(int value) {
void TracedValue::AppendDouble(double value) {
DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray);
WriteComma();
data_ += std::to_string(value);
i::EmbeddedVector<char, 100> buffer;
data_ += DoubleToCString(value, buffer);
}
void TracedValue::AppendBoolean(bool value) {
......
......@@ -16,7 +16,7 @@ TEST(FlatDictionary) {
std::string json = "PREFIX";
value->AppendAsTraceFormat(&json);
CHECK_EQ(
"PREFIX{\"int\":2014,\"double\":0.000000,\"bool\":true,\"string\":"
"PREFIX{\"int\":2014,\"double\":0,\"bool\":true,\"string\":"
"\"string\"}",
json);
}
......@@ -24,13 +24,13 @@ TEST(FlatDictionary) {
TEST(NoDotPathExpansion) {
auto value = TracedValue::Create();
value->SetInteger("in.t", 2014);
value->SetDouble("doub.le", 0.0);
value->SetDouble("doub.le", -20.25);
value->SetBoolean("bo.ol", true);
value->SetString("str.ing", "str.ing");
std::string json;
value->AppendAsTraceFormat(&json);
CHECK_EQ(
"{\"in.t\":2014,\"doub.le\":0.000000,\"bo.ol\":true,\"str.ing\":\"str."
"{\"in.t\":2014,\"doub.le\":-20.25,\"bo.ol\":true,\"str.ing\":\"str."
"ing\"}",
json);
}
......@@ -46,6 +46,7 @@ TEST(Hierarchy) {
value->SetString("s1", "foo");
value->EndDictionary();
value->SetDouble("d0", 0.0);
value->SetDouble("d1", 10.5);
value->SetBoolean("b0", true);
value->BeginArray("a1");
value->AppendInteger(1);
......@@ -69,8 +70,8 @@ TEST(Hierarchy) {
value->AppendAsTraceFormat(&json);
CHECK_EQ(
"{\"i0\":2014,\"dict1\":{\"i1\":2014,\"dict2\":{\"b2\":false},"
"\"s1\":\"foo\"},\"d0\":0.000000,\"b0\":true,\"a1\":[1,true,{\"i2\":3}],"
"\"s0\":\"foo\",\"arr1\":[{},[],{}]}",
"\"s1\":\"foo\"},\"d0\":0,\"d1\":10.5,\"b0\":true,\"a1\":[1,true,{\"i2\":"
"3}],\"s0\":\"foo\",\"arr1\":[{},[],{}]}",
json);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment