Count ArrayBuffer's backing_store memory in heap snapshot.
BUG=341741 LOG=N R=dslomov@chromium.org, loislo@chromium.org Review URL: https://codereview.chromium.org/163593002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19356 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
e18aff1c4b
commit
4aabb8aeec
@ -34,6 +34,7 @@
|
||||
#include "heap-profiler.h"
|
||||
#include "debug.h"
|
||||
#include "types.h"
|
||||
#include "v8conversions.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -899,10 +900,16 @@ HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object) {
|
||||
HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object,
|
||||
HeapEntry::Type type,
|
||||
const char* name) {
|
||||
int object_size = object->Size();
|
||||
SnapshotObjectId object_id =
|
||||
heap_object_map_->FindOrAddEntry(object->address(), object_size);
|
||||
return snapshot_->AddEntry(type, name, object_id, object_size);
|
||||
return AddEntry(object->address(), type, name, object->Size());
|
||||
}
|
||||
|
||||
|
||||
HeapEntry* V8HeapExplorer::AddEntry(Address address,
|
||||
HeapEntry::Type type,
|
||||
const char* name,
|
||||
int size) {
|
||||
SnapshotObjectId object_id = heap_object_map_->FindOrAddEntry(address, size);
|
||||
return snapshot_->AddEntry(type, name, object_id, size);
|
||||
}
|
||||
|
||||
|
||||
@ -1029,6 +1036,8 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
|
||||
|
||||
if (obj->IsJSGlobalProxy()) {
|
||||
ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj));
|
||||
} else if (obj->IsJSArrayBuffer()) {
|
||||
ExtractJSArrayBufferReferences(entry, JSArrayBuffer::cast(obj));
|
||||
} else if (obj->IsJSObject()) {
|
||||
ExtractJSObjectReferences(entry, JSObject::cast(obj));
|
||||
} else if (obj->IsString()) {
|
||||
@ -1147,13 +1156,6 @@ void V8HeapExplorer::ExtractJSObjectReferences(
|
||||
JSArrayBufferView::kBufferOffset);
|
||||
SetWeakReference(view, entry, "weak_next", view->weak_next(),
|
||||
JSArrayBufferView::kWeakNextOffset);
|
||||
} else if (obj->IsJSArrayBuffer()) {
|
||||
JSArrayBuffer* buffer = JSArrayBuffer::cast(obj);
|
||||
SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
|
||||
JSArrayBuffer::kWeakNextOffset);
|
||||
SetWeakReference(buffer, entry,
|
||||
"weak_first_view", buffer->weak_first_view(),
|
||||
JSArrayBuffer::kWeakFirstViewOffset);
|
||||
}
|
||||
TagObject(js_obj->properties(), "(object properties)");
|
||||
SetInternalReference(obj, entry,
|
||||
@ -1454,6 +1456,25 @@ void V8HeapExplorer::ExtractAllocationSiteReferences(int entry,
|
||||
}
|
||||
|
||||
|
||||
void V8HeapExplorer::ExtractJSArrayBufferReferences(
|
||||
int entry, JSArrayBuffer* buffer) {
|
||||
SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
|
||||
JSArrayBuffer::kWeakNextOffset);
|
||||
SetWeakReference(buffer, entry,
|
||||
"weak_first_view", buffer->weak_first_view(),
|
||||
JSArrayBuffer::kWeakFirstViewOffset);
|
||||
// Setup a reference to a native memory backing_store object.
|
||||
size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
|
||||
CHECK(data_size <= static_cast<size_t>(kMaxInt));
|
||||
HeapEntry* data_entry = AddEntry(
|
||||
static_cast<Address>(buffer->backing_store()),
|
||||
HeapEntry::kNative, "system / ArrayBufferData",
|
||||
static_cast<int>(data_size));
|
||||
filler_->SetNamedReference(HeapGraphEdge::kInternal,
|
||||
entry, "backing_store", data_entry);
|
||||
}
|
||||
|
||||
|
||||
void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) {
|
||||
if (!js_obj->IsJSFunction()) return;
|
||||
|
||||
|
@ -396,6 +396,11 @@ class V8HeapExplorer : public HeapEntriesAllocator {
|
||||
HeapEntry* AddEntry(HeapObject* object,
|
||||
HeapEntry::Type type,
|
||||
const char* name);
|
||||
HeapEntry* AddEntry(Address address,
|
||||
HeapEntry::Type type,
|
||||
const char* name,
|
||||
int size);
|
||||
|
||||
const char* GetSystemEntryName(HeapObject* object);
|
||||
|
||||
void ExtractReferences(HeapObject* obj);
|
||||
@ -414,6 +419,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
|
||||
void ExtractCellReferences(int entry, Cell* cell);
|
||||
void ExtractPropertyCellReferences(int entry, PropertyCell* cell);
|
||||
void ExtractAllocationSiteReferences(int entry, AllocationSite* site);
|
||||
void ExtractJSArrayBufferReferences(int entry, JSArrayBuffer* buffer);
|
||||
void ExtractClosureReferences(JSObject* js_obj, int entry);
|
||||
void ExtractPropertyReferences(JSObject* js_obj, int entry);
|
||||
bool ExtractAccessorPairProperty(JSObject* js_obj, int entry,
|
||||
|
@ -2381,6 +2381,10 @@ TEST(ArrayBufferAndArrayBufferView) {
|
||||
const v8::HeapGraphNode* first_view =
|
||||
GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view");
|
||||
CHECK_NE(NULL, first_view);
|
||||
const v8::HeapGraphNode* backing_store =
|
||||
GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store");
|
||||
CHECK_NE(NULL, backing_store);
|
||||
CHECK_EQ(400, backing_store->GetSelfSize());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user