From ed0ceee589f6d7b6d64ef1fcfdf42c9f83f07fb5 Mon Sep 17 00:00:00 2001 From: "loislo@chromium.org" Date: Sun, 11 Mar 2012 06:12:10 +0000 Subject: [PATCH] Revert "We have a problem with really big apps. The snapshot for such pages doesn't fit into JS heap on DevTools front-end side. I'd like to move the snapshot's nodes data into Int32Array." This reverts commit 8c08ecc2782d5a8c60eb0692ec8f13d6da3cdc58. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9666038 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10995 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/profile-generator-inl.h | 6 +++--- src/profile-generator.cc | 43 +++++++++++++++++++++---------------------- src/profile-generator.h | 42 ++++++++++++++++++++---------------------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/profile-generator-inl.h b/src/profile-generator-inl.h index d967ed3..7a70b01 100644 --- a/src/profile-generator-inl.h +++ b/src/profile-generator-inl.h @@ -95,7 +95,7 @@ CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { } -SnapshotObjectId HeapObjectsMap::GetNthGcSubrootId(int delta) { +uint64_t HeapObjectsMap::GetNthGcSubrootId(int delta) { return kGcRootsFirstSubrootId + delta * kObjectIdStep; } @@ -115,10 +115,10 @@ int V8HeapExplorer::GetGcSubrootOrder(HeapObject* subroot) { } -SnapshotObjectId HeapEntry::id() { +uint64_t HeapEntry::id() { union { Id stored_id; - SnapshotObjectId returned_id; + uint64_t returned_id; } id_adaptor = {id_}; return id_adaptor.returned_id; } diff --git a/src/profile-generator.cc b/src/profile-generator.cc index c4148f9..14349cc 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -965,7 +965,7 @@ HeapEntry* HeapGraphEdge::From() { void HeapEntry::Init(HeapSnapshot* snapshot, Type type, const char* name, - SnapshotObjectId id, + uint64_t id, int self_size, int children_count, int retainers_count) { @@ -980,7 +980,7 @@ void HeapEntry::Init(HeapSnapshot* snapshot, dominator_ = NULL; union { - SnapshotObjectId set_id; + uint64_t set_id; Id stored_id; } id_adaptor = {id}; id_ = id_adaptor.stored_id; @@ -1221,7 +1221,7 @@ HeapEntry* HeapSnapshot::AddGcSubrootEntry(int tag, HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type, const char* name, - SnapshotObjectId id, + uint64_t id, int size, int children_count, int retainers_count) { @@ -1253,7 +1253,7 @@ HeapEntry* HeapSnapshot::GetNextEntryToInit() { } -HeapEntry* HeapSnapshot::GetEntryById(SnapshotObjectId id) { +HeapEntry* HeapSnapshot::GetEntryById(uint64_t id) { List* entries_by_id = GetSortedEntriesList(); // Perform a binary search by id. @@ -1262,7 +1262,7 @@ HeapEntry* HeapSnapshot::GetEntryById(SnapshotObjectId id) { while (low <= high) { int mid = (static_cast(low) + static_cast(high)) >> 1; - SnapshotObjectId mid_id = entries_by_id->at(mid)->id(); + uint64_t mid_id = entries_by_id->at(mid)->id(); if (mid_id > id) high = mid - 1; else if (mid_id < id) @@ -1298,12 +1298,12 @@ void HeapSnapshot::Print(int max_depth) { // We split IDs on evens for embedder objects (see // HeapObjectsMap::GenerateId) and odds for native objects. -const SnapshotObjectId HeapObjectsMap::kInternalRootObjectId = 1; -const SnapshotObjectId HeapObjectsMap::kGcRootsObjectId = +const uint64_t HeapObjectsMap::kInternalRootObjectId = 1; +const uint64_t HeapObjectsMap::kGcRootsObjectId = HeapObjectsMap::kInternalRootObjectId + HeapObjectsMap::kObjectIdStep; -const SnapshotObjectId HeapObjectsMap::kGcRootsFirstSubrootId = +const uint64_t HeapObjectsMap::kGcRootsFirstSubrootId = HeapObjectsMap::kGcRootsObjectId + HeapObjectsMap::kObjectIdStep; -const SnapshotObjectId HeapObjectsMap::kFirstAvailableObjectId = +const uint64_t HeapObjectsMap::kFirstAvailableObjectId = HeapObjectsMap::kGcRootsFirstSubrootId + VisitorSynchronization::kNumberOfSyncTags * HeapObjectsMap::kObjectIdStep; @@ -1325,12 +1325,12 @@ void HeapObjectsMap::SnapshotGenerationFinished() { } -SnapshotObjectId HeapObjectsMap::FindObject(Address addr) { +uint64_t HeapObjectsMap::FindObject(Address addr) { if (!initial_fill_mode_) { - SnapshotObjectId existing = FindEntry(addr); + uint64_t existing = FindEntry(addr); if (existing != 0) return existing; } - SnapshotObjectId id = next_id_; + uint64_t id = next_id_; next_id_ += kObjectIdStep; AddEntry(addr, id); return id; @@ -1353,7 +1353,7 @@ void HeapObjectsMap::MoveObject(Address from, Address to) { } -void HeapObjectsMap::AddEntry(Address addr, SnapshotObjectId id) { +void HeapObjectsMap::AddEntry(Address addr, uint64_t id) { HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), true); ASSERT(entry->value == NULL); entry->value = reinterpret_cast(entries_->length()); @@ -1361,7 +1361,7 @@ void HeapObjectsMap::AddEntry(Address addr, SnapshotObjectId id) { } -SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) { +uint64_t HeapObjectsMap::FindEntry(Address addr) { HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false); if (entry != NULL) { int entry_index = @@ -1401,8 +1401,8 @@ void HeapObjectsMap::RemoveDeadEntries() { } -SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { - SnapshotObjectId id = static_cast(info->GetHash()); +uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { + uint64_t id = static_cast(info->GetHash()); const char* label = info->GetLabel(); id ^= HashSequentialString(label, static_cast(strlen(label)), @@ -1472,8 +1472,7 @@ void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { } -Handle HeapSnapshotsCollection::FindHeapObjectById( - SnapshotObjectId id) { +Handle HeapSnapshotsCollection::FindHeapObjectById(uint64_t id) { // First perform a full GC in order to avoid dead objects. HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, "HeapSnapshotsCollection::FindHeapObjectById"); @@ -3527,21 +3526,21 @@ void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge) { void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) { - // The buffer needs space for 6 ints, 1 unsigned, 7 commas, \n and \0 + // The buffer needs space for 6 ints, 1 uint64_t, 7 commas, \n and \0 static const int kBufferSize = 6 * MaxDecimalDigitsIn::kSigned // NOLINT - + MaxDecimalDigitsIn::kUnsigned // NOLINT + + MaxDecimalDigitsIn::kUnsigned // NOLINT + 7 + 1 + 1; EmbeddedVector buffer; Vector children = entry->children(); STATIC_CHECK(sizeof(int) == sizeof(entry->type())); // NOLINT STATIC_CHECK(sizeof(int) == sizeof(GetStringId(entry->name()))); // NOLINT - STATIC_CHECK(sizeof(unsigned) == sizeof(entry->id())); // 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,%u,%d,%d,%d,%d", + int result = OS::SNPrintF(buffer, "\n,%d,%d,%llu,%d,%d,%d,%d", entry->type(), GetStringId(entry->name()), entry->id(), diff --git a/src/profile-generator.h b/src/profile-generator.h index ba617f9..f9ae5f9 100644 --- a/src/profile-generator.h +++ b/src/profile-generator.h @@ -35,8 +35,6 @@ namespace v8 { namespace internal { -typedef uint32_t SnapshotObjectId; - class TokenEnumerator { public: TokenEnumerator(); @@ -535,7 +533,7 @@ class HeapEntry BASE_EMBEDDED { void Init(HeapSnapshot* snapshot, Type type, const char* name, - SnapshotObjectId id, + uint64_t id, int self_size, int children_count, int retainers_count); @@ -544,7 +542,7 @@ class HeapEntry BASE_EMBEDDED { Type type() { return static_cast(type_); } const char* name() { return name_; } void set_name(const char* name) { name_ = name; } - inline SnapshotObjectId id(); + inline uint64_t id(); int self_size() { return self_size_; } int retained_size() { return retained_size_; } void add_retained_size(int size) { retained_size_ += size; } @@ -653,7 +651,7 @@ class HeapSnapshot { int entries_count, int children_count, int retainers_count); HeapEntry* AddEntry(HeapEntry::Type type, const char* name, - SnapshotObjectId id, + uint64_t id, int size, int children_count, int retainers_count); @@ -664,7 +662,7 @@ class HeapSnapshot { int retainers_count); HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); void ClearPaint(); - HeapEntry* GetEntryById(SnapshotObjectId id); + HeapEntry* GetEntryById(uint64_t id); List* GetSortedEntriesList(); template void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } @@ -701,29 +699,29 @@ class HeapObjectsMap { ~HeapObjectsMap(); void SnapshotGenerationFinished(); - SnapshotObjectId FindObject(Address addr); + uint64_t FindObject(Address addr); void MoveObject(Address from, Address to); - static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); - static inline SnapshotObjectId GetNthGcSubrootId(int delta); + static uint64_t GenerateId(v8::RetainedObjectInfo* info); + static inline uint64_t GetNthGcSubrootId(int delta); static const int kObjectIdStep = 2; - static const SnapshotObjectId kInternalRootObjectId; - static const SnapshotObjectId kGcRootsObjectId; - static const SnapshotObjectId kNativesRootObjectId; - static const SnapshotObjectId kGcRootsFirstSubrootId; - static const SnapshotObjectId kFirstAvailableObjectId; + static const uint64_t kInternalRootObjectId; + static const uint64_t kGcRootsObjectId; + static const uint64_t kNativesRootObjectId; + static const uint64_t kGcRootsFirstSubrootId; + static const uint64_t kFirstAvailableObjectId; private: struct EntryInfo { - explicit EntryInfo(SnapshotObjectId id) : id(id), accessed(true) { } - EntryInfo(SnapshotObjectId id, bool accessed) : id(id), accessed(accessed) { } - SnapshotObjectId id; + explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } + EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } + uint64_t id; bool accessed; }; - void AddEntry(Address addr, SnapshotObjectId id); - SnapshotObjectId FindEntry(Address addr); + void AddEntry(Address addr, uint64_t id); + uint64_t FindEntry(Address addr); void RemoveDeadEntries(); static bool AddressesMatch(void* key1, void* key2) { @@ -737,7 +735,7 @@ class HeapObjectsMap { } bool initial_fill_mode_; - SnapshotObjectId next_id_; + uint64_t next_id_; HashMap entries_map_; List* entries_; @@ -762,8 +760,8 @@ class HeapSnapshotsCollection { StringsStorage* names() { return &names_; } TokenEnumerator* token_enumerator() { return token_enumerator_; } - SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); } - Handle FindHeapObjectById(SnapshotObjectId id); + uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } + Handle FindHeapObjectById(uint64_t id); void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } private: -- 2.7.4