Show map -> transition array -> descriptor array to the heap profiler.
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 16 Aug 2012 14:25:55 +0000 (14:25 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 16 Aug 2012 14:25:55 +0000 (14:25 +0000)
BUG=chromium:142625

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12321 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/profile-generator.cc
test/cctest/test-heap-profiler.cc

index 1a41396..87b91e3 100644 (file)
@@ -2007,11 +2007,21 @@ void V8HeapExplorer::ExtractMapReferences(int entry, Map* map) {
   SetInternalReference(map, entry,
                        "constructor", map->constructor(),
                        Map::kConstructorOffset);
-  if (!map->instance_descriptors()->IsEmpty()) {
-    TagObject(map->instance_descriptors(), "(map descriptors)");
-    // TODO(verwaest): Check what to do here.
+  if (map->HasTransitionArray()) {
+    TransitionArray* transitions = map->transitions();
+    if (!transitions->descriptors()->IsEmpty()) {
+      DescriptorArray* descriptors = transitions->descriptors();
+      TagObject(descriptors, "(map descriptors)");
+      SetInternalReference(transitions, entry,
+                           "descriptors", descriptors,
+                           TransitionArray::kDescriptorsOffset);
+      IndexedReferencesExtractor refs_extractor(
+          this, transitions, entry);
+      transitions->Iterate(&refs_extractor);
+    }
+    TagObject(transitions, "(transition array)");
     SetInternalReference(map, entry,
-                         "descriptors", map->instance_descriptors(),
+                         "transitions", transitions,
                          Map::kTransitionsOrBackPointerOffset);
   }
   SetInternalReference(map, entry,
index 3e03ae9..1be64d9 100644 (file)
@@ -1658,3 +1658,25 @@ TEST(NoRefsToNonEssentialEntries) {
       GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements");
   CHECK_EQ(NULL, elements);
 }
+
+
+TEST(MapHasDescriptorsAndTransitions) {
+  v8::HandleScope scope;
+  LocalContext env;
+  CompileRun("obj = { a: 10 };\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, "obj");
+  CHECK_NE(NULL, global_object);
+  const v8::HeapGraphNode* map =
+      GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map");
+  CHECK_NE(NULL, map);
+  const v8::HeapGraphNode* descriptors =
+      GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors");
+  CHECK_NE(NULL, descriptors);
+  const v8::HeapGraphNode* transitions =
+      GetProperty(map, v8::HeapGraphEdge::kInternal, "transitions");
+  CHECK_NE(NULL, transitions);
+}