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

Side by Side Diff: src/feedback-vector.cc

Issue 2707873002: Collect type profile for DevTools. (Closed)
Patch Set: Use constructor name if available. Created 3 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/feedback-vector.h" 5 #include "src/feedback-vector.h"
6 #include "src/code-stubs.h" 6 #include "src/code-stubs.h"
7 #include "src/feedback-vector-inl.h" 7 #include "src/feedback-vector-inl.h"
8 #include "src/ic/ic-inl.h" 8 #include "src/ic/ic-inl.h"
9 #include "src/ic/ic-state.h" 9 #include "src/ic/ic-state.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 case FeedbackSlotKind::kCompareOp: 142 case FeedbackSlotKind::kCompareOp:
143 return "INTERPRETER_COMPARE_IC"; 143 return "INTERPRETER_COMPARE_IC";
144 case FeedbackSlotKind::kToBoolean: 144 case FeedbackSlotKind::kToBoolean:
145 return "TO_BOOLEAN_IC"; 145 return "TO_BOOLEAN_IC";
146 case FeedbackSlotKind::kStoreDataPropertyInLiteral: 146 case FeedbackSlotKind::kStoreDataPropertyInLiteral:
147 return "STORE_DATA_PROPERTY_IN_LITERAL_IC"; 147 return "STORE_DATA_PROPERTY_IN_LITERAL_IC";
148 case FeedbackSlotKind::kCreateClosure: 148 case FeedbackSlotKind::kCreateClosure:
149 return "kCreateClosure"; 149 return "kCreateClosure";
150 case FeedbackSlotKind::kLiteral: 150 case FeedbackSlotKind::kLiteral:
151 return "LITERAL"; 151 return "LITERAL";
152 case FeedbackSlotKind::kTypeProfile:
153 return "TYPE_PROFILE";
152 case FeedbackSlotKind::kGeneral: 154 case FeedbackSlotKind::kGeneral:
153 return "STUB"; 155 return "STUB";
154 case FeedbackSlotKind::kKindsNumber: 156 case FeedbackSlotKind::kKindsNumber:
155 break; 157 break;
156 } 158 }
157 UNREACHABLE(); 159 UNREACHABLE();
158 return "?"; 160 return "?";
159 } 161 }
160 162
161 FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const { 163 FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 break; 214 break;
213 case FeedbackSlotKind::kLoadProperty: 215 case FeedbackSlotKind::kLoadProperty:
214 case FeedbackSlotKind::kLoadKeyed: 216 case FeedbackSlotKind::kLoadKeyed:
215 case FeedbackSlotKind::kStoreNamedSloppy: 217 case FeedbackSlotKind::kStoreNamedSloppy:
216 case FeedbackSlotKind::kStoreNamedStrict: 218 case FeedbackSlotKind::kStoreNamedStrict:
217 case FeedbackSlotKind::kStoreOwnNamed: 219 case FeedbackSlotKind::kStoreOwnNamed:
218 case FeedbackSlotKind::kStoreKeyedSloppy: 220 case FeedbackSlotKind::kStoreKeyedSloppy:
219 case FeedbackSlotKind::kStoreKeyedStrict: 221 case FeedbackSlotKind::kStoreKeyedStrict:
220 case FeedbackSlotKind::kStoreDataPropertyInLiteral: 222 case FeedbackSlotKind::kStoreDataPropertyInLiteral:
221 case FeedbackSlotKind::kGeneral: 223 case FeedbackSlotKind::kGeneral:
224 case FeedbackSlotKind::kTypeProfile:
222 array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER); 225 array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
223 break; 226 break;
224 227
225 case FeedbackSlotKind::kInvalid: 228 case FeedbackSlotKind::kInvalid:
226 case FeedbackSlotKind::kKindsNumber: 229 case FeedbackSlotKind::kKindsNumber:
227 UNREACHABLE(); 230 UNREACHABLE();
228 array->set(index, Smi::kZero, SKIP_WRITE_BARRIER); 231 array->set(index, Smi::kZero, SKIP_WRITE_BARRIER);
229 break; 232 break;
230 } 233 }
231 for (int j = 1; j < entry_size; j++) { 234 for (int j = 1; j < entry_size; j++) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 break; 332 break;
330 } 333 }
331 case FeedbackSlotKind::kBinaryOp: 334 case FeedbackSlotKind::kBinaryOp:
332 case FeedbackSlotKind::kCompareOp: { 335 case FeedbackSlotKind::kCompareOp: {
333 DCHECK(Get(slot)->IsSmi()); 336 DCHECK(Get(slot)->IsSmi());
334 // don't clear these smi slots. 337 // don't clear these smi slots.
335 // Set(slot, Smi::kZero); 338 // Set(slot, Smi::kZero);
336 break; 339 break;
337 } 340 }
338 case FeedbackSlotKind::kCreateClosure: { 341 case FeedbackSlotKind::kCreateClosure: {
339 break; 342 case FeedbackSlotKind::kTypeProfile:
343 break;
340 } 344 }
341 case FeedbackSlotKind::kGeneral: { 345 case FeedbackSlotKind::kGeneral: {
342 if (obj->IsHeapObject()) { 346 if (obj->IsHeapObject()) {
343 InstanceType instance_type = 347 InstanceType instance_type =
344 HeapObject::cast(obj)->map()->instance_type(); 348 HeapObject::cast(obj)->map()->instance_type();
345 // AllocationSites are exempt from clearing. They don't store Maps 349 // AllocationSites are exempt from clearing. They don't store Maps
346 // or Code pointers which can cause memory leaks if not cleared 350 // or Code pointers which can cause memory leaks if not cleared
347 // regularly. 351 // regularly.
348 if (instance_type != ALLOCATION_SITE_TYPE) { 352 if (instance_type != ALLOCATION_SITE_TYPE) {
349 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER); 353 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER);
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 } 1016 }
1013 1017
1014 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( 1018 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic(
1015 Handle<Name> name, Handle<Map> receiver_map) { 1019 Handle<Name> name, Handle<Map> receiver_map) {
1016 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 1020 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
1017 1021
1018 SetFeedback(*cell); 1022 SetFeedback(*cell);
1019 SetFeedbackExtra(*name); 1023 SetFeedbackExtra(*name);
1020 } 1024 }
1021 1025
1026 InlineCacheState CollectTypeProfileICNexus::StateFromFeedback() const {
1027 Isolate* isolate = GetIsolate();
1028 Object* feedback = GetFeedback();
1029
1030 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
1031 return UNINITIALIZED;
1032 } else if (feedback == *FeedbackVector::MegamorphicSentinel(isolate)) {
1033 return MEGAMORPHIC;
1034 } else if (feedback->IsName()) {
1035 // Don't check if the map is cleared.
1036 return MONOMORPHIC;
1037 }
1038
1039 DCHECK(feedback->IsArrayList());
1040 return POLYMORPHIC;
1041 }
1042
1043 void CollectTypeProfileICNexus::ConfigureMonomorphic(Handle<Name> type) {
1044 SetFeedback(*type);
1045 }
1046
1047 void CollectTypeProfileICNexus::ConfigurePolymorphic(Handle<Name> type) {
1048 Isolate* isolate = GetIsolate();
1049
1050 Object* known_types = GetFeedback();
1051 Handle<ArrayList> types;
1052 if (known_types->IsName()) {
1053 types = ArrayList::New(isolate, kMaxKeyedPolymorphism);
1054 ArrayList::Add(types, Handle<Name>(Name::cast(known_types), isolate));
1055 ArrayList::Add(types, type);
1056 } else {
1057 // This should create the union, not a list with double entries.
1058 DCHECK(known_types->IsArrayList());
1059 types = Handle<ArrayList>(ArrayList::cast(known_types), isolate);
1060 ArrayList::Add(types, type);
1061
1062 // We've reached an arbitrary number of too many different types.
1063 if (types->Length() > kMaxKeyedPolymorphism) {
1064 SetFeedback(*FeedbackVector::MegamorphicSentinel(isolate));
1065 return;
1066 }
1067 }
1068 SetFeedback(*types);
1069 }
1070
1022 } // namespace internal 1071 } // namespace internal
1023 } // namespace v8 1072 } // namespace v8
OLDNEW
« no previous file with comments | « src/feedback-vector.h ('k') | src/feedback-vector-inl.h » ('j') | src/feedback-vector-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698