Commit 4e3c3a95 authored by alexeif@chromium.org's avatar alexeif@chromium.org

Merge SetObjectNames extra pass into the main pass.

Because heap snapshotting is now performed in a single pass
it is safe to make calls to GetConstructorName and further to
LocalLookupRealNamedProperty right within that main pass.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11535 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f1ff027d
......@@ -1675,7 +1675,15 @@ HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object) {
HeapEntry::kRegExp,
collection_->names()->GetName(re->Pattern()));
} else if (object->IsJSObject()) {
return AddEntry(object, HeapEntry::kObject, "");
const char* name = collection_->names()->GetName(
GetConstructorName(JSObject::cast(object)));
if (object->IsJSGlobalObject()) {
const char* tag = objects_tags_.GetTag(object);
if (tag != NULL) {
name = collection_->names()->GetFormatted("%s / %s", name, tag);
}
}
return AddEntry(object, HeapEntry::kObject, name);
} else if (object->IsString()) {
return AddEntry(object,
HeapEntry::kString,
......@@ -2396,32 +2404,6 @@ bool V8HeapExplorer::IterateAndExtractReferences(
}
bool V8HeapExplorer::IterateAndSetObjectNames(SnapshotFillerInterface* filler) {
HeapIterator iterator(HeapIterator::kFilterUnreachable);
filler_ = filler;
for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
SetObjectName(obj);
}
return true;
}
void V8HeapExplorer::SetObjectName(HeapObject* object) {
if (!object->IsJSObject() || object->IsJSRegExp() || object->IsJSFunction()) {
return;
}
const char* name = collection_->names()->GetName(
GetConstructorName(JSObject::cast(object)));
if (object->IsJSGlobalObject()) {
const char* tag = objects_tags_.GetTag(object);
if (tag != NULL) {
name = collection_->names()->GetFormatted("%s / %s", name, tag);
}
}
GetEntry(object)->set_name(name);
}
bool V8HeapExplorer::IsEssentialObject(Object* object) {
// We have to use raw_unchecked_* versions because checked versions
// would fail during iteration over object properties.
......@@ -3149,15 +3131,8 @@ void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) {
bool HeapSnapshotGenerator::FillReferences() {
SnapshotFiller filler(snapshot_, &entries_);
v8_heap_explorer_.AddRootEntries(&filler);
// IterateAndExtractReferences cannot set object names because
// it makes call to JSObject::LocalLookupRealNamedProperty which
// in turn may relocate objects in property maps thus changing the heap
// layout and affecting retainer counts. This is not acceptable because
// number of retainers must not change between count and fill passes.
// To avoid this there's a separate postpass that set object names.
return v8_heap_explorer_.IterateAndExtractReferences(&filler)
&& dom_explorer_.IterateAndExtractReferences(&filler)
&& v8_heap_explorer_.IterateAndSetObjectNames(&filler);
&& dom_explorer_.IterateAndExtractReferences(&filler);
}
......
......@@ -526,7 +526,6 @@ class HeapEntry BASE_EMBEDDED {
HeapSnapshot* snapshot() { return snapshot_; }
Type type() { return static_cast<Type>(type_); }
const char* name() { return name_; }
void set_name(const char* name) { name_ = name; }
inline SnapshotObjectId id() { return id_; }
int self_size() { return self_size_; }
int retained_size() { return retained_size_; }
......@@ -889,7 +888,6 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void AddRootEntries(SnapshotFillerInterface* filler);
int EstimateObjectsCount(HeapIterator* iterator);
bool IterateAndExtractReferences(SnapshotFillerInterface* filler);
bool IterateAndSetObjectNames(SnapshotFillerInterface* filler);
void TagGlobalObjects();
static String* GetConstructorName(JSObject* object);
......@@ -968,7 +966,6 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void SetGcSubrootReference(
VisitorSynchronization::SyncTag tag, bool is_weak, Object* child);
const char* GetStrongGcSubrootName(Object* object);
void SetObjectName(HeapObject* object);
void TagObject(Object* obj, const char* tag);
HeapEntry* GetEntry(Object* obj);
......
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