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

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

Issue 1552473002: Revert of [runtime] Introduce dedicated JSBoundFunction to represent bound functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@FunctionConstructor
Patch Set: 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 = names_->GetName(String::cast(shared->name())); 808 const char* name = shared->bound() ? "native_bind" :
809 names_->GetName(String::cast(shared->name()));
809 return AddEntry(object, HeapEntry::kClosure, name); 810 return AddEntry(object, HeapEntry::kClosure, name);
810 } else if (object->IsJSBoundFunction()) {
811 return AddEntry(object, HeapEntry::kClosure, "native_bind");
812 } else if (object->IsJSRegExp()) { 811 } else if (object->IsJSRegExp()) {
813 JSRegExp* re = JSRegExp::cast(object); 812 JSRegExp* re = JSRegExp::cast(object);
814 return AddEntry(object, 813 return AddEntry(object,
815 HeapEntry::kRegExp, 814 HeapEntry::kRegExp,
816 names_->GetName(re->Pattern())); 815 names_->GetName(re->Pattern()));
817 } else if (object->IsJSObject()) { 816 } else if (object->IsJSObject()) {
818 const char* name = names_->GetName( 817 const char* name = names_->GetName(
819 GetConstructorName(JSObject::cast(object))); 818 GetConstructorName(JSObject::cast(object)));
820 if (object->IsJSGlobalObject()) { 819 if (object->IsJSGlobalObject()) {
821 const char* tag = objects_tags_.GetTag(object); 820 const char* tag = objects_tags_.GetTag(object);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 int entry, JSGlobalProxy* proxy) { 1091 int entry, JSGlobalProxy* proxy) {
1093 SetInternalReference(proxy, entry, 1092 SetInternalReference(proxy, entry,
1094 "native_context", proxy->native_context(), 1093 "native_context", proxy->native_context(),
1095 JSGlobalProxy::kNativeContextOffset); 1094 JSGlobalProxy::kNativeContextOffset);
1096 } 1095 }
1097 1096
1098 1097
1099 void V8HeapExplorer::ExtractJSObjectReferences( 1098 void V8HeapExplorer::ExtractJSObjectReferences(
1100 int entry, JSObject* js_obj) { 1099 int entry, JSObject* js_obj) {
1101 HeapObject* obj = js_obj; 1100 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->IsJSBoundFunction()) { 1107 if (obj->IsJSFunction()) {
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()) {
1125 JSFunction* js_fun = JSFunction::cast(js_obj); 1108 JSFunction* js_fun = JSFunction::cast(js_obj);
1126 Object* proto_or_map = js_fun->prototype_or_initial_map(); 1109 Object* proto_or_map = js_fun->prototype_or_initial_map();
1127 if (!proto_or_map->IsTheHole()) { 1110 if (!proto_or_map->IsTheHole()) {
1128 if (!proto_or_map->IsMap()) { 1111 if (!proto_or_map->IsMap()) {
1129 SetPropertyReference( 1112 SetPropertyReference(
1130 obj, entry, 1113 obj, entry,
1131 heap_->prototype_string(), proto_or_map, 1114 heap_->prototype_string(), proto_or_map,
1132 NULL, 1115 NULL,
1133 JSFunction::kPrototypeOrInitialMapOffset); 1116 JSFunction::kPrototypeOrInitialMapOffset);
1134 } else { 1117 } else {
1135 SetPropertyReference( 1118 SetPropertyReference(
1136 obj, entry, 1119 obj, entry,
1137 heap_->prototype_string(), js_fun->prototype()); 1120 heap_->prototype_string(), js_fun->prototype());
1138 SetInternalReference( 1121 SetInternalReference(
1139 obj, entry, "initial_map", proto_or_map, 1122 obj, entry, "initial_map", proto_or_map,
1140 JSFunction::kPrototypeOrInitialMapOffset); 1123 JSFunction::kPrototypeOrInitialMapOffset);
1141 } 1124 }
1142 } 1125 }
1143 SharedFunctionInfo* shared_info = js_fun->shared(); 1126 SharedFunctionInfo* shared_info = js_fun->shared();
1144 TagObject(js_fun->literals(), "(function literals)"); 1127 // JSFunction has either bindings or literals and never both.
1145 SetInternalReference(js_fun, entry, "literals", js_fun->literals(), 1128 bool bound = shared_info->bound();
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(),
1146 JSFunction::kLiteralsOffset); 1134 JSFunction::kLiteralsOffset);
1147 TagObject(shared_info, "(shared function info)"); 1135 TagObject(shared_info, "(shared function info)");
1148 SetInternalReference(js_fun, entry, 1136 SetInternalReference(js_fun, entry,
1149 "shared", shared_info, 1137 "shared", shared_info,
1150 JSFunction::kSharedFunctionInfoOffset); 1138 JSFunction::kSharedFunctionInfoOffset);
1151 TagObject(js_fun->context(), "(context)"); 1139 TagObject(js_fun->context(), "(context)");
1152 SetInternalReference(js_fun, entry, 1140 SetInternalReference(js_fun, entry,
1153 "context", js_fun->context(), 1141 "context", js_fun->context(),
1154 JSFunction::kContextOffset); 1142 JSFunction::kContextOffset);
1155 SetWeakReference(js_fun, entry, 1143 SetWeakReference(js_fun, entry,
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 for (int i = 0, l = array->length(); i < l; ++i) { 1566 for (int i = 0, l = array->length(); i < l; ++i) {
1579 if (is_weak) { 1567 if (is_weak) {
1580 SetWeakReference(array, entry, 1568 SetWeakReference(array, entry,
1581 i, array->get(i), array->OffsetOfElementAt(i)); 1569 i, array->get(i), array->OffsetOfElementAt(i));
1582 } else { 1570 } else {
1583 SetInternalReference(array, entry, 1571 SetInternalReference(array, entry,
1584 i, array->get(i), array->OffsetOfElementAt(i)); 1572 i, array->get(i), array->OffsetOfElementAt(i));
1585 } 1573 }
1586 } 1574 }
1587 } 1575 }
1576
1577
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 }
1588 1594
1589 1595
1590 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { 1596 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
1591 if (js_obj->HasFastProperties()) { 1597 if (js_obj->HasFastProperties()) {
1592 DescriptorArray* descs = js_obj->map()->instance_descriptors(); 1598 DescriptorArray* descs = js_obj->map()->instance_descriptors();
1593 int real_size = js_obj->map()->NumberOfOwnDescriptors(); 1599 int real_size = js_obj->map()->NumberOfOwnDescriptors();
1594 for (int i = 0; i < real_size; i++) { 1600 for (int i = 0; i < real_size; i++) {
1595 PropertyDetails details = descs->GetDetails(i); 1601 PropertyDetails details = descs->GetDetails(i);
1596 switch (details.location()) { 1602 switch (details.location()) {
1597 case kField: { 1603 case kField: {
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 for (int i = 1; i < sorted_strings.length(); ++i) { 3167 for (int i = 1; i < sorted_strings.length(); ++i) {
3162 writer_->AddCharacter(','); 3168 writer_->AddCharacter(',');
3163 SerializeString(sorted_strings[i]); 3169 SerializeString(sorted_strings[i]);
3164 if (writer_->aborted()) return; 3170 if (writer_->aborted()) return;
3165 } 3171 }
3166 } 3172 }
3167 3173
3168 3174
3169 } // namespace internal 3175 } // namespace internal
3170 } // namespace v8 3176 } // 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