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

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

Issue 1542963002: [runtime] Introduce dedicated JSBoundFunction to represent bound functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@FunctionConstructor
Patch Set: [arm64] Poke does not preserve flags with --debug-code. Created 4 years, 11 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
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | src/runtime/runtime.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/heap-snapshot-generator.h" 5 #include "src/profiler/heap-snapshot-generator.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/objects-body-descriptors.h" 10 #include "src/objects-body-descriptors.h"
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 798
799 HeapEntry* V8HeapExplorer::AllocateEntry(HeapThing ptr) { 799 HeapEntry* V8HeapExplorer::AllocateEntry(HeapThing ptr) {
800 return AddEntry(reinterpret_cast<HeapObject*>(ptr)); 800 return AddEntry(reinterpret_cast<HeapObject*>(ptr));
801 } 801 }
802 802
803 803
804 HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object) { 804 HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object) {
805 if (object->IsJSFunction()) { 805 if (object->IsJSFunction()) {
806 JSFunction* func = JSFunction::cast(object); 806 JSFunction* func = JSFunction::cast(object);
807 SharedFunctionInfo* shared = func->shared(); 807 SharedFunctionInfo* shared = func->shared();
808 const char* name = shared->bound() ? "native_bind" : 808 const char* name = names_->GetName(String::cast(shared->name()));
809 names_->GetName(String::cast(shared->name()));
810 return AddEntry(object, HeapEntry::kClosure, name); 809 return AddEntry(object, HeapEntry::kClosure, name);
810 } else if (object->IsJSBoundFunction()) {
811 return AddEntry(object, HeapEntry::kClosure, "native_bind");
811 } else if (object->IsJSRegExp()) { 812 } else if (object->IsJSRegExp()) {
812 JSRegExp* re = JSRegExp::cast(object); 813 JSRegExp* re = JSRegExp::cast(object);
813 return AddEntry(object, 814 return AddEntry(object,
814 HeapEntry::kRegExp, 815 HeapEntry::kRegExp,
815 names_->GetName(re->Pattern())); 816 names_->GetName(re->Pattern()));
816 } else if (object->IsJSObject()) { 817 } else if (object->IsJSObject()) {
817 const char* name = names_->GetName( 818 const char* name = names_->GetName(
818 GetConstructorName(JSObject::cast(object))); 819 GetConstructorName(JSObject::cast(object)));
819 if (object->IsJSGlobalObject()) { 820 if (object->IsJSGlobalObject()) {
820 const char* tag = objects_tags_.GetTag(object); 821 const char* tag = objects_tags_.GetTag(object);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 int entry, JSGlobalProxy* proxy) { 1092 int entry, JSGlobalProxy* proxy) {
1092 SetInternalReference(proxy, entry, 1093 SetInternalReference(proxy, entry,
1093 "native_context", proxy->native_context(), 1094 "native_context", proxy->native_context(),
1094 JSGlobalProxy::kNativeContextOffset); 1095 JSGlobalProxy::kNativeContextOffset);
1095 } 1096 }
1096 1097
1097 1098
1098 void V8HeapExplorer::ExtractJSObjectReferences( 1099 void V8HeapExplorer::ExtractJSObjectReferences(
1099 int entry, JSObject* js_obj) { 1100 int entry, JSObject* js_obj) {
1100 HeapObject* obj = js_obj; 1101 HeapObject* obj = js_obj;
1101 ExtractClosureReferences(js_obj, entry);
1102 ExtractPropertyReferences(js_obj, entry); 1102 ExtractPropertyReferences(js_obj, entry);
1103 ExtractElementReferences(js_obj, entry); 1103 ExtractElementReferences(js_obj, entry);
1104 ExtractInternalReferences(js_obj, entry); 1104 ExtractInternalReferences(js_obj, entry);
1105 PrototypeIterator iter(heap_->isolate(), js_obj); 1105 PrototypeIterator iter(heap_->isolate(), js_obj);
1106 SetPropertyReference(obj, entry, heap_->proto_string(), iter.GetCurrent()); 1106 SetPropertyReference(obj, entry, heap_->proto_string(), iter.GetCurrent());
1107 if (obj->IsJSFunction()) { 1107 if (obj->IsJSBoundFunction()) {
1108 JSBoundFunction* js_fun = JSBoundFunction::cast(obj);
1109 TagObject(js_fun->bound_arguments(), "(bound arguments)");
1110 SetInternalReference(js_fun, entry, "bindings", js_fun->bound_arguments(),
1111 JSBoundFunction::kBoundArgumentsOffset);
1112 TagObject(js_fun->creation_context(), "(creation context)");
1113 SetInternalReference(js_fun, entry, "creation_context",
1114 js_fun->creation_context(),
1115 JSBoundFunction::kCreationContextOffset);
1116 SetNativeBindReference(js_obj, entry, "bound_this", js_fun->bound_this());
1117 SetNativeBindReference(js_obj, entry, "bound_function",
1118 js_fun->bound_target_function());
1119 FixedArray* bindings = js_fun->bound_arguments();
1120 for (int i = 0; i < bindings->length(); i++) {
1121 const char* reference_name = names_->GetFormatted("bound_argument_%d", i);
1122 SetNativeBindReference(js_obj, entry, reference_name, bindings->get(i));
1123 }
1124 } else if (obj->IsJSFunction()) {
1108 JSFunction* js_fun = JSFunction::cast(js_obj); 1125 JSFunction* js_fun = JSFunction::cast(js_obj);
1109 Object* proto_or_map = js_fun->prototype_or_initial_map(); 1126 Object* proto_or_map = js_fun->prototype_or_initial_map();
1110 if (!proto_or_map->IsTheHole()) { 1127 if (!proto_or_map->IsTheHole()) {
1111 if (!proto_or_map->IsMap()) { 1128 if (!proto_or_map->IsMap()) {
1112 SetPropertyReference( 1129 SetPropertyReference(
1113 obj, entry, 1130 obj, entry,
1114 heap_->prototype_string(), proto_or_map, 1131 heap_->prototype_string(), proto_or_map,
1115 NULL, 1132 NULL,
1116 JSFunction::kPrototypeOrInitialMapOffset); 1133 JSFunction::kPrototypeOrInitialMapOffset);
1117 } else { 1134 } else {
1118 SetPropertyReference( 1135 SetPropertyReference(
1119 obj, entry, 1136 obj, entry,
1120 heap_->prototype_string(), js_fun->prototype()); 1137 heap_->prototype_string(), js_fun->prototype());
1121 SetInternalReference( 1138 SetInternalReference(
1122 obj, entry, "initial_map", proto_or_map, 1139 obj, entry, "initial_map", proto_or_map,
1123 JSFunction::kPrototypeOrInitialMapOffset); 1140 JSFunction::kPrototypeOrInitialMapOffset);
1124 } 1141 }
1125 } 1142 }
1126 SharedFunctionInfo* shared_info = js_fun->shared(); 1143 SharedFunctionInfo* shared_info = js_fun->shared();
1127 // JSFunction has either bindings or literals and never both. 1144 TagObject(js_fun->literals(), "(function literals)");
1128 bool bound = shared_info->bound(); 1145 SetInternalReference(js_fun, entry, "literals", js_fun->literals(),
1129 TagObject(js_fun->literals_or_bindings(),
1130 bound ? "(function bindings)" : "(function literals)");
1131 SetInternalReference(js_fun, entry,
1132 bound ? "bindings" : "literals",
1133 js_fun->literals_or_bindings(),
1134 JSFunction::kLiteralsOffset); 1146 JSFunction::kLiteralsOffset);
1135 TagObject(shared_info, "(shared function info)"); 1147 TagObject(shared_info, "(shared function info)");
1136 SetInternalReference(js_fun, entry, 1148 SetInternalReference(js_fun, entry,
1137 "shared", shared_info, 1149 "shared", shared_info,
1138 JSFunction::kSharedFunctionInfoOffset); 1150 JSFunction::kSharedFunctionInfoOffset);
1139 TagObject(js_fun->context(), "(context)"); 1151 TagObject(js_fun->context(), "(context)");
1140 SetInternalReference(js_fun, entry, 1152 SetInternalReference(js_fun, entry,
1141 "context", js_fun->context(), 1153 "context", js_fun->context(),
1142 JSFunction::kContextOffset); 1154 JSFunction::kContextOffset);
1143 SetWeakReference(js_fun, entry, 1155 SetWeakReference(js_fun, entry,
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 SetWeakReference(array, entry, 1580 SetWeakReference(array, entry,
1569 i, array->get(i), array->OffsetOfElementAt(i)); 1581 i, array->get(i), array->OffsetOfElementAt(i));
1570 } else { 1582 } else {
1571 SetInternalReference(array, entry, 1583 SetInternalReference(array, entry,
1572 i, array->get(i), array->OffsetOfElementAt(i)); 1584 i, array->get(i), array->OffsetOfElementAt(i));
1573 } 1585 }
1574 } 1586 }
1575 } 1587 }
1576 1588
1577 1589
1578 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) {
1579 if (!js_obj->IsJSFunction()) return;
1580
1581 JSFunction* func = JSFunction::cast(js_obj);
1582 if (func->shared()->bound()) {
1583 BindingsArray* bindings = func->function_bindings();
1584 SetNativeBindReference(js_obj, entry, "bound_this", bindings->bound_this());
1585 SetNativeBindReference(js_obj, entry, "bound_function",
1586 bindings->bound_function());
1587 for (int i = 0; i < bindings->bindings_count(); i++) {
1588 const char* reference_name = names_->GetFormatted("bound_argument_%d", i);
1589 SetNativeBindReference(js_obj, entry, reference_name,
1590 bindings->binding(i));
1591 }
1592 }
1593 }
1594
1595
1596 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { 1590 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
1597 if (js_obj->HasFastProperties()) { 1591 if (js_obj->HasFastProperties()) {
1598 DescriptorArray* descs = js_obj->map()->instance_descriptors(); 1592 DescriptorArray* descs = js_obj->map()->instance_descriptors();
1599 int real_size = js_obj->map()->NumberOfOwnDescriptors(); 1593 int real_size = js_obj->map()->NumberOfOwnDescriptors();
1600 for (int i = 0; i < real_size; i++) { 1594 for (int i = 0; i < real_size; i++) {
1601 PropertyDetails details = descs->GetDetails(i); 1595 PropertyDetails details = descs->GetDetails(i);
1602 switch (details.location()) { 1596 switch (details.location()) {
1603 case kField: { 1597 case kField: {
1604 Representation r = details.representation(); 1598 Representation r = details.representation();
1605 if (r.IsSmi() || r.IsDouble()) break; 1599 if (r.IsSmi() || r.IsDouble()) break;
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 for (int i = 1; i < sorted_strings.length(); ++i) { 3161 for (int i = 1; i < sorted_strings.length(); ++i) {
3168 writer_->AddCharacter(','); 3162 writer_->AddCharacter(',');
3169 SerializeString(sorted_strings[i]); 3163 SerializeString(sorted_strings[i]);
3170 if (writer_->aborted()) return; 3164 if (writer_->aborted()) return;
3171 } 3165 }
3172 } 3166 }
3173 3167
3174 3168
3175 } // namespace internal 3169 } // namespace internal
3176 } // namespace v8 3170 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698