Revision: 11404
Author:   [email protected]
Date:     Fri Apr 20 07:03:06 2012
Log: Eliminate internal and hidden links to oddballs and other non-essential objects in heap snapshot.

Review URL: https://chromiumcodereview.appspot.com/10162005
http://code.google.com/p/v8/source/detail?r=11404

Modified:
 /branches/bleeding_edge/src/profile-generator.cc
 /branches/bleeding_edge/src/profile-generator.h
 /branches/bleeding_edge/test/cctest/test-heap-profiler.cc

=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Fri Apr 20 06:57:13 2012 +++ /branches/bleeding_edge/src/profile-generator.cc Fri Apr 20 07:03:06 2012
@@ -2478,6 +2478,20 @@
   }
   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.
+  return object->IsHeapObject()
+      && !object->IsOddball()
+      && object != heap_->raw_unchecked_empty_byte_array()
+      && object != heap_->raw_unchecked_empty_fixed_array()
+      && object != heap_->raw_unchecked_empty_descriptor_array()
+      && object != heap_->raw_unchecked_fixed_array_map()
+      && object != heap_->raw_unchecked_global_property_cell_map()
+      && object != heap_->raw_unchecked_shared_function_info_map();
+}


 void V8HeapExplorer::SetClosureReference(HeapObject* parent_obj,
@@ -2535,10 +2549,7 @@
                                           int field_offset) {
   HeapEntry* child_entry = GetEntry(child_obj);
   if (child_entry == NULL) return;
-  // We have to use raw_unchecked_* version because when the
-  // empty_fixed_array itself is being processed all its inline properties
-  // are invalid and the check in empty_fixed_array() function fails.
-  if (child_obj != heap_->raw_unchecked_empty_fixed_array()) {
+  if (IsEssentialObject(child_obj)) {
     filler_->SetNamedReference(HeapGraphEdge::kInternal,
                                parent_obj, parent_entry,
                                reference_name,
@@ -2555,8 +2566,7 @@
                                           int field_offset) {
   HeapEntry* child_entry = GetEntry(child_obj);
   if (child_entry == NULL) return;
-  // See the comment regarding raw_unchecked_* above.
-  if (child_obj != heap_->raw_unchecked_empty_fixed_array()) {
+  if (IsEssentialObject(child_obj)) {
     filler_->SetNamedReference(HeapGraphEdge::kInternal,
                                parent_obj, parent_entry,
                                collection_->names()->GetName(index),
@@ -2571,7 +2581,7 @@
                                         int index,
                                         Object* child_obj) {
   HeapEntry* child_entry = GetEntry(child_obj);
-  if (child_entry != NULL) {
+  if (child_entry != NULL && IsEssentialObject(child_obj)) {
     filler_->SetIndexedReference(HeapGraphEdge::kHidden,
                                  parent_obj,
                                  parent_entry,
@@ -2711,11 +2721,7 @@


 void V8HeapExplorer::TagObject(Object* obj, const char* tag) {
-  if (obj->IsHeapObject() &&
-      !obj->IsOddball() &&
-      obj != heap_->raw_unchecked_empty_byte_array() &&
-      obj != heap_->raw_unchecked_empty_fixed_array() &&
-      obj != heap_->raw_unchecked_empty_descriptor_array()) {
+  if (IsEssentialObject(obj)) {
     objects_tags_.SetTag(obj, tag);
   }
 }
=======================================
--- /branches/bleeding_edge/src/profile-generator.h     Thu Apr 19 08:58:42 2012
+++ /branches/bleeding_edge/src/profile-generator.h     Fri Apr 20 07:03:06 2012
@@ -980,6 +980,7 @@
   void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
   void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry);
   void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry);
+  bool IsEssentialObject(Object* object);
   void SetClosureReference(HeapObject* parent_obj,
                            HeapEntry* parent,
                            String* reference_name,
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Thu Apr 19 09:31:01 2012 +++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Fri Apr 20 07:03:06 2012
@@ -1645,3 +1645,22 @@
     CHECK(isalpha(**name));
   }
 }
+
+
+TEST(NoRefsToNonEssentialEntries) {
+  v8::HandleScope scope;
+  LocalContext env;
+  CompileRun("global_object = {};\n");
+  const v8::HeapSnapshot* snapshot =
+      v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
+  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+  const v8::HeapGraphNode* global_object =
+      GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object");
+  CHECK_NE(NULL, global_object);
+  const v8::HeapGraphNode* properties =
+ GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties");
+  CHECK_EQ(NULL, properties);
+  const v8::HeapGraphNode* elements =
+      GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements");
+  CHECK_EQ(NULL, elements);
+}

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

Reply via email to