Reviewers: Mikhail Naganov (Chromium), Yury Semikhatsky, loislo,

Description:
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.


Please review this at https://chromiumcodereview.appspot.com/10332087/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/profile-generator.h
  M src/profile-generator.cc


Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index c78bf28394dd00495ba6382191da2e07d06e3edd..3f4e935b04b6df12c987259b4c2dc1e071be1d73 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -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);
 }


Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index 18c157cdfd88be9d96bec203e3ec4d318db049fb..bc1fb42d8845c31453f5e74f7a23166ca871e933 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -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);


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to