From 8454eeb72d60cf460265ca1d3c12a6062f157477 Mon Sep 17 00:00:00 2001 From: "mikhail.naganov@gmail.com" Date: Fri, 2 Mar 2012 15:31:04 +0000 Subject: [PATCH] Fix corrupted snapshot serializaton on ia32. BUG=v8/1985 TEST=none Review URL: https://chromiumcodereview.appspot.com/9582006 Patch from Alexei Filippov . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10910 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/profile-generator.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/profile-generator.cc b/src/profile-generator.cc index dd2f7014d..39f8ff3c9 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -3490,6 +3490,9 @@ void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge) { || edge->type() == HeapGraphEdge::kHidden || edge->type() == HeapGraphEdge::kWeak ? edge->index() : GetStringId(edge->name()); + STATIC_CHECK(sizeof(int) == sizeof(edge->type())); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(edge_name_or_index)); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(GetNodeId(edge->to()))); // NOLINT int result = OS::SNPrintF(buffer, ",%d,%d,%d", edge->type(), edge_name_or_index, GetNodeId(edge->to())); USE(result); @@ -3499,12 +3502,21 @@ void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge) { void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) { - // The buffer needs space for 7 ints, 7 commas, \n and \0 + // The buffer needs space for 6 ints, 1 uint64_t, 7 commas, \n and \0 static const int kBufferSize = - MaxDecimalDigitsIn::kSigned * 7 + 7 + 1 + 1; // NOLINT + 6 * MaxDecimalDigitsIn::kSigned // NOLINT + + MaxDecimalDigitsIn::kUnsigned // NOLINT + + 7 + 1 + 1; EmbeddedVector buffer; Vector children = entry->children(); - int result = OS::SNPrintF(buffer, "\n,%d,%d,%d,%d,%d,%d,%d", + STATIC_CHECK(sizeof(int) == sizeof(entry->type())); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(GetStringId(entry->name()))); // NOLINT + STATIC_CHECK(sizeof(uint64_t) == sizeof(entry->id())); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(entry->self_size())); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(entry->retained_size())); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(GetNodeId(entry->dominator()))); // NOLINT + STATIC_CHECK(sizeof(int) == sizeof(children.length())); // NOLINT + int result = OS::SNPrintF(buffer, "\n,%d,%d,%llu,%d,%d,%d,%d", entry->type(), GetStringId(entry->name()), entry->id(), -- 2.34.1