Commit d857c994 authored by loislo@chromium.org's avatar loislo@chromium.org

Current schema of calculation max_snapshot_js_object_id is not always correct.

As the result the test is flaky.

BUG=v8/2042
TEST=HeapEntryIdsAndGC
R=mnaganov

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11187 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0acfd5af
...@@ -1158,6 +1158,11 @@ void HeapSnapshot::Delete() { ...@@ -1158,6 +1158,11 @@ void HeapSnapshot::Delete() {
} }
void HeapSnapshot::RememberLastJSObjectId() {
max_snapshot_js_object_id_ = collection_->last_assigned_id();
}
void HeapSnapshot::AllocateEntries(int entries_count, void HeapSnapshot::AllocateEntries(int entries_count,
int children_count, int children_count,
int retainers_count) { int retainers_count) {
...@@ -1224,11 +1229,6 @@ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type, ...@@ -1224,11 +1229,6 @@ 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;
} }
...@@ -3111,6 +3111,8 @@ bool HeapSnapshotGenerator::GenerateSnapshot() { ...@@ -3111,6 +3111,8 @@ bool HeapSnapshotGenerator::GenerateSnapshot() {
// Pass 2. Fill references. // Pass 2. Fill references.
if (!FillReferences()) return false; if (!FillReferences()) return false;
snapshot_->RememberLastJSObjectId();
if (!SetEntriesDominators()) return false; if (!SetEntriesDominators()) return false;
if (!CalculateRetainedSizes()) return false; if (!CalculateRetainedSizes()) return false;
......
...@@ -645,6 +645,7 @@ class HeapSnapshot { ...@@ -645,6 +645,7 @@ 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_; }
void RememberLastJSObjectId();
SnapshotObjectId max_snapshot_js_object_id() const { SnapshotObjectId max_snapshot_js_object_id() const {
return max_snapshot_js_object_id_; return max_snapshot_js_object_id_;
} }
...@@ -704,6 +705,9 @@ class HeapObjectsMap { ...@@ -704,6 +705,9 @@ class HeapObjectsMap {
void SnapshotGenerationFinished(); void SnapshotGenerationFinished();
SnapshotObjectId FindObject(Address addr); SnapshotObjectId FindObject(Address addr);
void MoveObject(Address from, Address to); void MoveObject(Address from, Address to);
SnapshotObjectId last_assigned_id() const {
return next_id_ - kObjectIdStep;
}
static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
static inline SnapshotObjectId GetNthGcSubrootId(int delta); static inline SnapshotObjectId GetNthGcSubrootId(int delta);
...@@ -768,6 +772,9 @@ class HeapSnapshotsCollection { ...@@ -768,6 +772,9 @@ class HeapSnapshotsCollection {
SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); } SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); }
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
SnapshotObjectId last_assigned_id() const {
return ids_.last_assigned_id();
}
private: private:
INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) {
......
...@@ -424,12 +424,9 @@ TEST(HeapEntryIdsAndGC) { ...@@ -424,12 +424,9 @@ TEST(HeapEntryIdsAndGC) {
const v8::HeapSnapshot* snapshot2 = const v8::HeapSnapshot* snapshot2 =
v8::HeapProfiler::TakeSnapshot(s2_str); v8::HeapProfiler::TakeSnapshot(s2_str);
// Second snapshot has one more string, it is it's name 's2'. CHECK(snapshot1->GetMaxSnapshotJSObjectId() > 7000);
CHECK( CHECK(snapshot1->GetMaxSnapshotJSObjectId() <=
snapshot1->GetMaxSnapshotJSObjectId() <= snapshot2->GetMaxSnapshotJSObjectId());
snapshot2->GetMaxSnapshotJSObjectId() &&
snapshot2->GetMaxSnapshotJSObjectId() <=
snapshot1->GetMaxSnapshotJSObjectId() + i::HeapObjectsMap::kObjectIdStep);
const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
......
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