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

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

Issue 2707873002: Collect type profile for DevTools. (Closed)
Patch Set: Fix typo. Created 3 years, 9 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/feedback-vector.h ('k') | src/feedback-vector-inl.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 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
163 bool FeedbackMetadata::HasTypeProfileSlot() const {
164 for (int i = 0; i < slot_count();) {
165 FeedbackSlotKind kind = GetKind(FeedbackSlot(i));
mvstanton 2017/03/10 14:57:23 nit: There is also a feedback metadata iterator cl
Franzi 2017/03/11 07:04:02 Thanks. Fixed!
166 if (kind == FeedbackSlotKind::kTypeProfile) {
167 return true;
168 }
169 int entry_size = FeedbackMetadata::GetSlotSize(kind);
170 DCHECK_LT(0, entry_size);
171 i += entry_size;
172 }
173 return false;
174 }
175
161 FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const { 176 FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const {
162 DCHECK(!is_empty()); 177 DCHECK(!is_empty());
163 return metadata()->GetKind(slot); 178 return metadata()->GetKind(slot);
164 } 179 }
165 180
166 // static 181 // static
167 Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate, 182 Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate,
168 Handle<SharedFunctionInfo> shared) { 183 Handle<SharedFunctionInfo> shared) {
169 Factory* factory = isolate->factory(); 184 Factory* factory = isolate->factory();
170 185
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 break; 227 break;
213 case FeedbackSlotKind::kLoadProperty: 228 case FeedbackSlotKind::kLoadProperty:
214 case FeedbackSlotKind::kLoadKeyed: 229 case FeedbackSlotKind::kLoadKeyed:
215 case FeedbackSlotKind::kStoreNamedSloppy: 230 case FeedbackSlotKind::kStoreNamedSloppy:
216 case FeedbackSlotKind::kStoreNamedStrict: 231 case FeedbackSlotKind::kStoreNamedStrict:
217 case FeedbackSlotKind::kStoreOwnNamed: 232 case FeedbackSlotKind::kStoreOwnNamed:
218 case FeedbackSlotKind::kStoreKeyedSloppy: 233 case FeedbackSlotKind::kStoreKeyedSloppy:
219 case FeedbackSlotKind::kStoreKeyedStrict: 234 case FeedbackSlotKind::kStoreKeyedStrict:
220 case FeedbackSlotKind::kStoreDataPropertyInLiteral: 235 case FeedbackSlotKind::kStoreDataPropertyInLiteral:
221 case FeedbackSlotKind::kGeneral: 236 case FeedbackSlotKind::kGeneral:
237 case FeedbackSlotKind::kTypeProfile:
222 array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER); 238 array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
223 break; 239 break;
224 240
225 case FeedbackSlotKind::kInvalid: 241 case FeedbackSlotKind::kInvalid:
226 case FeedbackSlotKind::kKindsNumber: 242 case FeedbackSlotKind::kKindsNumber:
227 UNREACHABLE(); 243 UNREACHABLE();
228 array->set(index, Smi::kZero, SKIP_WRITE_BARRIER); 244 array->set(index, Smi::kZero, SKIP_WRITE_BARRIER);
229 break; 245 break;
230 } 246 }
231 for (int j = 1; j < entry_size; j++) { 247 for (int j = 1; j < entry_size; j++) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 break; 345 break;
330 } 346 }
331 case FeedbackSlotKind::kBinaryOp: 347 case FeedbackSlotKind::kBinaryOp:
332 case FeedbackSlotKind::kCompareOp: { 348 case FeedbackSlotKind::kCompareOp: {
333 DCHECK(Get(slot)->IsSmi()); 349 DCHECK(Get(slot)->IsSmi());
334 // don't clear these smi slots. 350 // don't clear these smi slots.
335 // Set(slot, Smi::kZero); 351 // Set(slot, Smi::kZero);
336 break; 352 break;
337 } 353 }
338 case FeedbackSlotKind::kCreateClosure: { 354 case FeedbackSlotKind::kCreateClosure: {
339 break; 355 case FeedbackSlotKind::kTypeProfile:
356 break;
340 } 357 }
341 case FeedbackSlotKind::kGeneral: { 358 case FeedbackSlotKind::kGeneral: {
342 if (obj->IsHeapObject()) { 359 if (obj->IsHeapObject()) {
343 InstanceType instance_type = 360 InstanceType instance_type =
344 HeapObject::cast(obj)->map()->instance_type(); 361 HeapObject::cast(obj)->map()->instance_type();
345 // AllocationSites are exempt from clearing. They don't store Maps 362 // AllocationSites are exempt from clearing. They don't store Maps
346 // or Code pointers which can cause memory leaks if not cleared 363 // or Code pointers which can cause memory leaks if not cleared
347 // regularly. 364 // regularly.
348 if (instance_type != ALLOCATION_SITE_TYPE) { 365 if (instance_type != ALLOCATION_SITE_TYPE) {
349 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER); 366 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER);
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 } 1033 }
1017 1034
1018 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( 1035 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic(
1019 Handle<Name> name, Handle<Map> receiver_map) { 1036 Handle<Name> name, Handle<Map> receiver_map) {
1020 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 1037 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
1021 1038
1022 SetFeedback(*cell); 1039 SetFeedback(*cell);
1023 SetFeedbackExtra(*name); 1040 SetFeedbackExtra(*name);
1024 } 1041 }
1025 1042
1043 InlineCacheState CollectTypeProfileNexus::StateFromFeedback() const {
1044 Isolate* isolate = GetIsolate();
1045 Object* const feedback = GetFeedback();
1046
1047 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
1048 return UNINITIALIZED;
1049 }
1050 return MONOMORPHIC;
1051 }
1052
1053 void CollectTypeProfileNexus::Collect(Handle<Name> type) {
1054 Isolate* isolate = GetIsolate();
1055
1056 Object* const feedback = GetFeedback();
1057 Handle<ArrayList> types;
1058
1059 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
1060 types = ArrayList::New(isolate, 1);
1061 } else {
1062 types = Handle<ArrayList>(ArrayList::cast(feedback), isolate);
1063 }
1064 // TODO(franzih): Somehow sort this list. Either avoid duplicates
1065 // or use the common base type.
1066 SetFeedback(*ArrayList::Add(types, type));
1067 }
1068
1069 void CollectTypeProfileNexus::Print() const {
1070 Isolate* isolate = GetIsolate();
1071
1072 Object* const feedback = GetFeedback();
1073
1074 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
1075 return;
1076 }
1077
1078 Handle<ArrayList> list;
1079 list = Handle<ArrayList>(ArrayList::cast(feedback), isolate);
1080
1081 for (int i = 0; i < list->Length(); i++) {
1082 Name* name = Name::cast(list->Get(i));
1083 name->Print();
1084 }
1085 }
1086
1026 } // namespace internal 1087 } // namespace internal
1027 } // namespace v8 1088 } // namespace v8
OLDNEW
« no previous file with comments | « src/feedback-vector.h ('k') | src/feedback-vector-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698