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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 SetFeedback(*cell); | 639 SetFeedback(*cell); |
640 SetFeedbackExtra(*handler); | 640 SetFeedbackExtra(*handler); |
641 } else { | 641 } else { |
642 Handle<FixedArray> array = EnsureExtraArrayOfSize(2); | 642 Handle<FixedArray> array = EnsureExtraArrayOfSize(2); |
643 SetFeedback(*name); | 643 SetFeedback(*name); |
644 array->set(0, *cell); | 644 array->set(0, *cell); |
645 array->set(1, *handler); | 645 array->set(1, *handler); |
646 } | 646 } |
647 } | 647 } |
648 | 648 |
649 void FeedbackNexus::ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, | 649 void FeedbackNexus::ConfigurePolymorphic(Handle<Name> name, |
| 650 MapHandles const& maps, |
650 List<Handle<Object>>* handlers) { | 651 List<Handle<Object>>* handlers) { |
651 int receiver_count = maps->length(); | 652 int receiver_count = static_cast<int>(maps.size()); |
652 DCHECK(receiver_count > 1); | 653 DCHECK(receiver_count > 1); |
653 Handle<FixedArray> array; | 654 Handle<FixedArray> array; |
654 if (name.is_null()) { | 655 if (name.is_null()) { |
655 array = EnsureArrayOfSize(receiver_count * 2); | 656 array = EnsureArrayOfSize(receiver_count * 2); |
656 SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()), | 657 SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()), |
657 SKIP_WRITE_BARRIER); | 658 SKIP_WRITE_BARRIER); |
658 } else { | 659 } else { |
659 array = EnsureExtraArrayOfSize(receiver_count * 2); | 660 array = EnsureExtraArrayOfSize(receiver_count * 2); |
660 SetFeedback(*name); | 661 SetFeedback(*name); |
661 } | 662 } |
662 | 663 |
663 for (int current = 0; current < receiver_count; ++current) { | 664 for (int current = 0; current < receiver_count; ++current) { |
664 Handle<Map> map = maps->at(current); | 665 Handle<Map> map = maps[current]; |
665 Handle<WeakCell> cell = Map::WeakCellForMap(map); | 666 Handle<WeakCell> cell = Map::WeakCellForMap(map); |
666 array->set(current * 2, *cell); | 667 array->set(current * 2, *cell); |
667 array->set(current * 2 + 1, *handlers->at(current)); | 668 array->set(current * 2 + 1, *handlers->at(current)); |
668 } | 669 } |
669 } | 670 } |
670 | 671 |
671 int FeedbackNexus::ExtractMaps(MapHandleList* maps) const { | 672 int FeedbackNexus::ExtractMaps(MapHandles* maps) const { |
672 Isolate* isolate = GetIsolate(); | 673 Isolate* isolate = GetIsolate(); |
673 Object* feedback = GetFeedback(); | 674 Object* feedback = GetFeedback(); |
674 bool is_named_feedback = IsPropertyNameFeedback(feedback); | 675 bool is_named_feedback = IsPropertyNameFeedback(feedback); |
675 if (feedback->IsFixedArray() || is_named_feedback) { | 676 if (feedback->IsFixedArray() || is_named_feedback) { |
676 int found = 0; | 677 int found = 0; |
677 if (is_named_feedback) { | 678 if (is_named_feedback) { |
678 feedback = GetFeedbackExtra(); | 679 feedback = GetFeedbackExtra(); |
679 } | 680 } |
680 FixedArray* array = FixedArray::cast(feedback); | 681 FixedArray* array = FixedArray::cast(feedback); |
681 const int increment = 2; | 682 const int increment = 2; |
682 for (int i = 0; i < array->length(); i += increment) { | 683 for (int i = 0; i < array->length(); i += increment) { |
683 DCHECK(array->get(i)->IsWeakCell()); | 684 DCHECK(array->get(i)->IsWeakCell()); |
684 WeakCell* cell = WeakCell::cast(array->get(i)); | 685 WeakCell* cell = WeakCell::cast(array->get(i)); |
685 if (!cell->cleared()) { | 686 if (!cell->cleared()) { |
686 Map* map = Map::cast(cell->value()); | 687 Map* map = Map::cast(cell->value()); |
687 maps->Add(handle(map, isolate)); | 688 maps->push_back(handle(map, isolate)); |
688 found++; | 689 found++; |
689 } | 690 } |
690 } | 691 } |
691 return found; | 692 return found; |
692 } else if (feedback->IsWeakCell()) { | 693 } else if (feedback->IsWeakCell()) { |
693 WeakCell* cell = WeakCell::cast(feedback); | 694 WeakCell* cell = WeakCell::cast(feedback); |
694 if (!cell->cleared()) { | 695 if (!cell->cleared()) { |
695 Map* map = Map::cast(cell->value()); | 696 Map* map = Map::cast(cell->value()); |
696 maps->Add(handle(map, isolate)); | 697 maps->push_back(handle(map, isolate)); |
697 return 1; | 698 return 1; |
698 } | 699 } |
699 } | 700 } |
700 | 701 |
701 return 0; | 702 return 0; |
702 } | 703 } |
703 | 704 |
704 MaybeHandle<Object> FeedbackNexus::FindHandlerForMap(Handle<Map> map) const { | 705 MaybeHandle<Object> FeedbackNexus::FindHandlerForMap(Handle<Map> map) const { |
705 Object* feedback = GetFeedback(); | 706 Object* feedback = GetFeedback(); |
706 Isolate* isolate = GetIsolate(); | 707 Isolate* isolate = GetIsolate(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 Name* KeyedStoreICNexus::FindFirstName() const { | 785 Name* KeyedStoreICNexus::FindFirstName() const { |
785 Object* feedback = GetFeedback(); | 786 Object* feedback = GetFeedback(); |
786 if (IsPropertyNameFeedback(feedback)) { | 787 if (IsPropertyNameFeedback(feedback)) { |
787 return Name::cast(feedback); | 788 return Name::cast(feedback); |
788 } | 789 } |
789 return NULL; | 790 return NULL; |
790 } | 791 } |
791 | 792 |
792 KeyedAccessStoreMode KeyedStoreICNexus::GetKeyedAccessStoreMode() const { | 793 KeyedAccessStoreMode KeyedStoreICNexus::GetKeyedAccessStoreMode() const { |
793 KeyedAccessStoreMode mode = STANDARD_STORE; | 794 KeyedAccessStoreMode mode = STANDARD_STORE; |
794 MapHandleList maps; | 795 MapHandles maps; |
795 List<Handle<Object>> handlers; | 796 List<Handle<Object>> handlers; |
796 | 797 |
797 if (GetKeyType() == PROPERTY) return mode; | 798 if (GetKeyType() == PROPERTY) return mode; |
798 | 799 |
799 ExtractMaps(&maps); | 800 ExtractMaps(&maps); |
800 FindHandlers(&handlers, maps.length()); | 801 FindHandlers(&handlers, static_cast<int>(maps.size())); |
801 for (int i = 0; i < handlers.length(); i++) { | 802 for (int i = 0; i < handlers.length(); i++) { |
802 // The first handler that isn't the slow handler will have the bits we need. | 803 // The first handler that isn't the slow handler will have the bits we need. |
803 Handle<Object> maybe_code_handler = handlers.at(i); | 804 Handle<Object> maybe_code_handler = handlers.at(i); |
804 Handle<Code> handler; | 805 Handle<Code> handler; |
805 if (maybe_code_handler->IsTuple3()) { | 806 if (maybe_code_handler->IsTuple3()) { |
806 // Elements transition. | 807 // Elements transition. |
807 Handle<Tuple3> data_handler = Handle<Tuple3>::cast(maybe_code_handler); | 808 Handle<Tuple3> data_handler = Handle<Tuple3>::cast(maybe_code_handler); |
808 handler = handle(Code::cast(data_handler->value2())); | 809 handler = handle(Code::cast(data_handler->value2())); |
809 } else if (maybe_code_handler->IsTuple2()) { | 810 } else if (maybe_code_handler->IsTuple2()) { |
810 // Element store with prototype chain check. | 811 // Element store with prototype chain check. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 return *isolate->factory()->NewJSMap(); | 982 return *isolate->factory()->NewJSMap(); |
982 } | 983 } |
983 | 984 |
984 return *ConvertToJSObject( | 985 return *ConvertToJSObject( |
985 isolate, Handle<UnseededNumberDictionary>( | 986 isolate, Handle<UnseededNumberDictionary>( |
986 UnseededNumberDictionary::cast(feedback), isolate)); | 987 UnseededNumberDictionary::cast(feedback), isolate)); |
987 } | 988 } |
988 | 989 |
989 } // namespace internal | 990 } // namespace internal |
990 } // namespace v8 | 991 } // namespace v8 |
OLD | NEW |