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/type-feedback-vector.h" | 5 #include "src/type-feedback-vector.h" |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) { | 106 const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) { |
107 switch (kind) { | 107 switch (kind) { |
108 case FeedbackVectorSlotKind::INVALID: | 108 case FeedbackVectorSlotKind::INVALID: |
109 return "INVALID"; | 109 return "INVALID"; |
110 case FeedbackVectorSlotKind::CALL_IC: | 110 case FeedbackVectorSlotKind::CALL_IC: |
111 return "CALL_IC"; | 111 return "CALL_IC"; |
112 case FeedbackVectorSlotKind::CONSTRUCT_IC: | |
113 return "CONSTRUCT_IC"; | |
114 case FeedbackVectorSlotKind::LOAD_IC: | 112 case FeedbackVectorSlotKind::LOAD_IC: |
115 return "LOAD_IC"; | 113 return "LOAD_IC"; |
116 case FeedbackVectorSlotKind::KEYED_LOAD_IC: | 114 case FeedbackVectorSlotKind::KEYED_LOAD_IC: |
117 return "KEYED_LOAD_IC"; | 115 return "KEYED_LOAD_IC"; |
118 case FeedbackVectorSlotKind::STORE_IC: | 116 case FeedbackVectorSlotKind::STORE_IC: |
119 return "STORE_IC"; | 117 return "STORE_IC"; |
120 case FeedbackVectorSlotKind::KEYED_STORE_IC: | 118 case FeedbackVectorSlotKind::KEYED_STORE_IC: |
121 return "KEYED_STORE_IC"; | 119 return "KEYED_STORE_IC"; |
122 case FeedbackVectorSlotKind::GENERAL: | 120 case FeedbackVectorSlotKind::GENERAL: |
123 return "STUB"; | 121 return "STUB"; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 FeedbackVectorSlotKind kind = iter.kind(); | 215 FeedbackVectorSlotKind kind = iter.kind(); |
218 | 216 |
219 Object* obj = Get(slot); | 217 Object* obj = Get(slot); |
220 if (obj != uninitialized_sentinel) { | 218 if (obj != uninitialized_sentinel) { |
221 switch (kind) { | 219 switch (kind) { |
222 case FeedbackVectorSlotKind::CALL_IC: { | 220 case FeedbackVectorSlotKind::CALL_IC: { |
223 CallICNexus nexus(this, slot); | 221 CallICNexus nexus(this, slot); |
224 nexus.Clear(shared->code()); | 222 nexus.Clear(shared->code()); |
225 break; | 223 break; |
226 } | 224 } |
227 case FeedbackVectorSlotKind::CONSTRUCT_IC: { | |
228 ConstructICNexus nexus(this, slot); | |
229 nexus.Clear(shared->code()); | |
230 break; | |
231 } | |
232 case FeedbackVectorSlotKind::LOAD_IC: { | 225 case FeedbackVectorSlotKind::LOAD_IC: { |
233 LoadICNexus nexus(this, slot); | 226 LoadICNexus nexus(this, slot); |
234 nexus.Clear(shared->code()); | 227 nexus.Clear(shared->code()); |
235 break; | 228 break; |
236 } | 229 } |
237 case FeedbackVectorSlotKind::KEYED_LOAD_IC: { | 230 case FeedbackVectorSlotKind::KEYED_LOAD_IC: { |
238 KeyedLoadICNexus nexus(this, slot); | 231 KeyedLoadICNexus nexus(this, slot); |
239 nexus.Clear(shared->code()); | 232 nexus.Clear(shared->code()); |
240 break; | 233 break; |
241 } | 234 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return GENERIC; | 478 return GENERIC; |
486 } else if (feedback->IsAllocationSite() || feedback->IsWeakCell()) { | 479 } else if (feedback->IsAllocationSite() || feedback->IsWeakCell()) { |
487 return MONOMORPHIC; | 480 return MONOMORPHIC; |
488 } | 481 } |
489 | 482 |
490 CHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)); | 483 CHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)); |
491 return UNINITIALIZED; | 484 return UNINITIALIZED; |
492 } | 485 } |
493 | 486 |
494 | 487 |
495 Handle<Object> CallICNexus::GetCallFeedback() { | |
496 Object* feedback = GetFeedback(); | |
497 if (feedback->IsWeakCell()) { | |
498 feedback = WeakCell::cast(feedback)->value(); | |
499 } | |
500 if (!feedback->IsJSFunction() && !feedback->IsAllocationSite()) { | |
501 feedback = GetIsolate()->heap()->undefined_value(); | |
502 } | |
503 return handle(feedback, GetIsolate()); | |
504 } | |
505 | |
506 | |
507 int CallICNexus::ExtractCallCount() { | 488 int CallICNexus::ExtractCallCount() { |
508 Object* call_count = GetFeedbackExtra(); | 489 Object* call_count = GetFeedbackExtra(); |
509 if (call_count->IsSmi()) { | 490 if (call_count->IsSmi()) { |
510 int value = Smi::cast(call_count)->value() / 2; | 491 int value = Smi::cast(call_count)->value() / 2; |
511 return value; | 492 return value; |
512 } | 493 } |
513 return -1; | 494 return -1; |
514 } | 495 } |
515 | 496 |
516 | 497 |
517 void CallICNexus::Clear(Code* host) { CallIC::Clear(GetIsolate(), host, this); } | 498 void CallICNexus::Clear(Code* host) { CallIC::Clear(GetIsolate(), host, this); } |
518 | 499 |
519 | 500 |
520 void ConstructICNexus::Clear(Code* host) { | |
521 ConstructIC::Clear(GetIsolate(), host, this); | |
522 } | |
523 | |
524 | |
525 void CallICNexus::ConfigureMonomorphicArray() { | 501 void CallICNexus::ConfigureMonomorphicArray() { |
526 Object* feedback = GetFeedback(); | 502 Object* feedback = GetFeedback(); |
527 if (!feedback->IsAllocationSite()) { | 503 if (!feedback->IsAllocationSite()) { |
528 Handle<AllocationSite> new_site = | 504 Handle<AllocationSite> new_site = |
529 GetIsolate()->factory()->NewAllocationSite(); | 505 GetIsolate()->factory()->NewAllocationSite(); |
530 SetFeedback(*new_site); | 506 SetFeedback(*new_site); |
531 } | 507 } |
532 SetFeedbackExtra(Smi::FromInt(kCallCountIncrement), SKIP_WRITE_BARRIER); | 508 SetFeedbackExtra(Smi::FromInt(kCallCountIncrement), SKIP_WRITE_BARRIER); |
533 } | 509 } |
534 | 510 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 return mode; | 843 return mode; |
868 } | 844 } |
869 | 845 |
870 | 846 |
871 IcCheckType KeyedStoreICNexus::GetKeyType() const { | 847 IcCheckType KeyedStoreICNexus::GetKeyType() const { |
872 // The structure of the vector slots tells us the type. | 848 // The structure of the vector slots tells us the type. |
873 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; | 849 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; |
874 } | 850 } |
875 } // namespace internal | 851 } // namespace internal |
876 } // namespace v8 | 852 } // namespace v8 |
OLD | NEW |