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

Side by Side Diff: src/code-stubs.h

Issue 915583002: Massage the CodeStub class hierarchy a bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | src/code-stubs-hydrogen.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_CODE_STUBS_H_ 5 #ifndef V8_CODE_STUBS_H_
6 #define V8_CODE_STUBS_H_ 6 #define V8_CODE_STUBS_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 static void InitializeDescriptor(Isolate* isolate, uint32_t key, 207 static void InitializeDescriptor(Isolate* isolate, uint32_t key,
208 CodeStubDescriptor* desc); 208 CodeStubDescriptor* desc);
209 209
210 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); 210 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key);
211 211
212 // Returns information for computing the number key. 212 // Returns information for computing the number key.
213 virtual Major MajorKey() const = 0; 213 virtual Major MajorKey() const = 0;
214 uint32_t MinorKey() const { return minor_key_; } 214 uint32_t MinorKey() const { return minor_key_; }
215 215
216 // BinaryOpStub needs to override this.
217 virtual Code::Kind GetCodeKind() const;
218
216 virtual InlineCacheState GetICState() const { return UNINITIALIZED; } 219 virtual InlineCacheState GetICState() const { return UNINITIALIZED; }
217 virtual ExtraICState GetExtraICState() const { return kNoExtraICState; } 220 virtual ExtraICState GetExtraICState() const { return kNoExtraICState; }
218 virtual Code::StubType GetStubType() { 221 virtual Code::StubType GetStubType() const { return Code::NORMAL; }
219 return Code::NORMAL;
220 }
221 222
222 friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) { 223 friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) {
223 s.PrintName(os); 224 s.PrintName(os);
224 return os; 225 return os;
225 } 226 }
226 227
227 Isolate* isolate() const { return isolate_; } 228 Isolate* isolate() const { return isolate_; }
228 229
229 protected: 230 protected:
230 CodeStub(uint32_t key, Isolate* isolate) 231 CodeStub(uint32_t key, Isolate* isolate)
(...skipping 23 matching lines...) Expand all
254 // initially generated. 255 // initially generated.
255 void RecordCodeGeneration(Handle<Code> code); 256 void RecordCodeGeneration(Handle<Code> code);
256 257
257 // Finish the code object after it has been generated. 258 // Finish the code object after it has been generated.
258 virtual void FinishCode(Handle<Code> code) { } 259 virtual void FinishCode(Handle<Code> code) { }
259 260
260 // Activate newly generated stub. Is called after 261 // Activate newly generated stub. Is called after
261 // registering stub in the stub cache. 262 // registering stub in the stub cache.
262 virtual void Activate(Code* code) { } 263 virtual void Activate(Code* code) { }
263 264
264 // BinaryOpStub needs to override this.
265 virtual Code::Kind GetCodeKind() const;
266
267 // Add the code to a specialized cache, specific to an individual 265 // Add the code to a specialized cache, specific to an individual
268 // stub type. Please note, this method must add the code object to a 266 // stub type. Please note, this method must add the code object to a
269 // roots object, otherwise we will remove the code during GC. 267 // roots object, otherwise we will remove the code during GC.
270 virtual void AddToSpecialCache(Handle<Code> new_object) { } 268 virtual void AddToSpecialCache(Handle<Code> new_object) { }
271 269
272 // Find code in a specialized cache, work is delegated to the specific stub. 270 // Find code in a specialized cache, work is delegated to the specific stub.
273 virtual bool FindCodeInSpecialCache(Code** code_out) { 271 virtual bool FindCodeInSpecialCache(Code** code_out) {
274 return false; 272 return false;
275 } 273 }
276 274
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 }; 879 };
882 880
883 881
884 // TODO(mvstanton): Translate to hydrogen code stub. 882 // TODO(mvstanton): Translate to hydrogen code stub.
885 class LoadIndexedInterceptorStub : public PlatformCodeStub { 883 class LoadIndexedInterceptorStub : public PlatformCodeStub {
886 public: 884 public:
887 explicit LoadIndexedInterceptorStub(Isolate* isolate) 885 explicit LoadIndexedInterceptorStub(Isolate* isolate)
888 : PlatformCodeStub(isolate) {} 886 : PlatformCodeStub(isolate) {}
889 887
890 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; } 888 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; }
891 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 889 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
892 890
893 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); 891 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
894 DEFINE_PLATFORM_CODE_STUB(LoadIndexedInterceptor, PlatformCodeStub); 892 DEFINE_PLATFORM_CODE_STUB(LoadIndexedInterceptor, PlatformCodeStub);
895 }; 893 };
896 894
897 895
898 class LoadIndexedStringStub : public PlatformCodeStub { 896 class LoadIndexedStringStub : public PlatformCodeStub {
899 public: 897 public:
900 explicit LoadIndexedStringStub(Isolate* isolate) 898 explicit LoadIndexedStringStub(Isolate* isolate)
901 : PlatformCodeStub(isolate) {} 899 : PlatformCodeStub(isolate) {}
902 900
903 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; } 901 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; }
904 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 902 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
905 903
906 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); 904 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
907 DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub); 905 DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub);
908 }; 906 };
909 907
910 908
911 class HandlerStub : public HydrogenCodeStub { 909 class HandlerStub : public HydrogenCodeStub {
912 public: 910 public:
913 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; } 911 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; }
914 ExtraICState GetExtraICState() const OVERRIDE { return kind(); } 912 ExtraICState GetExtraICState() const OVERRIDE { return kind(); }
(...skipping 19 matching lines...) Expand all
934 set_sub_minor_key(LoadFieldByIndexBits::encode(property_index_key)); 932 set_sub_minor_key(LoadFieldByIndexBits::encode(property_index_key));
935 } 933 }
936 934
937 FieldIndex index() const { 935 FieldIndex index() const {
938 int property_index_key = LoadFieldByIndexBits::decode(sub_minor_key()); 936 int property_index_key = LoadFieldByIndexBits::decode(sub_minor_key());
939 return FieldIndex::FromFieldAccessStubKey(property_index_key); 937 return FieldIndex::FromFieldAccessStubKey(property_index_key);
940 } 938 }
941 939
942 protected: 940 protected:
943 Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; } 941 Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; }
944 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 942 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
945 943
946 private: 944 private:
947 class LoadFieldByIndexBits : public BitField<int, 0, 13> {}; 945 class LoadFieldByIndexBits : public BitField<int, 0, 13> {};
948 946
949 DEFINE_HANDLER_CODE_STUB(LoadField, HandlerStub); 947 DEFINE_HANDLER_CODE_STUB(LoadField, HandlerStub);
950 }; 948 };
951 949
952 950
953 class KeyedLoadSloppyArgumentsStub : public HandlerStub { 951 class KeyedLoadSloppyArgumentsStub : public HandlerStub {
954 public: 952 public:
955 explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate) 953 explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate)
956 : HandlerStub(isolate) {} 954 : HandlerStub(isolate) {}
957 955
958 protected: 956 protected:
959 Code::Kind kind() const OVERRIDE { return Code::KEYED_LOAD_IC; } 957 Code::Kind kind() const OVERRIDE { return Code::KEYED_LOAD_IC; }
960 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 958 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
961 959
962 private: 960 private:
963 DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub); 961 DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub);
964 }; 962 };
965 963
966 964
967 class LoadConstantStub : public HandlerStub { 965 class LoadConstantStub : public HandlerStub {
968 public: 966 public:
969 LoadConstantStub(Isolate* isolate, int constant_index) 967 LoadConstantStub(Isolate* isolate, int constant_index)
970 : HandlerStub(isolate) { 968 : HandlerStub(isolate) {
971 set_sub_minor_key(ConstantIndexBits::encode(constant_index)); 969 set_sub_minor_key(ConstantIndexBits::encode(constant_index));
972 } 970 }
973 971
974 int constant_index() const { 972 int constant_index() const {
975 return ConstantIndexBits::decode(sub_minor_key()); 973 return ConstantIndexBits::decode(sub_minor_key());
976 } 974 }
977 975
978 protected: 976 protected:
979 Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; } 977 Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; }
980 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 978 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
981 979
982 private: 980 private:
983 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; 981 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {};
984 982
985 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub); 983 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub);
986 }; 984 };
987 985
988 986
989 class StringLengthStub: public HandlerStub { 987 class StringLengthStub: public HandlerStub {
990 public: 988 public:
991 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {} 989 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {}
992 990
993 protected: 991 protected:
994 Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; } 992 Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; }
995 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 993 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
996 994
997 DEFINE_HANDLER_CODE_STUB(StringLength, HandlerStub); 995 DEFINE_HANDLER_CODE_STUB(StringLength, HandlerStub);
998 }; 996 };
999 997
1000 998
1001 class StoreFieldStub : public HandlerStub { 999 class StoreFieldStub : public HandlerStub {
1002 public: 1000 public:
1003 StoreFieldStub(Isolate* isolate, FieldIndex index, 1001 StoreFieldStub(Isolate* isolate, FieldIndex index,
1004 Representation representation) 1002 Representation representation)
1005 : HandlerStub(isolate) { 1003 : HandlerStub(isolate) {
1006 int property_index_key = index.GetFieldAccessStubKey(); 1004 int property_index_key = index.GetFieldAccessStubKey();
1007 uint8_t repr = PropertyDetails::EncodeRepresentation(representation); 1005 uint8_t repr = PropertyDetails::EncodeRepresentation(representation);
1008 set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) | 1006 set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) |
1009 RepresentationBits::encode(repr)); 1007 RepresentationBits::encode(repr));
1010 } 1008 }
1011 1009
1012 FieldIndex index() const { 1010 FieldIndex index() const {
1013 int property_index_key = StoreFieldByIndexBits::decode(sub_minor_key()); 1011 int property_index_key = StoreFieldByIndexBits::decode(sub_minor_key());
1014 return FieldIndex::FromFieldAccessStubKey(property_index_key); 1012 return FieldIndex::FromFieldAccessStubKey(property_index_key);
1015 } 1013 }
1016 1014
1017 Representation representation() { 1015 Representation representation() {
1018 uint8_t repr = RepresentationBits::decode(sub_minor_key()); 1016 uint8_t repr = RepresentationBits::decode(sub_minor_key());
1019 return PropertyDetails::DecodeRepresentation(repr); 1017 return PropertyDetails::DecodeRepresentation(repr);
1020 } 1018 }
1021 1019
1022 protected: 1020 protected:
1023 Code::Kind kind() const OVERRIDE { return Code::STORE_IC; } 1021 Code::Kind kind() const OVERRIDE { return Code::STORE_IC; }
1024 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 1022 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
1025 1023
1026 private: 1024 private:
1027 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; 1025 class StoreFieldByIndexBits : public BitField<int, 0, 13> {};
1028 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; 1026 class RepresentationBits : public BitField<uint8_t, 13, 4> {};
1029 1027
1030 DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub); 1028 DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub);
1031 }; 1029 };
1032 1030
1033 1031
1034 class StoreTransitionStub : public HandlerStub { 1032 class StoreTransitionStub : public HandlerStub {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 } 1065 }
1068 1066
1069 StoreMode store_mode() const { 1067 StoreMode store_mode() const {
1070 return StoreModeBits::decode(sub_minor_key()); 1068 return StoreModeBits::decode(sub_minor_key());
1071 } 1069 }
1072 1070
1073 CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE; 1071 CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE;
1074 1072
1075 protected: 1073 protected:
1076 Code::Kind kind() const OVERRIDE { return Code::STORE_IC; } 1074 Code::Kind kind() const OVERRIDE { return Code::STORE_IC; }
1077 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 1075 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
1078 1076
1079 private: 1077 private:
1080 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; 1078 class StoreFieldByIndexBits : public BitField<int, 0, 13> {};
1081 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; 1079 class RepresentationBits : public BitField<uint8_t, 13, 4> {};
1082 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; 1080 class StoreModeBits : public BitField<StoreMode, 17, 2> {};
1083 1081
1084 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); 1082 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub);
1085 }; 1083 };
1086 1084
1087 1085
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 SlotIndexBits::is_valid(lookup_result->slot_index); 2110 SlotIndexBits::is_valid(lookup_result->slot_index);
2113 } 2111 }
2114 2112
2115 private: 2113 private:
2116 static const int kContextIndexBits = 13; 2114 static const int kContextIndexBits = 13;
2117 static const int kSlotIndexBits = 13; 2115 static const int kSlotIndexBits = 13;
2118 class ContextIndexBits : public BitField<int, 0, kContextIndexBits> {}; 2116 class ContextIndexBits : public BitField<int, 0, kContextIndexBits> {};
2119 class SlotIndexBits 2117 class SlotIndexBits
2120 : public BitField<int, kContextIndexBits, kSlotIndexBits> {}; 2118 : public BitField<int, kContextIndexBits, kSlotIndexBits> {};
2121 2119
2122 Code::StubType GetStubType() OVERRIDE { return Code::FAST; } 2120 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }
2123 2121
2124 DEFINE_CODE_STUB_BASE(ScriptContextFieldStub, HandlerStub); 2122 DEFINE_CODE_STUB_BASE(ScriptContextFieldStub, HandlerStub);
2125 }; 2123 };
2126 2124
2127 2125
2128 class LoadScriptContextFieldStub : public ScriptContextFieldStub { 2126 class LoadScriptContextFieldStub : public ScriptContextFieldStub {
2129 public: 2127 public:
2130 LoadScriptContextFieldStub( 2128 LoadScriptContextFieldStub(
2131 Isolate* isolate, const ScriptContextTable::LookupResult* lookup_result) 2129 Isolate* isolate, const ScriptContextTable::LookupResult* lookup_result)
2132 : ScriptContextFieldStub(isolate, lookup_result) {} 2130 : ScriptContextFieldStub(isolate, lookup_result) {}
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 2677
2680 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR 2678 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR
2681 #undef DEFINE_PLATFORM_CODE_STUB 2679 #undef DEFINE_PLATFORM_CODE_STUB
2682 #undef DEFINE_HANDLER_CODE_STUB 2680 #undef DEFINE_HANDLER_CODE_STUB
2683 #undef DEFINE_HYDROGEN_CODE_STUB 2681 #undef DEFINE_HYDROGEN_CODE_STUB
2684 #undef DEFINE_CODE_STUB 2682 #undef DEFINE_CODE_STUB
2685 #undef DEFINE_CODE_STUB_BASE 2683 #undef DEFINE_CODE_STUB_BASE
2686 } } // namespace v8::internal 2684 } } // namespace v8::internal
2687 2685
2688 #endif // V8_CODE_STUBS_H_ 2686 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « no previous file | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698