Revision: 18830
Author:   [email protected]
Date:     Fri Jan 24 15:10:09 2014 UTC
Log: Mark weak fields of JSArrayBuffer and JSArrayBufferView as weak in heap snapshot.

BUG=337144
LOG=N
[email protected], [email protected]

Review URL: https://codereview.chromium.org/138443009
http://code.google.com/p/v8/source/detail?r=18830

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

=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.cc Mon Jan 13 10:57:49 2014 UTC +++ /branches/bleeding_edge/src/heap-snapshot-generator.cc Fri Jan 24 15:10:09 2014 UTC
@@ -1130,6 +1130,18 @@
     SetInternalReference(global_obj, entry,
                          "global_receiver", global_obj->global_receiver(),
                          GlobalObject::kGlobalReceiverOffset);
+  } else if (obj->IsJSArrayBufferView()) {
+    JSArrayBufferView* view = JSArrayBufferView::cast(obj);
+    SetInternalReference(view, entry, "buffer", view->buffer(),
+                         JSArrayBufferView::kBufferOffset);
+    SetWeakReference(view, entry, 1, view->weak_next(),
+                     JSArrayBufferView::kWeakNextOffset);
+  } else if (obj->IsJSArrayBuffer()) {
+    JSArrayBuffer* buffer = JSArrayBuffer::cast(obj);
+    SetWeakReference(buffer, entry, 1, buffer->weak_next(),
+                     JSArrayBuffer::kWeakNextOffset);
+    SetWeakReference(buffer, entry, 2, buffer->weak_first_view(),
+                     JSArrayBuffer::kWeakFirstViewOffset);
   }
   TagObject(js_obj->properties(), "(object properties)");
   SetInternalReference(obj, entry,
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Fri Jan 17 10:52:00 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Fri Jan 24 15:10:09 2014 UTC
@@ -2319,3 +2319,24 @@
     heap_profiler->StopTrackingHeapObjects();
   }
 }
+
+
+TEST(ArrayBufferAndArrayBufferView) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+  v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+  CompileRun("arr1 = new Uint32Array(100);\n");
+  const v8::HeapSnapshot* snapshot =
+      heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
+  CHECK(ValidateSnapshot(snapshot));
+  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+  const v8::HeapGraphNode* arr1_obj =
+      GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1");
+  CHECK_NE(NULL, arr1_obj);
+  const v8::HeapGraphNode* arr1_buffer =
+      GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer");
+  CHECK_NE(NULL, arr1_buffer);
+  const v8::HeapGraphNode* first_view =
+      GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "2");
+  CHECK_NE(NULL, first_view);
+}

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to