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
This commit is contained in:
loislo@chromium.org 2012-03-29 14:18:11 +00:00
parent 0acfd5af07
commit d857c994b6
3 changed files with 17 additions and 11 deletions

View File

@ -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,
int children_count,
int retainers_count) {
@ -1224,11 +1229,6 @@ 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;
}
@ -3111,6 +3111,8 @@ bool HeapSnapshotGenerator::GenerateSnapshot() {
// Pass 2. Fill references.
if (!FillReferences()) return false;
snapshot_->RememberLastJSObjectId();
if (!SetEntriesDominators()) return false;
if (!CalculateRetainedSizes()) return false;

View File

@ -645,6 +645,7 @@ 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_; }
void RememberLastJSObjectId();
SnapshotObjectId max_snapshot_js_object_id() const {
return max_snapshot_js_object_id_;
}
@ -704,6 +705,9 @@ class HeapObjectsMap {
void SnapshotGenerationFinished();
SnapshotObjectId FindObject(Address addr);
void MoveObject(Address from, Address to);
SnapshotObjectId last_assigned_id() const {
return next_id_ - kObjectIdStep;
}
static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
static inline SnapshotObjectId GetNthGcSubrootId(int delta);
@ -768,6 +772,9 @@ class HeapSnapshotsCollection {
SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); }
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
SnapshotObjectId last_assigned_id() const {
return ids_.last_assigned_id();
}
private:
INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) {

View File

@ -424,12 +424,9 @@ TEST(HeapEntryIdsAndGC) {
const v8::HeapSnapshot* snapshot2 =
v8::HeapProfiler::TakeSnapshot(s2_str);
// Second snapshot has one more string, it is it's name 's2'.
CHECK(
snapshot1->GetMaxSnapshotJSObjectId() <=
snapshot2->GetMaxSnapshotJSObjectId() &&
snapshot2->GetMaxSnapshotJSObjectId() <=
snapshot1->GetMaxSnapshotJSObjectId() + i::HeapObjectsMap::kObjectIdStep);
CHECK(snapshot1->GetMaxSnapshotJSObjectId() > 7000);
CHECK(snapshot1->GetMaxSnapshotJSObjectId() <=
snapshot2->GetMaxSnapshotJSObjectId());
const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);