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 {
/** Returns a node by index. */
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.
* All pointers to nodes, edges and paths previously returned become
......
......@@ -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,
HeapSnapshot::SerializationFormat format) const {
i::Isolate* isolate = i::Isolate::Current();
......
......@@ -1133,7 +1133,8 @@ HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
gc_roots_entry_(NULL),
natives_root_entry_(NULL),
raw_entries_(NULL),
entries_sorted_(false) {
entries_sorted_(false),
max_snapshot_js_object_id_(0) {
STATIC_CHECK(
sizeof(HeapGraphEdge) ==
SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize);
......@@ -1223,6 +1224,11 @@ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type,
int retainers_count) {
HeapEntry* entry = GetNextEntryToInit();
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;
}
......
......@@ -35,8 +35,6 @@
namespace v8 {
namespace internal {
typedef uint32_t SnapshotObjectId;
class TokenEnumerator {
public:
TokenEnumerator();
......@@ -647,6 +645,9 @@ class HeapSnapshot {
HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; }
List<HeapEntry*>* entries() { return &entries_; }
size_t raw_entries_size() { return raw_entries_size_; }
SnapshotObjectId max_snapshot_js_object_id() const {
return max_snapshot_js_object_id_;
}
void AllocateEntries(
int entries_count, int children_count, int retainers_count);
......@@ -687,6 +688,7 @@ class HeapSnapshot {
List<HeapEntry*> entries_;
bool entries_sorted_;
size_t raw_entries_size_;
SnapshotObjectId max_snapshot_js_object_id_;
friend class HeapSnapshotTester;
......
......@@ -422,6 +422,11 @@ TEST(HeapEntryIdsAndGC) {
const v8::HeapSnapshot* snapshot2 =
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* global2 = GetGlobalObject(snapshot2);
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