Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 163593002: Count ArrayBuffer's backing_store memory in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added a static_cast Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 16 matching lines...) Expand all
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "heap-snapshot-generator-inl.h" 30 #include "heap-snapshot-generator-inl.h"
31 31
32 #include "allocation-tracker.h" 32 #include "allocation-tracker.h"
33 #include "code-stubs.h" 33 #include "code-stubs.h"
34 #include "heap-profiler.h" 34 #include "heap-profiler.h"
35 #include "debug.h" 35 #include "debug.h"
36 #include "types.h" 36 #include "types.h"
37 #include "v8conversions.h"
37 38
38 namespace v8 { 39 namespace v8 {
39 namespace internal { 40 namespace internal {
40 41
41 42
42 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to) 43 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to)
43 : type_(type), 44 : type_(type),
44 from_index_(from), 45 from_index_(from),
45 to_index_(to), 46 to_index_(to),
46 name_(name) { 47 name_(name) {
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 } else if (object->IsHeapNumber()) { 893 } else if (object->IsHeapNumber()) {
893 return AddEntry(object, HeapEntry::kHeapNumber, "number"); 894 return AddEntry(object, HeapEntry::kHeapNumber, "number");
894 } 895 }
895 return AddEntry(object, HeapEntry::kHidden, GetSystemEntryName(object)); 896 return AddEntry(object, HeapEntry::kHidden, GetSystemEntryName(object));
896 } 897 }
897 898
898 899
899 HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object, 900 HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object,
900 HeapEntry::Type type, 901 HeapEntry::Type type,
901 const char* name) { 902 const char* name) {
902 int object_size = object->Size(); 903 return AddEntry(object->address(), type, name, object->Size());
903 SnapshotObjectId object_id =
904 heap_object_map_->FindOrAddEntry(object->address(), object_size);
905 return snapshot_->AddEntry(type, name, object_id, object_size);
906 } 904 }
907 905
908 906
907 HeapEntry* V8HeapExplorer::AddEntry(Address address,
908 HeapEntry::Type type,
909 const char* name,
910 int size) {
911 SnapshotObjectId object_id = heap_object_map_->FindOrAddEntry(address, size);
912 return snapshot_->AddEntry(type, name, object_id, size);
913 }
914
915
909 class GcSubrootsEnumerator : public ObjectVisitor { 916 class GcSubrootsEnumerator : public ObjectVisitor {
910 public: 917 public:
911 GcSubrootsEnumerator( 918 GcSubrootsEnumerator(
912 SnapshotFillerInterface* filler, V8HeapExplorer* explorer) 919 SnapshotFillerInterface* filler, V8HeapExplorer* explorer)
913 : filler_(filler), 920 : filler_(filler),
914 explorer_(explorer), 921 explorer_(explorer),
915 previous_object_count_(0), 922 previous_object_count_(0),
916 object_count_(0) { 923 object_count_(0) {
917 } 924 }
918 void VisitPointers(Object** start, Object** end) { 925 void VisitPointers(Object** start, Object** end) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 }; 1029 };
1023 1030
1024 1031
1025 void V8HeapExplorer::ExtractReferences(HeapObject* obj) { 1032 void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
1026 HeapEntry* heap_entry = GetEntry(obj); 1033 HeapEntry* heap_entry = GetEntry(obj);
1027 if (heap_entry == NULL) return; // No interest in this object. 1034 if (heap_entry == NULL) return; // No interest in this object.
1028 int entry = heap_entry->index(); 1035 int entry = heap_entry->index();
1029 1036
1030 if (obj->IsJSGlobalProxy()) { 1037 if (obj->IsJSGlobalProxy()) {
1031 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj)); 1038 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj));
1039 } else if (obj->IsJSArrayBuffer()) {
1040 ExtractJSArrayBufferReferences(entry, JSArrayBuffer::cast(obj));
1032 } else if (obj->IsJSObject()) { 1041 } else if (obj->IsJSObject()) {
1033 ExtractJSObjectReferences(entry, JSObject::cast(obj)); 1042 ExtractJSObjectReferences(entry, JSObject::cast(obj));
1034 } else if (obj->IsString()) { 1043 } else if (obj->IsString()) {
1035 ExtractStringReferences(entry, String::cast(obj)); 1044 ExtractStringReferences(entry, String::cast(obj));
1036 } else if (obj->IsContext()) { 1045 } else if (obj->IsContext()) {
1037 ExtractContextReferences(entry, Context::cast(obj)); 1046 ExtractContextReferences(entry, Context::cast(obj));
1038 } else if (obj->IsMap()) { 1047 } else if (obj->IsMap()) {
1039 ExtractMapReferences(entry, Map::cast(obj)); 1048 ExtractMapReferences(entry, Map::cast(obj));
1040 } else if (obj->IsSharedFunctionInfo()) { 1049 } else if (obj->IsSharedFunctionInfo()) {
1041 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); 1050 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 "global_receiver", global_obj->global_receiver(), 1149 "global_receiver", global_obj->global_receiver(),
1141 GlobalObject::kGlobalReceiverOffset); 1150 GlobalObject::kGlobalReceiverOffset);
1142 STATIC_CHECK(GlobalObject::kHeaderSize - JSObject::kHeaderSize == 1151 STATIC_CHECK(GlobalObject::kHeaderSize - JSObject::kHeaderSize ==
1143 4 * kPointerSize); 1152 4 * kPointerSize);
1144 } else if (obj->IsJSArrayBufferView()) { 1153 } else if (obj->IsJSArrayBufferView()) {
1145 JSArrayBufferView* view = JSArrayBufferView::cast(obj); 1154 JSArrayBufferView* view = JSArrayBufferView::cast(obj);
1146 SetInternalReference(view, entry, "buffer", view->buffer(), 1155 SetInternalReference(view, entry, "buffer", view->buffer(),
1147 JSArrayBufferView::kBufferOffset); 1156 JSArrayBufferView::kBufferOffset);
1148 SetWeakReference(view, entry, "weak_next", view->weak_next(), 1157 SetWeakReference(view, entry, "weak_next", view->weak_next(),
1149 JSArrayBufferView::kWeakNextOffset); 1158 JSArrayBufferView::kWeakNextOffset);
1150 } else if (obj->IsJSArrayBuffer()) {
1151 JSArrayBuffer* buffer = JSArrayBuffer::cast(obj);
1152 SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
1153 JSArrayBuffer::kWeakNextOffset);
1154 SetWeakReference(buffer, entry,
1155 "weak_first_view", buffer->weak_first_view(),
1156 JSArrayBuffer::kWeakFirstViewOffset);
1157 } 1159 }
1158 TagObject(js_obj->properties(), "(object properties)"); 1160 TagObject(js_obj->properties(), "(object properties)");
1159 SetInternalReference(obj, entry, 1161 SetInternalReference(obj, entry,
1160 "properties", js_obj->properties(), 1162 "properties", js_obj->properties(),
1161 JSObject::kPropertiesOffset); 1163 JSObject::kPropertiesOffset);
1162 TagObject(js_obj->elements(), "(object elements)"); 1164 TagObject(js_obj->elements(), "(object elements)");
1163 SetInternalReference(obj, entry, 1165 SetInternalReference(obj, entry,
1164 "elements", js_obj->elements(), 1166 "elements", js_obj->elements(),
1165 JSObject::kElementsOffset); 1167 JSObject::kElementsOffset);
1166 } 1168 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 AllocationSite::kNestedSiteOffset); 1449 AllocationSite::kNestedSiteOffset);
1448 SetInternalReference(site, entry, "dependent_code", site->dependent_code(), 1450 SetInternalReference(site, entry, "dependent_code", site->dependent_code(),
1449 AllocationSite::kDependentCodeOffset); 1451 AllocationSite::kDependentCodeOffset);
1450 // Do not visit weak_next as it is not visited by the StaticVisitor, 1452 // Do not visit weak_next as it is not visited by the StaticVisitor,
1451 // and we're not very interested in weak_next field here. 1453 // and we're not very interested in weak_next field here.
1452 STATIC_CHECK(AllocationSite::kWeakNextOffset >= 1454 STATIC_CHECK(AllocationSite::kWeakNextOffset >=
1453 AllocationSite::BodyDescriptor::kEndOffset); 1455 AllocationSite::BodyDescriptor::kEndOffset);
1454 } 1456 }
1455 1457
1456 1458
1459 void V8HeapExplorer::ExtractJSArrayBufferReferences(
1460 int entry, JSArrayBuffer* buffer) {
1461 SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
1462 JSArrayBuffer::kWeakNextOffset);
1463 SetWeakReference(buffer, entry,
1464 "weak_first_view", buffer->weak_first_view(),
1465 JSArrayBuffer::kWeakFirstViewOffset);
1466 // Setup a reference to a native memory backing_store object.
1467 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
1468 CHECK(data_size <= static_cast<size_t>(kMaxInt));
1469 HeapEntry* data_entry = AddEntry(
1470 static_cast<Address>(buffer->backing_store()),
1471 HeapEntry::kNative, "system / ArrayBufferData",
1472 static_cast<int>(data_size));
1473 filler_->SetNamedReference(HeapGraphEdge::kInternal,
1474 entry, "backing_store", data_entry);
1475 }
1476
1477
1457 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { 1478 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) {
1458 if (!js_obj->IsJSFunction()) return; 1479 if (!js_obj->IsJSFunction()) return;
1459 1480
1460 JSFunction* func = JSFunction::cast(js_obj); 1481 JSFunction* func = JSFunction::cast(js_obj);
1461 if (func->shared()->bound()) { 1482 if (func->shared()->bound()) {
1462 FixedArray* bindings = func->function_bindings(); 1483 FixedArray* bindings = func->function_bindings();
1463 SetNativeBindReference(js_obj, entry, "bound_this", 1484 SetNativeBindReference(js_obj, entry, "bound_this",
1464 bindings->get(JSFunction::kBoundThisIndex)); 1485 bindings->get(JSFunction::kBoundThisIndex));
1465 SetNativeBindReference(js_obj, entry, "bound_function", 1486 SetNativeBindReference(js_obj, entry, "bound_function",
1466 bindings->get(JSFunction::kBoundFunctionIndex)); 1487 bindings->get(JSFunction::kBoundFunctionIndex));
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 writer_->AddString("\"<dummy>\""); 3021 writer_->AddString("\"<dummy>\"");
3001 for (int i = 1; i < sorted_strings.length(); ++i) { 3022 for (int i = 1; i < sorted_strings.length(); ++i) {
3002 writer_->AddCharacter(','); 3023 writer_->AddCharacter(',');
3003 SerializeString(sorted_strings[i]); 3024 SerializeString(sorted_strings[i]);
3004 if (writer_->aborted()) return; 3025 if (writer_->aborted()) return;
3005 } 3026 }
3006 } 3027 }
3007 3028
3008 3029
3009 } } // namespace v8::internal 3030 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698