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