Commit 410f3a33 authored by loislo@chromium.org's avatar loislo@chromium.org

This value is required for showing the heap snapshot delta in Summary view of DevTools.Profiler.

At the moment it is evaluating on the front-end side and this is cost us 2 * (load time + parse time + traverse via snapshot) because I need this value for two previous snapshots.

BUG=none
TEST=test-heap-profiler

Review URL: https://chromiumcodereview.appspot.com/9858016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11150 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7a1cbb2d
...@@ -347,6 +347,9 @@ class V8EXPORT HeapSnapshot { ...@@ -347,6 +347,9 @@ class V8EXPORT HeapSnapshot {
/** Returns a node by index. */ /** Returns a node by index. */
const HeapGraphNode* GetNode(int index) const; const HeapGraphNode* GetNode(int index) const;
/** Returns a max seen JS object Id. */
SnapshotObjectId GetMaxSnapshotJSObjectId() const;
/** /**
* Deletes the snapshot and removes it from HeapProfiler's list. * Deletes the snapshot and removes it from HeapProfiler's list.
* All pointers to nodes, edges and paths previously returned become * All pointers to nodes, edges and paths previously returned become
......
...@@ -6157,6 +6157,13 @@ const HeapGraphNode* HeapSnapshot::GetNode(int index) const { ...@@ -6157,6 +6157,13 @@ const HeapGraphNode* HeapSnapshot::GetNode(int index) const {
} }
SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetMaxSnapshotJSObjectId");
return ToInternal(this)->max_snapshot_js_object_id();
}
void HeapSnapshot::Serialize(OutputStream* stream, void HeapSnapshot::Serialize(OutputStream* stream,
HeapSnapshot::SerializationFormat format) const { HeapSnapshot::SerializationFormat format) const {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
......
...@@ -1133,7 +1133,8 @@ HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, ...@@ -1133,7 +1133,8 @@ HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
gc_roots_entry_(NULL), gc_roots_entry_(NULL),
natives_root_entry_(NULL), natives_root_entry_(NULL),
raw_entries_(NULL), raw_entries_(NULL),
entries_sorted_(false) { entries_sorted_(false),
max_snapshot_js_object_id_(0) {
STATIC_CHECK( STATIC_CHECK(
sizeof(HeapGraphEdge) == sizeof(HeapGraphEdge) ==
SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize); SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize);
...@@ -1223,6 +1224,11 @@ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type, ...@@ -1223,6 +1224,11 @@ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type,
int retainers_count) { int retainers_count) {
HeapEntry* entry = GetNextEntryToInit(); HeapEntry* entry = GetNextEntryToInit();
entry->Init(this, type, name, id, size, children_count, retainers_count); entry->Init(this, type, name, id, size, children_count, retainers_count);
// Track only js objects. They have odd ids.
if (id % HeapObjectsMap::kObjectIdStep && id > max_snapshot_js_object_id_)
max_snapshot_js_object_id_ = id;
return entry; return entry;
} }
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
typedef uint32_t SnapshotObjectId;
class TokenEnumerator { class TokenEnumerator {
public: public:
TokenEnumerator(); TokenEnumerator();
...@@ -647,6 +645,9 @@ class HeapSnapshot { ...@@ -647,6 +645,9 @@ class HeapSnapshot {
HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; }
List<HeapEntry*>* entries() { return &entries_; } List<HeapEntry*>* entries() { return &entries_; }
size_t raw_entries_size() { return raw_entries_size_; } size_t raw_entries_size() { return raw_entries_size_; }
SnapshotObjectId max_snapshot_js_object_id() const {
return max_snapshot_js_object_id_;
}
void AllocateEntries( void AllocateEntries(
int entries_count, int children_count, int retainers_count); int entries_count, int children_count, int retainers_count);
...@@ -687,6 +688,7 @@ class HeapSnapshot { ...@@ -687,6 +688,7 @@ class HeapSnapshot {
List<HeapEntry*> entries_; List<HeapEntry*> entries_;
bool entries_sorted_; bool entries_sorted_;
size_t raw_entries_size_; size_t raw_entries_size_;
SnapshotObjectId max_snapshot_js_object_id_;
friend class HeapSnapshotTester; friend class HeapSnapshotTester;
......
...@@ -422,6 +422,11 @@ TEST(HeapEntryIdsAndGC) { ...@@ -422,6 +422,11 @@ TEST(HeapEntryIdsAndGC) {
const v8::HeapSnapshot* snapshot2 = const v8::HeapSnapshot* snapshot2 =
v8::HeapProfiler::TakeSnapshot(v8_str("s2")); v8::HeapProfiler::TakeSnapshot(v8_str("s2"));
// Second snapshot has one more string, it is it's name 's2'.
CHECK_EQ_SNAPSHOT_OBJECT_ID(
snapshot1->GetMaxSnapshotJSObjectId() + i::HeapObjectsMap::kObjectIdStep,
snapshot2->GetMaxSnapshotJSObjectId());
const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId());
......
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