Chromium Code Reviews

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

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

Powered by Google App Engine