Chromium Code Reviews| 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"; | |
| 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 Loading... | |
| 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 Loading... | |
| 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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 } | 1020 } |
| 1017 | 1021 |
| 1018 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( | 1022 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( |
| 1019 Handle<Name> name, Handle<Map> receiver_map) { | 1023 Handle<Name> name, Handle<Map> receiver_map) { |
| 1020 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 1024 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
| 1021 | 1025 |
| 1022 SetFeedback(*cell); | 1026 SetFeedback(*cell); |
| 1023 SetFeedbackExtra(*name); | 1027 SetFeedbackExtra(*name); |
| 1024 } | 1028 } |
| 1025 | 1029 |
| 1030 InlineCacheState CollectTypeProfileNexus::StateFromFeedback() const { | |
| 1031 Isolate* isolate = GetIsolate(); | |
| 1032 Object* const feedback = GetFeedback(); | |
| 1033 | |
| 1034 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) { | |
| 1035 return UNINITIALIZED; | |
| 1036 } | |
| 1037 return MONOMORPHIC; | |
| 1038 } | |
| 1039 | |
| 1040 void CollectTypeProfileNexus::Collect(Handle<Name> type) { | |
| 1041 Isolate* isolate = GetIsolate(); | |
| 1042 | |
| 1043 Object* const feedback = GetFeedback(); | |
| 1044 Handle<ArrayList> types; | |
| 1045 | |
| 1046 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) { | |
| 1047 types = ArrayList::New(isolate, 1); | |
| 1048 } else { | |
| 1049 types = Handle<ArrayList>(ArrayList::cast(feedback), isolate); | |
| 1050 } | |
| 1051 // TODO(franzih): Somehow sort this list. Either avoid duplicates | |
| 1052 // or use the common base type. | |
| 1053 SetFeedback(*ArrayList::Add(types, type)); | |
|
Yang
2017/03/09 10:28:27
We could use a StringSet here.
Franzi
2017/03/10 12:14:28
Ok. Didn't know we have those. If it's OK, I'll do
| |
| 1054 } | |
| 1055 | |
| 1056 void CollectTypeProfileNexus::Print() const { | |
| 1057 Isolate* isolate = GetIsolate(); | |
| 1058 | |
| 1059 Object* const feedback = GetFeedback(); | |
| 1060 | |
| 1061 if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) { | |
| 1062 return; | |
| 1063 } | |
| 1064 | |
| 1065 Handle<ArrayList> list; | |
| 1066 list = Handle<ArrayList>(ArrayList::cast(feedback), isolate); | |
| 1067 | |
| 1068 for (int i = 0; i < list->Length(); i++) { | |
| 1069 Name* name = Name::cast(list->Get(i)); | |
| 1070 name->Print(); | |
| 1071 } | |
| 1072 } | |
| 1073 | |
| 1026 } // namespace internal | 1074 } // namespace internal |
| 1027 } // namespace v8 | 1075 } // namespace v8 |
| OLD | NEW |