| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 179   // Ensure we can skip the write barrier | 179   // Ensure we can skip the write barrier | 
| 180   Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); | 180   Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); | 
| 181   DCHECK_EQ(*factory->uninitialized_symbol(), *uninitialized_sentinel); | 181   DCHECK_EQ(*factory->uninitialized_symbol(), *uninitialized_sentinel); | 
| 182   for (int i = 0; i < slot_count;) { | 182   for (int i = 0; i < slot_count;) { | 
| 183     FeedbackVectorSlot slot(i); | 183     FeedbackVectorSlot slot(i); | 
| 184     FeedbackVectorSlotKind kind = metadata->GetKind(slot); | 184     FeedbackVectorSlotKind kind = metadata->GetKind(slot); | 
| 185     int index = TypeFeedbackVector::GetIndex(slot); | 185     int index = TypeFeedbackVector::GetIndex(slot); | 
| 186     int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); | 186     int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); | 
| 187 | 187 | 
| 188     Object* value; | 188     Object* value; | 
| 189     if (FLAG_new_load_global_ic && | 189     if (kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC) { | 
| 190         kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC) { |  | 
| 191       value = *factory->empty_weak_cell(); | 190       value = *factory->empty_weak_cell(); | 
| 192     } else { | 191     } else { | 
| 193       value = *uninitialized_sentinel; | 192       value = *uninitialized_sentinel; | 
| 194     } | 193     } | 
| 195     array->set(index, value, SKIP_WRITE_BARRIER); | 194     array->set(index, value, SKIP_WRITE_BARRIER); | 
| 196     for (int j = 1; j < entry_size; j++) { | 195     for (int j = 1; j < entry_size; j++) { | 
| 197       array->set(index + j, *uninitialized_sentinel, SKIP_WRITE_BARRIER); | 196       array->set(index + j, *uninitialized_sentinel, SKIP_WRITE_BARRIER); | 
| 198     } | 197     } | 
| 199     i += entry_size; | 198     i += entry_size; | 
| 200   } | 199   } | 
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 456     return MONOMORPHIC; | 455     return MONOMORPHIC; | 
| 457   } | 456   } | 
| 458 | 457 | 
| 459   return UNINITIALIZED; | 458   return UNINITIALIZED; | 
| 460 } | 459 } | 
| 461 | 460 | 
| 462 InlineCacheState LoadGlobalICNexus::StateFromFeedback() const { | 461 InlineCacheState LoadGlobalICNexus::StateFromFeedback() const { | 
| 463   Isolate* isolate = GetIsolate(); | 462   Isolate* isolate = GetIsolate(); | 
| 464   Object* feedback = GetFeedback(); | 463   Object* feedback = GetFeedback(); | 
| 465 | 464 | 
| 466   if (FLAG_new_load_global_ic) { | 465   Object* extra = GetFeedbackExtra(); | 
| 467     Object* extra = GetFeedbackExtra(); | 466   if (!WeakCell::cast(feedback)->cleared() || | 
| 468     if (!WeakCell::cast(feedback)->cleared() || | 467       extra != *TypeFeedbackVector::UninitializedSentinel(isolate)) { | 
| 469         extra != *TypeFeedbackVector::UninitializedSentinel(isolate)) { | 468     return MONOMORPHIC; | 
| 470       return MONOMORPHIC; |  | 
| 471     } |  | 
| 472 |  | 
| 473   } else { |  | 
| 474     if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) { |  | 
| 475       return UNINITIALIZED; |  | 
| 476     } else if (feedback == *TypeFeedbackVector::MegamorphicSentinel(isolate)) { |  | 
| 477       return MEGAMORPHIC; |  | 
| 478     } else if (feedback == |  | 
| 479                *TypeFeedbackVector::PremonomorphicSentinel(isolate)) { |  | 
| 480       return PREMONOMORPHIC; |  | 
| 481     } else if (feedback->IsFixedArray()) { |  | 
| 482       // Determine state purely by our structure, don't check if the maps are |  | 
| 483       // cleared. |  | 
| 484       return POLYMORPHIC; |  | 
| 485     } else if (feedback->IsWeakCell()) { |  | 
| 486       // Don't check if the map is cleared. |  | 
| 487       return MONOMORPHIC; |  | 
| 488     } |  | 
| 489   } | 469   } | 
| 490   return UNINITIALIZED; | 470   return UNINITIALIZED; | 
| 491 } | 471 } | 
| 492 | 472 | 
| 493 InlineCacheState KeyedLoadICNexus::StateFromFeedback() const { | 473 InlineCacheState KeyedLoadICNexus::StateFromFeedback() const { | 
| 494   Isolate* isolate = GetIsolate(); | 474   Isolate* isolate = GetIsolate(); | 
| 495   Object* feedback = GetFeedback(); | 475   Object* feedback = GetFeedback(); | 
| 496 | 476 | 
| 497   if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) { | 477   if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) { | 
| 498     return UNINITIALIZED; | 478     return UNINITIALIZED; | 
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 628 } | 608 } | 
| 629 | 609 | 
| 630 | 610 | 
| 631 void LoadICNexus::ConfigureMonomorphic(Handle<Map> receiver_map, | 611 void LoadICNexus::ConfigureMonomorphic(Handle<Map> receiver_map, | 
| 632                                        Handle<Code> handler) { | 612                                        Handle<Code> handler) { | 
| 633   Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 613   Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 
| 634   SetFeedback(*cell); | 614   SetFeedback(*cell); | 
| 635   SetFeedbackExtra(*handler); | 615   SetFeedbackExtra(*handler); | 
| 636 } | 616 } | 
| 637 | 617 | 
| 638 void LoadGlobalICNexus::ConfigureMonomorphic(Handle<Map> receiver_map, |  | 
| 639                                              Handle<Code> handler) { |  | 
| 640   Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |  | 
| 641   SetFeedback(*cell); |  | 
| 642   SetFeedbackExtra(*handler); |  | 
| 643 } |  | 
| 644 |  | 
| 645 void LoadGlobalICNexus::ConfigureUninitialized() { | 618 void LoadGlobalICNexus::ConfigureUninitialized() { | 
| 646   Isolate* isolate = GetIsolate(); | 619   Isolate* isolate = GetIsolate(); | 
| 647   SetFeedback(isolate->heap()->empty_weak_cell(), SKIP_WRITE_BARRIER); | 620   SetFeedback(isolate->heap()->empty_weak_cell(), SKIP_WRITE_BARRIER); | 
| 648   SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(isolate), | 621   SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(isolate), | 
| 649                    SKIP_WRITE_BARRIER); | 622                    SKIP_WRITE_BARRIER); | 
| 650 } | 623 } | 
| 651 | 624 | 
| 652 void LoadGlobalICNexus::ConfigurePropertyCellMode(Handle<PropertyCell> cell) { | 625 void LoadGlobalICNexus::ConfigurePropertyCellMode(Handle<PropertyCell> cell) { | 
| 653   Isolate* isolate = GetIsolate(); | 626   Isolate* isolate = GetIsolate(); | 
| 654   SetFeedback(*isolate->factory()->NewWeakCell(cell)); | 627   SetFeedback(*isolate->factory()->NewWeakCell(cell)); | 
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 979 | 952 | 
| 980 IcCheckType KeyedStoreICNexus::GetKeyType() const { | 953 IcCheckType KeyedStoreICNexus::GetKeyType() const { | 
| 981   Object* feedback = GetFeedback(); | 954   Object* feedback = GetFeedback(); | 
| 982   if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) { | 955   if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) { | 
| 983     return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value()); | 956     return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value()); | 
| 984   } | 957   } | 
| 985   return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT; | 958   return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT; | 
| 986 } | 959 } | 
| 987 }  // namespace internal | 960 }  // namespace internal | 
| 988 }  // namespace v8 | 961 }  // namespace v8 | 
| OLD | NEW | 
|---|