Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: src/type-feedback-vector.cc

Issue 2412043003: [ic] Support non-code handlers in megamorphic stub cache. (Closed)
Patch Set: Addressing comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ic/stub-cache.cc ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-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"
11 #include "src/type-feedback-vector-inl.h" 11 #include "src/type-feedback-vector-inl.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 16
17 static bool IsPropertyNameFeedback(Object* feedback) { 17 static bool IsPropertyNameFeedback(Object* feedback) {
18 if (feedback->IsString()) return true; 18 if (feedback->IsString()) return true;
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 int GetStepSize(FixedArray* array, Isolate* isolate) { 844 int GetStepSize(FixedArray* array, Isolate* isolate) {
845 // The array should be of the form 845 // The array should be of the form
846 // [map, handler, map, handler, ...] 846 // [map, handler, map, handler, ...]
847 // or 847 // or
848 // [map, map, handler, map, map, handler, ...] 848 // [map, map, handler, map, map, handler, ...]
849 // where "map" is either a WeakCell or |undefined|, 849 // where "map" is either a WeakCell or |undefined|,
850 // and "handler" is either a Code object or a Smi. 850 // and "handler" is either a Code object or a Smi.
851 DCHECK(array->length() >= 2); 851 DCHECK(array->length() >= 2);
852 Object* second = array->get(1); 852 Object* second = array->get(1);
853 if (second->IsWeakCell() || second->IsUndefined(isolate)) return 3; 853 if (second->IsWeakCell() || second->IsUndefined(isolate)) return 3;
854 DCHECK(second->IsCode() || second->IsSmi()); 854 DCHECK(IC::IsHandler(second));
855 return 2; 855 return 2;
856 } 856 }
857 857
858 #ifdef DEBUG // Only used by DCHECKs below.
859 bool IsHandler(Object* object) {
860 return object->IsSmi() ||
861 (object->IsCode() && Code::cast(object)->is_handler());
862 }
863 #endif
864
865 } // namespace 858 } // namespace
866 859
867 int FeedbackNexus::ExtractMaps(MapHandleList* maps) const { 860 int FeedbackNexus::ExtractMaps(MapHandleList* maps) const {
868 Isolate* isolate = GetIsolate(); 861 Isolate* isolate = GetIsolate();
869 Object* feedback = GetFeedback(); 862 Object* feedback = GetFeedback();
870 bool is_named_feedback = IsPropertyNameFeedback(feedback); 863 bool is_named_feedback = IsPropertyNameFeedback(feedback);
871 if (feedback->IsFixedArray() || is_named_feedback) { 864 if (feedback->IsFixedArray() || is_named_feedback) {
872 int found = 0; 865 int found = 0;
873 if (is_named_feedback) { 866 if (is_named_feedback) {
874 feedback = GetFeedbackExtra(); 867 feedback = GetFeedbackExtra();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 900 }
908 FixedArray* array = FixedArray::cast(feedback); 901 FixedArray* array = FixedArray::cast(feedback);
909 int increment = GetStepSize(array, isolate); 902 int increment = GetStepSize(array, isolate);
910 for (int i = 0; i < array->length(); i += increment) { 903 for (int i = 0; i < array->length(); i += increment) {
911 DCHECK(array->get(i)->IsWeakCell()); 904 DCHECK(array->get(i)->IsWeakCell());
912 WeakCell* cell = WeakCell::cast(array->get(i)); 905 WeakCell* cell = WeakCell::cast(array->get(i));
913 if (!cell->cleared()) { 906 if (!cell->cleared()) {
914 Map* array_map = Map::cast(cell->value()); 907 Map* array_map = Map::cast(cell->value());
915 if (array_map == *map) { 908 if (array_map == *map) {
916 Object* code = array->get(i + increment - 1); 909 Object* code = array->get(i + increment - 1);
917 DCHECK(IsHandler(code)); 910 DCHECK(IC::IsHandler(code));
918 return handle(code, isolate); 911 return handle(code, isolate);
919 } 912 }
920 } 913 }
921 } 914 }
922 } else if (feedback->IsWeakCell()) { 915 } else if (feedback->IsWeakCell()) {
923 WeakCell* cell = WeakCell::cast(feedback); 916 WeakCell* cell = WeakCell::cast(feedback);
924 if (!cell->cleared()) { 917 if (!cell->cleared()) {
925 Map* cell_map = Map::cast(cell->value()); 918 Map* cell_map = Map::cast(cell->value());
926 if (cell_map == *map) { 919 if (cell_map == *map) {
927 Object* code = GetFeedbackExtra(); 920 Object* code = GetFeedbackExtra();
928 DCHECK(IsHandler(code)); 921 DCHECK(IC::IsHandler(code));
929 return handle(code, isolate); 922 return handle(code, isolate);
930 } 923 }
931 } 924 }
932 } 925 }
933 926
934 return MaybeHandle<Code>(); 927 return MaybeHandle<Code>();
935 } 928 }
936 929
937 bool FeedbackNexus::FindHandlers(List<Handle<Object>>* code_list, 930 bool FeedbackNexus::FindHandlers(List<Handle<Object>>* code_list,
938 int length) const { 931 int length) const {
939 Object* feedback = GetFeedback(); 932 Object* feedback = GetFeedback();
940 Isolate* isolate = GetIsolate(); 933 Isolate* isolate = GetIsolate();
941 int count = 0; 934 int count = 0;
942 bool is_named_feedback = IsPropertyNameFeedback(feedback); 935 bool is_named_feedback = IsPropertyNameFeedback(feedback);
943 if (feedback->IsFixedArray() || is_named_feedback) { 936 if (feedback->IsFixedArray() || is_named_feedback) {
944 if (is_named_feedback) { 937 if (is_named_feedback) {
945 feedback = GetFeedbackExtra(); 938 feedback = GetFeedbackExtra();
946 } 939 }
947 FixedArray* array = FixedArray::cast(feedback); 940 FixedArray* array = FixedArray::cast(feedback);
948 int increment = GetStepSize(array, isolate); 941 int increment = GetStepSize(array, isolate);
949 for (int i = 0; i < array->length(); i += increment) { 942 for (int i = 0; i < array->length(); i += increment) {
950 DCHECK(array->get(i)->IsWeakCell()); 943 DCHECK(array->get(i)->IsWeakCell());
951 WeakCell* cell = WeakCell::cast(array->get(i)); 944 WeakCell* cell = WeakCell::cast(array->get(i));
952 // Be sure to skip handlers whose maps have been cleared. 945 // Be sure to skip handlers whose maps have been cleared.
953 if (!cell->cleared()) { 946 if (!cell->cleared()) {
954 Object* code = array->get(i + increment - 1); 947 Object* code = array->get(i + increment - 1);
955 DCHECK(IsHandler(code)); 948 DCHECK(IC::IsHandler(code));
956 code_list->Add(handle(code, isolate)); 949 code_list->Add(handle(code, isolate));
957 count++; 950 count++;
958 } 951 }
959 } 952 }
960 } else if (feedback->IsWeakCell()) { 953 } else if (feedback->IsWeakCell()) {
961 WeakCell* cell = WeakCell::cast(feedback); 954 WeakCell* cell = WeakCell::cast(feedback);
962 if (!cell->cleared()) { 955 if (!cell->cleared()) {
963 Object* code = GetFeedbackExtra(); 956 Object* code = GetFeedbackExtra();
964 DCHECK(IsHandler(code)); 957 DCHECK(IC::IsHandler(code));
965 code_list->Add(handle(code, isolate)); 958 code_list->Add(handle(code, isolate));
966 count++; 959 count++;
967 } 960 }
968 } 961 }
969 return count == length; 962 return count == length;
970 } 963 }
971 964
972 965
973 void LoadICNexus::Clear(Code* host) { LoadIC::Clear(GetIsolate(), host, this); } 966 void LoadICNexus::Clear(Code* host) { LoadIC::Clear(GetIsolate(), host, this); }
974 967
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 return BinaryOperationHintFromFeedback(feedback); 1073 return BinaryOperationHintFromFeedback(feedback);
1081 } 1074 }
1082 1075
1083 CompareOperationHint CompareICNexus::GetCompareOperationFeedback() const { 1076 CompareOperationHint CompareICNexus::GetCompareOperationFeedback() const {
1084 int feedback = Smi::cast(GetFeedback())->value(); 1077 int feedback = Smi::cast(GetFeedback())->value();
1085 return CompareOperationHintFromFeedback(feedback); 1078 return CompareOperationHintFromFeedback(feedback);
1086 } 1079 }
1087 1080
1088 } // namespace internal 1081 } // namespace internal
1089 } // namespace v8 1082 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/stub-cache.cc ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698