Commit 01a6c8ae authored by alph@chromium.org's avatar alph@chromium.org

Mark weak fields of JSArrayBuffer and JSArrayBufferView as weak in heap snapshot.

BUG=337144
LOG=N
R=ulan@chromium.org, yurys@chromium.org

Review URL: https://codereview.chromium.org/138443009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18830 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a3d03111
......@@ -1130,6 +1130,18 @@ void V8HeapExplorer::ExtractJSObjectReferences(
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,
......
......@@ -2319,3 +2319,24 @@ TEST(TrackBumpPointerAllocations) {
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);
}
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