| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "globals.h" | 34 #include "globals.h" |
| 35 #include "macro-assembler.h" | 35 #include "macro-assembler.h" |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 // List of code stubs used on all platforms. | 40 // List of code stubs used on all platforms. |
| 41 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 41 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 42 V(CallFunction) \ | 42 V(CallFunction) \ |
| 43 V(CallConstruct) \ | 43 V(CallConstruct) \ |
| 44 V(BinaryOp) \ | 44 V(BinaryOpIC) \ |
| 45 V(StringAdd) \ | 45 V(StringAdd) \ |
| 46 V(NewStringAdd) \ | 46 V(NewStringAdd) \ |
| 47 V(SubString) \ | 47 V(SubString) \ |
| 48 V(StringCompare) \ | 48 V(StringCompare) \ |
| 49 V(Compare) \ | 49 V(Compare) \ |
| 50 V(CompareIC) \ | 50 V(CompareIC) \ |
| 51 V(CompareNilIC) \ | 51 V(CompareNilIC) \ |
| 52 V(MathPow) \ | 52 V(MathPow) \ |
| 53 V(StringLength) \ | 53 V(StringLength) \ |
| 54 V(FunctionPrototype) \ | 54 V(FunctionPrototype) \ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 #else | 119 #else |
| 120 #define CODE_STUB_LIST_MIPS(V) | 120 #define CODE_STUB_LIST_MIPS(V) |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 // Combined list of code stubs. | 123 // Combined list of code stubs. |
| 124 #define CODE_STUB_LIST(V) \ | 124 #define CODE_STUB_LIST(V) \ |
| 125 CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 125 CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 126 CODE_STUB_LIST_ARM(V) \ | 126 CODE_STUB_LIST_ARM(V) \ |
| 127 CODE_STUB_LIST_MIPS(V) | 127 CODE_STUB_LIST_MIPS(V) |
| 128 | 128 |
| 129 // Mode to overwrite BinaryExpression values. | |
| 130 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; | |
| 131 | |
| 132 // Stub is base classes of all stubs. | 129 // Stub is base classes of all stubs. |
| 133 class CodeStub BASE_EMBEDDED { | 130 class CodeStub BASE_EMBEDDED { |
| 134 public: | 131 public: |
| 135 enum Major { | 132 enum Major { |
| 136 #define DEF_ENUM(name) name, | 133 #define DEF_ENUM(name) name, |
| 137 CODE_STUB_LIST(DEF_ENUM) | 134 CODE_STUB_LIST(DEF_ENUM) |
| 138 #undef DEF_ENUM | 135 #undef DEF_ENUM |
| 139 NoCache, // marker for stubs that do custom caching | 136 NoCache, // marker for stubs that do custom caching |
| 140 NUMBER_OF_IDS | 137 NUMBER_OF_IDS |
| 141 }; | 138 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 154 | 151 |
| 155 // Gets the major key from a code object that is a code stub or binary op IC. | 152 // Gets the major key from a code object that is a code stub or binary op IC. |
| 156 static Major GetMajorKey(Code* code_stub) { | 153 static Major GetMajorKey(Code* code_stub) { |
| 157 return static_cast<Major>(code_stub->major_key()); | 154 return static_cast<Major>(code_stub->major_key()); |
| 158 } | 155 } |
| 159 | 156 |
| 160 static const char* MajorName(Major major_key, bool allow_unknown_keys); | 157 static const char* MajorName(Major major_key, bool allow_unknown_keys); |
| 161 | 158 |
| 162 virtual ~CodeStub() {} | 159 virtual ~CodeStub() {} |
| 163 | 160 |
| 164 bool CompilingCallsToThisStubIsGCSafe(Isolate* isolate) { | |
| 165 bool is_pregenerated = IsPregenerated(isolate); | |
| 166 Code* code = NULL; | |
| 167 CHECK(!is_pregenerated || FindCodeInCache(&code, isolate)); | |
| 168 return is_pregenerated; | |
| 169 } | |
| 170 | |
| 171 // See comment above, where Instanceof is defined. | |
| 172 virtual bool IsPregenerated(Isolate* isolate) { return false; } | |
| 173 | |
| 174 static void GenerateStubsAheadOfTime(Isolate* isolate); | 161 static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 175 static void GenerateStubsRequiringBuiltinsAheadOfTime(Isolate* isolate); | 162 static void GenerateStubsRequiringBuiltinsAheadOfTime(Isolate* isolate); |
| 176 static void GenerateFPStubs(Isolate* isolate); | 163 static void GenerateFPStubs(Isolate* isolate); |
| 177 | 164 |
| 178 // Some stubs put untagged junk on the stack that cannot be scanned by the | 165 // Some stubs put untagged junk on the stack that cannot be scanned by the |
| 179 // GC. This means that we must be statically sure that no GC can occur while | 166 // GC. This means that we must be statically sure that no GC can occur while |
| 180 // they are running. If that is the case they should override this to return | 167 // they are running. If that is the case they should override this to return |
| 181 // true, which will cause an assertion if we try to call something that can | 168 // true, which will cause an assertion if we try to call something that can |
| 182 // GC or if we try to put a stack frame on top of the junk, which would not | 169 // GC or if we try to put a stack frame on top of the junk, which would not |
| 183 // result in a traversable stack. | 170 // result in a traversable stack. |
| 184 virtual bool SometimesSetsUpAFrame() { return true; } | 171 virtual bool SometimesSetsUpAFrame() { return true; } |
| 185 | 172 |
| 186 // Lookup the code in the (possibly custom) cache. | 173 // Lookup the code in the (possibly custom) cache. |
| 187 bool FindCodeInCache(Code** code_out, Isolate* isolate); | 174 bool FindCodeInCache(Code** code_out, Isolate* isolate); |
| 188 | 175 |
| 189 // Returns information for computing the number key. | 176 // Returns information for computing the number key. |
| 190 virtual Major MajorKey() = 0; | 177 virtual Major MajorKey() = 0; |
| 191 virtual int MinorKey() = 0; | 178 virtual int MinorKey() = 0; |
| 192 | 179 |
| 193 virtual InlineCacheState GetICState() { | 180 virtual InlineCacheState GetICState() { |
| 194 return UNINITIALIZED; | 181 return UNINITIALIZED; |
| 195 } | 182 } |
| 196 virtual Code::ExtraICState GetExtraICState() { | 183 virtual ExtraICState GetExtraICState() { |
| 197 return Code::kNoExtraICState; | 184 return kNoExtraICState; |
| 198 } | 185 } |
| 199 virtual Code::StubType GetStubType() { | 186 virtual Code::StubType GetStubType() { |
| 200 return Code::NORMAL; | 187 return Code::NORMAL; |
| 201 } | 188 } |
| 202 virtual int GetStubFlags() { | 189 virtual int GetStubFlags() { |
| 203 return -1; | 190 return -1; |
| 204 } | 191 } |
| 205 | 192 |
| 206 virtual void PrintName(StringStream* stream); | 193 virtual void PrintName(StringStream* stream); |
| 207 | 194 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // If a stub uses a special cache override this. | 238 // If a stub uses a special cache override this. |
| 252 virtual bool UseSpecialCache() { return false; } | 239 virtual bool UseSpecialCache() { return false; } |
| 253 | 240 |
| 254 // Computes the key based on major and minor. | 241 // Computes the key based on major and minor. |
| 255 uint32_t GetKey() { | 242 uint32_t GetKey() { |
| 256 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); | 243 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
| 257 return MinorKeyBits::encode(MinorKey()) | | 244 return MinorKeyBits::encode(MinorKey()) | |
| 258 MajorKeyBits::encode(MajorKey()); | 245 MajorKeyBits::encode(MajorKey()); |
| 259 } | 246 } |
| 260 | 247 |
| 248 STATIC_ASSERT(NUMBER_OF_IDS < (1 << kStubMajorKeyBits)); |
| 261 class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {}; | 249 class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {}; |
| 262 class MinorKeyBits: public BitField<uint32_t, | 250 class MinorKeyBits: public BitField<uint32_t, |
| 263 kStubMajorKeyBits, kStubMinorKeyBits> {}; // NOLINT | 251 kStubMajorKeyBits, kStubMinorKeyBits> {}; // NOLINT |
| 264 | 252 |
| 265 friend class BreakPointIterator; | 253 friend class BreakPointIterator; |
| 266 }; | 254 }; |
| 267 | 255 |
| 268 | 256 |
| 269 class PlatformCodeStub : public CodeStub { | 257 class PlatformCodeStub : public CodeStub { |
| 270 public: | 258 public: |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 DISALLOW_COPY_AND_ASSIGN(FastCloneShallowObjectStub); | 664 DISALLOW_COPY_AND_ASSIGN(FastCloneShallowObjectStub); |
| 677 }; | 665 }; |
| 678 | 666 |
| 679 | 667 |
| 680 class CreateAllocationSiteStub : public HydrogenCodeStub { | 668 class CreateAllocationSiteStub : public HydrogenCodeStub { |
| 681 public: | 669 public: |
| 682 explicit CreateAllocationSiteStub() { } | 670 explicit CreateAllocationSiteStub() { } |
| 683 | 671 |
| 684 virtual Handle<Code> GenerateCode(Isolate* isolate); | 672 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 685 | 673 |
| 686 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
| 687 | |
| 688 static void GenerateAheadOfTime(Isolate* isolate); | 674 static void GenerateAheadOfTime(Isolate* isolate); |
| 689 | 675 |
| 690 virtual void InitializeInterfaceDescriptor( | 676 virtual void InitializeInterfaceDescriptor( |
| 691 Isolate* isolate, | 677 Isolate* isolate, |
| 692 CodeStubInterfaceDescriptor* descriptor); | 678 CodeStubInterfaceDescriptor* descriptor); |
| 693 | 679 |
| 694 private: | 680 private: |
| 695 Major MajorKey() { return CreateAllocationSite; } | 681 Major MajorKey() { return CreateAllocationSite; } |
| 696 int NotMissMinorKey() { return 0; } | 682 int NotMissMinorKey() { return 0; } |
| 697 | 683 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 virtual CodeStub::Major MajorKey() { return StringLength; } | 825 virtual CodeStub::Major MajorKey() { return StringLength; } |
| 840 }; | 826 }; |
| 841 | 827 |
| 842 | 828 |
| 843 class StoreICStub: public ICStub { | 829 class StoreICStub: public ICStub { |
| 844 public: | 830 public: |
| 845 StoreICStub(Code::Kind kind, StrictModeFlag strict_mode) | 831 StoreICStub(Code::Kind kind, StrictModeFlag strict_mode) |
| 846 : ICStub(kind), strict_mode_(strict_mode) { } | 832 : ICStub(kind), strict_mode_(strict_mode) { } |
| 847 | 833 |
| 848 protected: | 834 protected: |
| 849 virtual Code::ExtraICState GetExtraICState() { | 835 virtual ExtraICState GetExtraICState() { |
| 850 return strict_mode_; | 836 return StoreIC::ComputeExtraICState(strict_mode_); |
| 851 } | 837 } |
| 852 | 838 |
| 853 private: | 839 private: |
| 854 STATIC_ASSERT(KindBits::kSize == 4); | 840 STATIC_ASSERT(KindBits::kSize == 4); |
| 855 class StrictModeBits: public BitField<bool, 4, 1> {}; | 841 class StrictModeBits: public BitField<bool, 4, 1> {}; |
| 856 virtual int MinorKey() { | 842 virtual int MinorKey() { |
| 857 return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_); | 843 return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_); |
| 858 } | 844 } |
| 859 | 845 |
| 860 StrictModeFlag strict_mode_; | 846 StrictModeFlag strict_mode_; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 STATIC_ASSERT(KindBits::kSize == 4); | 937 STATIC_ASSERT(KindBits::kSize == 4); |
| 952 class InobjectBits: public BitField<bool, 4, 1> {}; | 938 class InobjectBits: public BitField<bool, 4, 1> {}; |
| 953 class IndexBits: public BitField<int, 5, 11> {}; | 939 class IndexBits: public BitField<int, 5, 11> {}; |
| 954 class UnboxedDoubleBits: public BitField<bool, 16, 1> {}; | 940 class UnboxedDoubleBits: public BitField<bool, 16, 1> {}; |
| 955 virtual CodeStub::Major MajorKey() { return LoadField; } | 941 virtual CodeStub::Major MajorKey() { return LoadField; } |
| 956 }; | 942 }; |
| 957 | 943 |
| 958 | 944 |
| 959 class StoreGlobalStub : public HandlerStub { | 945 class StoreGlobalStub : public HandlerStub { |
| 960 public: | 946 public: |
| 961 StoreGlobalStub(StrictModeFlag strict_mode, bool is_constant) { | 947 explicit StoreGlobalStub(bool is_constant) { |
| 962 bit_field_ = StrictModeBits::encode(strict_mode) | | 948 bit_field_ = IsConstantBits::encode(is_constant); |
| 963 IsConstantBits::encode(is_constant); | |
| 964 } | 949 } |
| 965 | 950 |
| 966 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, | 951 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, |
| 967 Map* receiver_map, | 952 Map* receiver_map, |
| 968 PropertyCell* cell) { | 953 PropertyCell* cell) { |
| 969 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate); | 954 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate); |
| 970 // Replace the placeholder cell and global object map with the actual global | 955 // Replace the placeholder cell and global object map with the actual global |
| 971 // cell and receiver map. | 956 // cell and receiver map. |
| 972 Map* cell_map = isolate->heap()->global_property_cell_map(); | 957 Map* cell_map = isolate->heap()->global_property_cell_map(); |
| 973 code->ReplaceNthObject(1, cell_map, cell); | 958 code->ReplaceNthObject(1, cell_map, cell); |
| 974 code->ReplaceNthObject(1, isolate->heap()->meta_map(), receiver_map); | 959 code->ReplaceNthObject(1, isolate->heap()->meta_map(), receiver_map); |
| 975 return code; | 960 return code; |
| 976 } | 961 } |
| 977 | 962 |
| 978 virtual Code::Kind kind() const { return Code::STORE_IC; } | 963 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 979 | 964 |
| 980 virtual Handle<Code> GenerateCode(Isolate* isolate); | 965 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 981 | 966 |
| 982 virtual void InitializeInterfaceDescriptor( | 967 virtual void InitializeInterfaceDescriptor( |
| 983 Isolate* isolate, | 968 Isolate* isolate, |
| 984 CodeStubInterfaceDescriptor* descriptor); | 969 CodeStubInterfaceDescriptor* descriptor); |
| 985 | 970 |
| 986 virtual Code::ExtraICState GetExtraICState() { return bit_field_; } | 971 virtual ExtraICState GetExtraICState() { return bit_field_; } |
| 987 | 972 |
| 988 bool is_constant() { | 973 bool is_constant() { |
| 989 return IsConstantBits::decode(bit_field_); | 974 return IsConstantBits::decode(bit_field_); |
| 990 } | 975 } |
| 991 void set_is_constant(bool value) { | 976 void set_is_constant(bool value) { |
| 992 bit_field_ = IsConstantBits::update(bit_field_, value); | 977 bit_field_ = IsConstantBits::update(bit_field_, value); |
| 993 } | 978 } |
| 994 | 979 |
| 995 Representation representation() { | 980 Representation representation() { |
| 996 return Representation::FromKind(RepresentationBits::decode(bit_field_)); | 981 return Representation::FromKind(RepresentationBits::decode(bit_field_)); |
| 997 } | 982 } |
| 998 void set_representation(Representation r) { | 983 void set_representation(Representation r) { |
| 999 bit_field_ = RepresentationBits::update(bit_field_, r.kind()); | 984 bit_field_ = RepresentationBits::update(bit_field_, r.kind()); |
| 1000 } | 985 } |
| 1001 | 986 |
| 1002 private: | 987 private: |
| 1003 virtual int NotMissMinorKey() { return GetExtraICState(); } | 988 virtual int NotMissMinorKey() { return GetExtraICState(); } |
| 1004 Major MajorKey() { return StoreGlobal; } | 989 Major MajorKey() { return StoreGlobal; } |
| 1005 | 990 |
| 1006 class StrictModeBits: public BitField<StrictModeFlag, 0, 1> {}; | 991 class IsConstantBits: public BitField<bool, 0, 1> {}; |
| 1007 class IsConstantBits: public BitField<bool, 1, 1> {}; | 992 class RepresentationBits: public BitField<Representation::Kind, 1, 8> {}; |
| 1008 class RepresentationBits: public BitField<Representation::Kind, 2, 8> {}; | |
| 1009 | 993 |
| 1010 int bit_field_; | 994 int bit_field_; |
| 1011 | 995 |
| 1012 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub); | 996 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub); |
| 1013 }; | 997 }; |
| 1014 | 998 |
| 1015 | 999 |
| 1016 class KeyedLoadFieldStub: public LoadFieldStub { | 1000 class KeyedLoadFieldStub: public LoadFieldStub { |
| 1017 public: | 1001 public: |
| 1018 KeyedLoadFieldStub(bool inobject, int index, Representation representation) | 1002 KeyedLoadFieldStub(bool inobject, int index, Representation representation) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1031 }; | 1015 }; |
| 1032 | 1016 |
| 1033 | 1017 |
| 1034 class KeyedArrayCallStub: public HICStub { | 1018 class KeyedArrayCallStub: public HICStub { |
| 1035 public: | 1019 public: |
| 1036 KeyedArrayCallStub(bool holey, int argc) : HICStub(), argc_(argc) { | 1020 KeyedArrayCallStub(bool holey, int argc) : HICStub(), argc_(argc) { |
| 1037 bit_field_ = ContextualBits::encode(false) | HoleyBits::encode(holey); | 1021 bit_field_ = ContextualBits::encode(false) | HoleyBits::encode(holey); |
| 1038 } | 1022 } |
| 1039 | 1023 |
| 1040 virtual Code::Kind kind() const { return Code::KEYED_CALL_IC; } | 1024 virtual Code::Kind kind() const { return Code::KEYED_CALL_IC; } |
| 1041 virtual Code::ExtraICState GetExtraICState() { return bit_field_; } | 1025 virtual ExtraICState GetExtraICState() { return bit_field_; } |
| 1042 | 1026 |
| 1043 ElementsKind elements_kind() { | 1027 ElementsKind elements_kind() { |
| 1044 return HoleyBits::decode(bit_field_) ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS; | 1028 return HoleyBits::decode(bit_field_) ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS; |
| 1045 } | 1029 } |
| 1046 | 1030 |
| 1047 int argc() { return argc_; } | 1031 int argc() { return argc_; } |
| 1048 virtual int GetStubFlags() { return argc(); } | 1032 virtual int GetStubFlags() { return argc(); } |
| 1049 | 1033 |
| 1050 static bool IsHoley(Handle<Code> code) { | 1034 static bool IsHoley(Handle<Code> code) { |
| 1051 Code::ExtraICState state = code->extra_ic_state(); | 1035 ExtraICState state = code->extra_ic_state(); |
| 1052 return HoleyBits::decode(state); | 1036 return HoleyBits::decode(state); |
| 1053 } | 1037 } |
| 1054 | 1038 |
| 1055 virtual void InitializeInterfaceDescriptor( | 1039 virtual void InitializeInterfaceDescriptor( |
| 1056 Isolate* isolate, | 1040 Isolate* isolate, |
| 1057 CodeStubInterfaceDescriptor* descriptor); | 1041 CodeStubInterfaceDescriptor* descriptor); |
| 1058 | 1042 |
| 1059 virtual Handle<Code> GenerateCode(Isolate* isolate); | 1043 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 1060 | 1044 |
| 1061 private: | 1045 private: |
| 1062 virtual int NotMissMinorKey() { | 1046 virtual int NotMissMinorKey() { |
| 1063 return GetExtraICState() | ArgcBits::encode(argc_); | 1047 return GetExtraICState() | ArgcBits::encode(argc_); |
| 1064 } | 1048 } |
| 1065 | 1049 |
| 1066 class ContextualBits: public BitField<bool, 0, 1> {}; | 1050 class ContextualBits: public BitField<bool, 0, 1> {}; |
| 1067 STATIC_ASSERT(CallICBase::Contextual::kShift == ContextualBits::kShift); | 1051 STATIC_ASSERT(CallICBase::Contextual::kShift == ContextualBits::kShift); |
| 1068 STATIC_ASSERT(CallICBase::Contextual::kSize == ContextualBits::kSize); | 1052 STATIC_ASSERT(CallICBase::Contextual::kSize == ContextualBits::kSize); |
| 1069 class HoleyBits: public BitField<bool, 1, 1> {}; | 1053 class HoleyBits: public BitField<bool, 1, 1> {}; |
| 1070 STATIC_ASSERT(Code::kArgumentsBits <= kStubMinorKeyBits - 2); | 1054 STATIC_ASSERT(Code::kArgumentsBits <= kStubMinorKeyBits - 2); |
| 1071 class ArgcBits: public BitField<int, 2, Code::kArgumentsBits> {}; | 1055 class ArgcBits: public BitField<int, 2, Code::kArgumentsBits> {}; |
| 1072 virtual CodeStub::Major MajorKey() { return KeyedArrayCall; } | 1056 virtual CodeStub::Major MajorKey() { return KeyedArrayCall; } |
| 1073 int bit_field_; | 1057 int bit_field_; |
| 1074 int argc_; | 1058 int argc_; |
| 1075 }; | 1059 }; |
| 1076 | 1060 |
| 1077 | 1061 |
| 1078 class BinaryOpStub: public HydrogenCodeStub { | 1062 class BinaryOpICStub V8_FINAL : public HydrogenCodeStub { |
| 1079 public: | 1063 public: |
| 1080 BinaryOpStub(Token::Value op, OverwriteMode mode) | 1064 BinaryOpICStub(Token::Value op, OverwriteMode mode) |
| 1081 : HydrogenCodeStub(UNINITIALIZED), op_(op), mode_(mode) { | 1065 : HydrogenCodeStub(UNINITIALIZED), state_(op, mode) {} |
| 1082 ASSERT(op <= LAST_TOKEN && op >= FIRST_TOKEN); | 1066 |
| 1083 Initialize(); | 1067 explicit BinaryOpICStub(const BinaryOpIC::State& state) : state_(state) {} |
| 1068 |
| 1069 static void GenerateAheadOfTime(Isolate* isolate); |
| 1070 |
| 1071 virtual void InitializeInterfaceDescriptor( |
| 1072 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1073 |
| 1074 static void InstallDescriptors(Isolate* isolate); |
| 1075 |
| 1076 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { |
| 1077 return Code::BINARY_OP_IC; |
| 1084 } | 1078 } |
| 1085 | 1079 |
| 1086 explicit BinaryOpStub(Code::ExtraICState state) | 1080 virtual InlineCacheState GetICState() V8_OVERRIDE { |
| 1087 : op_(decode_token(OpBits::decode(state))), | 1081 return state_.GetICState(); |
| 1088 mode_(OverwriteModeField::decode(state)), | |
| 1089 fixed_right_arg_( | |
| 1090 Maybe<int>(HasFixedRightArgBits::decode(state), | |
| 1091 decode_arg_value(FixedRightArgValueBits::decode(state)))), | |
| 1092 left_state_(LeftStateField::decode(state)), | |
| 1093 right_state_(fixed_right_arg_.has_value | |
| 1094 ? ((fixed_right_arg_.value <= Smi::kMaxValue) ? SMI : INT32) | |
| 1095 : RightStateField::decode(state)), | |
| 1096 result_state_(ResultStateField::decode(state)) { | |
| 1097 // We don't deserialize the SSE2 Field, since this is only used to be able | |
| 1098 // to include SSE2 as well as non-SSE2 versions in the snapshot. For code | |
| 1099 // generation we always want it to reflect the current state. | |
| 1100 ASSERT(!fixed_right_arg_.has_value || | |
| 1101 can_encode_arg_value(fixed_right_arg_.value)); | |
| 1102 } | 1082 } |
| 1103 | 1083 |
| 1104 static const int FIRST_TOKEN = Token::BIT_OR; | 1084 virtual ExtraICState GetExtraICState() V8_OVERRIDE { |
| 1105 static const int LAST_TOKEN = Token::MOD; | 1085 return state_.GetExtraICState(); |
| 1106 | |
| 1107 static void GenerateAheadOfTime(Isolate* isolate); | |
| 1108 virtual void InitializeInterfaceDescriptor( | |
| 1109 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor); | |
| 1110 static void InitializeForIsolate(Isolate* isolate) { | |
| 1111 BinaryOpStub binopStub(UNINITIALIZED); | |
| 1112 binopStub.InitializeInterfaceDescriptor( | |
| 1113 isolate, isolate->code_stub_interface_descriptor(CodeStub::BinaryOp)); | |
| 1114 } | |
| 1115 | |
| 1116 virtual Code::Kind GetCodeKind() const { return Code::BINARY_OP_IC; } | |
| 1117 virtual InlineCacheState GetICState() { | |
| 1118 if (Max(left_state_, right_state_) == NONE) { | |
| 1119 return ::v8::internal::UNINITIALIZED; | |
| 1120 } | |
| 1121 if (Max(left_state_, right_state_) == GENERIC) return MEGAMORPHIC; | |
| 1122 return MONOMORPHIC; | |
| 1123 } | 1086 } |
| 1124 | 1087 |
| 1125 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { | 1088 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1126 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | 1089 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1127 } | 1090 } |
| 1128 | 1091 |
| 1129 virtual Code::ExtraICState GetExtraICState() { | 1092 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 1130 bool sse_field = Max(result_state_, Max(left_state_, right_state_)) > SMI && | |
| 1131 CpuFeatures::IsSafeForSnapshot(SSE2); | |
| 1132 | 1093 |
| 1133 return OpBits::encode(encode_token(op_)) | 1094 const BinaryOpIC::State& state() const { return state_; } |
| 1134 | LeftStateField::encode(left_state_) | |
| 1135 | RightStateField::encode(fixed_right_arg_.has_value | |
| 1136 ? NONE : right_state_) | |
| 1137 | ResultStateField::encode(result_state_) | |
| 1138 | HasFixedRightArgBits::encode(fixed_right_arg_.has_value) | |
| 1139 | FixedRightArgValueBits::encode(fixed_right_arg_.has_value | |
| 1140 ? encode_arg_value( | |
| 1141 fixed_right_arg_.value) | |
| 1142 : 0) | |
| 1143 | SSE2Field::encode(sse_field) | |
| 1144 | OverwriteModeField::encode(mode_); | |
| 1145 } | |
| 1146 | 1095 |
| 1147 bool CanReuseDoubleBox() { | 1096 virtual void PrintState(StringStream* stream) V8_OVERRIDE; |
| 1148 return result_state_ <= NUMBER && result_state_ > SMI && | |
| 1149 ((left_state_ > SMI && left_state_ <= NUMBER && | |
| 1150 mode_ == OVERWRITE_LEFT) || | |
| 1151 (right_state_ > SMI && right_state_ <= NUMBER && | |
| 1152 mode_ == OVERWRITE_RIGHT)); | |
| 1153 } | |
| 1154 | 1097 |
| 1155 bool HasSideEffects(Isolate* isolate) const { | 1098 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1156 Handle<Type> left = GetLeftType(isolate); | 1099 static const int kLeft = 0; |
| 1157 Handle<Type> right = GetRightType(isolate); | 1100 static const int kRight = 1; |
| 1158 return left->Maybe(Type::Receiver()) || right->Maybe(Type::Receiver()); | |
| 1159 } | |
| 1160 | |
| 1161 virtual Handle<Code> GenerateCode(Isolate* isolate); | |
| 1162 | |
| 1163 Maybe<Handle<Object> > Result(Handle<Object> left, | |
| 1164 Handle<Object> right, | |
| 1165 Isolate* isolate); | |
| 1166 | |
| 1167 Token::Value operation() const { return op_; } | |
| 1168 OverwriteMode mode() const { return mode_; } | |
| 1169 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | |
| 1170 | |
| 1171 Handle<Type> GetLeftType(Isolate* isolate) const; | |
| 1172 Handle<Type> GetRightType(Isolate* isolate) const; | |
| 1173 Handle<Type> GetResultType(Isolate* isolate) const; | |
| 1174 | |
| 1175 void UpdateStatus(Handle<Object> left, | |
| 1176 Handle<Object> right, | |
| 1177 Maybe<Handle<Object> > result); | |
| 1178 | |
| 1179 void PrintState(StringStream* stream); | |
| 1180 | 1101 |
| 1181 private: | 1102 private: |
| 1182 explicit BinaryOpStub(InitializationState state) : HydrogenCodeStub(state), | 1103 static void GenerateAheadOfTime(Isolate* isolate, |
| 1183 op_(Token::ADD), | 1104 const BinaryOpIC::State& state); |
| 1184 mode_(NO_OVERWRITE) { | |
| 1185 Initialize(); | |
| 1186 } | |
| 1187 void Initialize(); | |
| 1188 | 1105 |
| 1189 enum State { NONE, SMI, INT32, NUMBER, STRING, GENERIC }; | 1106 virtual Major MajorKey() V8_OVERRIDE { return BinaryOpIC; } |
| 1107 virtual int NotMissMinorKey() V8_OVERRIDE { return GetExtraICState(); } |
| 1190 | 1108 |
| 1191 // We truncate the last bit of the token. | 1109 BinaryOpIC::State state_; |
| 1192 STATIC_ASSERT(LAST_TOKEN - FIRST_TOKEN < (1 << 5)); | |
| 1193 class LeftStateField: public BitField<State, 0, 3> {}; | |
| 1194 // When fixed right arg is set, we don't need to store the right state. | |
| 1195 // Thus the two fields can overlap. | |
| 1196 class HasFixedRightArgBits: public BitField<bool, 4, 1> {}; | |
| 1197 class FixedRightArgValueBits: public BitField<int, 5, 4> {}; | |
| 1198 class RightStateField: public BitField<State, 5, 3> {}; | |
| 1199 class ResultStateField: public BitField<State, 9, 3> {}; | |
| 1200 class SSE2Field: public BitField<bool, 12, 1> {}; | |
| 1201 class OverwriteModeField: public BitField<OverwriteMode, 13, 2> {}; | |
| 1202 class OpBits: public BitField<int, 15, 5> {}; | |
| 1203 | 1110 |
| 1204 virtual CodeStub::Major MajorKey() { return BinaryOp; } | 1111 DISALLOW_COPY_AND_ASSIGN(BinaryOpICStub); |
| 1205 virtual int NotMissMinorKey() { return GetExtraICState(); } | |
| 1206 | |
| 1207 static Handle<Type> StateToType(State state, | |
| 1208 Isolate* isolate); | |
| 1209 | |
| 1210 static void Generate(Token::Value op, | |
| 1211 State left, | |
| 1212 int right, | |
| 1213 State result, | |
| 1214 OverwriteMode mode, | |
| 1215 Isolate* isolate); | |
| 1216 | |
| 1217 static void Generate(Token::Value op, | |
| 1218 State left, | |
| 1219 State right, | |
| 1220 State result, | |
| 1221 OverwriteMode mode, | |
| 1222 Isolate* isolate); | |
| 1223 | |
| 1224 void UpdateStatus(Handle<Object> object, | |
| 1225 State* state); | |
| 1226 | |
| 1227 bool can_encode_arg_value(int32_t value) const; | |
| 1228 int encode_arg_value(int32_t value) const; | |
| 1229 int32_t decode_arg_value(int value) const; | |
| 1230 int encode_token(Token::Value op) const; | |
| 1231 Token::Value decode_token(int op) const; | |
| 1232 | |
| 1233 bool has_int_result() const { | |
| 1234 return op_ == Token::BIT_XOR || op_ == Token::BIT_AND || | |
| 1235 op_ == Token::BIT_OR || op_ == Token::SAR || op_ == Token::SHL; | |
| 1236 } | |
| 1237 | |
| 1238 const char* StateToName(State state); | |
| 1239 | |
| 1240 void PrintBaseName(StringStream* stream); | |
| 1241 | |
| 1242 Token::Value op_; | |
| 1243 OverwriteMode mode_; | |
| 1244 | |
| 1245 Maybe<int> fixed_right_arg_; | |
| 1246 State left_state_; | |
| 1247 State right_state_; | |
| 1248 State result_state_; | |
| 1249 }; | 1112 }; |
| 1250 | 1113 |
| 1251 | 1114 |
| 1252 // TODO(bmeurer): Rename to StringAddStub once we dropped the old StringAddStub. | 1115 // TODO(bmeurer): Rename to StringAddStub once we dropped the old StringAddStub. |
| 1253 class NewStringAddStub V8_FINAL : public HydrogenCodeStub { | 1116 class NewStringAddStub V8_FINAL : public HydrogenCodeStub { |
| 1254 public: | 1117 public: |
| 1255 NewStringAddStub(StringAddFlags flags, PretenureFlag pretenure_flag) | 1118 NewStringAddStub(StringAddFlags flags, PretenureFlag pretenure_flag) |
| 1256 : bit_field_(StringAddFlagsBits::encode(flags) | | 1119 : bit_field_(StringAddFlagsBits::encode(flags) | |
| 1257 PretenureFlagBits::encode(pretenure_flag)) {} | 1120 PretenureFlagBits::encode(pretenure_flag)) {} |
| 1258 | 1121 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 }; | 1222 }; |
| 1360 | 1223 |
| 1361 | 1224 |
| 1362 class CompareNilICStub : public HydrogenCodeStub { | 1225 class CompareNilICStub : public HydrogenCodeStub { |
| 1363 public: | 1226 public: |
| 1364 Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>()); | 1227 Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>()); |
| 1365 Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map); | 1228 Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map); |
| 1366 | 1229 |
| 1367 explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { } | 1230 explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { } |
| 1368 | 1231 |
| 1369 CompareNilICStub(Code::ExtraICState ic_state, | 1232 CompareNilICStub(ExtraICState ic_state, |
| 1370 InitializationState init_state = INITIALIZED) | 1233 InitializationState init_state = INITIALIZED) |
| 1371 : HydrogenCodeStub(init_state), | 1234 : HydrogenCodeStub(init_state), |
| 1372 nil_value_(NilValueField::decode(ic_state)), | 1235 nil_value_(NilValueField::decode(ic_state)), |
| 1373 state_(State(TypesField::decode(ic_state))) { | 1236 state_(State(TypesField::decode(ic_state))) { |
| 1374 } | 1237 } |
| 1375 | 1238 |
| 1376 static Handle<Code> GetUninitialized(Isolate* isolate, | 1239 static Handle<Code> GetUninitialized(Isolate* isolate, |
| 1377 NilValue nil) { | 1240 NilValue nil) { |
| 1378 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); | 1241 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); |
| 1379 } | 1242 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1396 return MONOMORPHIC; | 1259 return MONOMORPHIC; |
| 1397 } else { | 1260 } else { |
| 1398 return PREMONOMORPHIC; | 1261 return PREMONOMORPHIC; |
| 1399 } | 1262 } |
| 1400 } | 1263 } |
| 1401 | 1264 |
| 1402 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } | 1265 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } |
| 1403 | 1266 |
| 1404 virtual Handle<Code> GenerateCode(Isolate* isolate); | 1267 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 1405 | 1268 |
| 1406 virtual Code::ExtraICState GetExtraICState() { | 1269 virtual ExtraICState GetExtraICState() { |
| 1407 return NilValueField::encode(nil_value_) | | 1270 return NilValueField::encode(nil_value_) | |
| 1408 TypesField::encode(state_.ToIntegral()); | 1271 TypesField::encode(state_.ToIntegral()); |
| 1409 } | 1272 } |
| 1410 | 1273 |
| 1411 void UpdateStatus(Handle<Object> object); | 1274 void UpdateStatus(Handle<Object> object); |
| 1412 | 1275 |
| 1413 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } | 1276 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } |
| 1414 NilValue GetNilValue() const { return nil_value_; } | 1277 NilValue GetNilValue() const { return nil_value_; } |
| 1415 void ClearState() { state_.RemoveAll(); } | 1278 void ClearState() { state_.RemoveAll(); } |
| 1416 | 1279 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 explicit CEntryStub(int result_size, | 1325 explicit CEntryStub(int result_size, |
| 1463 SaveFPRegsMode save_doubles = kDontSaveFPRegs) | 1326 SaveFPRegsMode save_doubles = kDontSaveFPRegs) |
| 1464 : result_size_(result_size), save_doubles_(save_doubles) { } | 1327 : result_size_(result_size), save_doubles_(save_doubles) { } |
| 1465 | 1328 |
| 1466 void Generate(MacroAssembler* masm); | 1329 void Generate(MacroAssembler* masm); |
| 1467 | 1330 |
| 1468 // The version of this stub that doesn't save doubles is generated ahead of | 1331 // The version of this stub that doesn't save doubles is generated ahead of |
| 1469 // time, so it's OK to call it from other stubs that can't cope with GC during | 1332 // time, so it's OK to call it from other stubs that can't cope with GC during |
| 1470 // their code generation. On machines that always have gp registers (x64) we | 1333 // their code generation. On machines that always have gp registers (x64) we |
| 1471 // can generate both variants ahead of time. | 1334 // can generate both variants ahead of time. |
| 1472 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE; | |
| 1473 static void GenerateAheadOfTime(Isolate* isolate); | 1335 static void GenerateAheadOfTime(Isolate* isolate); |
| 1474 | 1336 |
| 1475 protected: | 1337 protected: |
| 1476 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { | 1338 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1477 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | 1339 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1478 }; | 1340 }; |
| 1479 | 1341 |
| 1480 private: | 1342 private: |
| 1481 void GenerateCore(MacroAssembler* masm, | 1343 void GenerateCore(MacroAssembler* masm, |
| 1482 Label* throw_normal_exception, | 1344 Label* throw_normal_exception, |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 } | 1676 } |
| 1815 | 1677 |
| 1816 private: | 1678 private: |
| 1817 StringCharCodeAtGenerator char_code_at_generator_; | 1679 StringCharCodeAtGenerator char_code_at_generator_; |
| 1818 StringCharFromCodeGenerator char_from_code_generator_; | 1680 StringCharFromCodeGenerator char_from_code_generator_; |
| 1819 | 1681 |
| 1820 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); | 1682 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
| 1821 }; | 1683 }; |
| 1822 | 1684 |
| 1823 | 1685 |
| 1824 class AllowStubCallsScope { | |
| 1825 public: | |
| 1826 AllowStubCallsScope(MacroAssembler* masm, bool allow) | |
| 1827 : masm_(masm), previous_allow_(masm->allow_stub_calls()) { | |
| 1828 masm_->set_allow_stub_calls(allow); | |
| 1829 } | |
| 1830 ~AllowStubCallsScope() { | |
| 1831 masm_->set_allow_stub_calls(previous_allow_); | |
| 1832 } | |
| 1833 | |
| 1834 private: | |
| 1835 MacroAssembler* masm_; | |
| 1836 bool previous_allow_; | |
| 1837 | |
| 1838 DISALLOW_COPY_AND_ASSIGN(AllowStubCallsScope); | |
| 1839 }; | |
| 1840 | |
| 1841 | |
| 1842 class KeyedLoadDictionaryElementStub : public HydrogenCodeStub { | 1686 class KeyedLoadDictionaryElementStub : public HydrogenCodeStub { |
| 1843 public: | 1687 public: |
| 1844 KeyedLoadDictionaryElementStub() {} | 1688 KeyedLoadDictionaryElementStub() {} |
| 1845 | 1689 |
| 1846 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; | 1690 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 1847 | 1691 |
| 1848 virtual void InitializeInterfaceDescriptor( | 1692 virtual void InitializeInterfaceDescriptor( |
| 1849 Isolate* isolate, | 1693 Isolate* isolate, |
| 1850 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 1694 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1851 | 1695 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 } | 1923 } |
| 2080 | 1924 |
| 2081 AllocationSiteOverrideMode override_mode() const { | 1925 AllocationSiteOverrideMode override_mode() const { |
| 2082 return AllocationSiteOverrideModeBits::decode(bit_field_); | 1926 return AllocationSiteOverrideModeBits::decode(bit_field_); |
| 2083 } | 1927 } |
| 2084 | 1928 |
| 2085 ContextCheckMode context_mode() const { | 1929 ContextCheckMode context_mode() const { |
| 2086 return ContextCheckModeBits::decode(bit_field_); | 1930 return ContextCheckModeBits::decode(bit_field_); |
| 2087 } | 1931 } |
| 2088 | 1932 |
| 2089 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { | |
| 2090 // We only pre-generate stubs that verify correct context | |
| 2091 return context_mode() == CONTEXT_CHECK_REQUIRED; | |
| 2092 } | |
| 2093 | |
| 2094 static void GenerateStubsAheadOfTime(Isolate* isolate); | 1933 static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2095 static void InstallDescriptors(Isolate* isolate); | 1934 static void InstallDescriptors(Isolate* isolate); |
| 2096 | 1935 |
| 2097 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 1936 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 2098 static const int kConstructor = 0; | 1937 static const int kConstructor = 0; |
| 2099 static const int kPropertyCell = 1; | 1938 static const int kPropertyCell = 1; |
| 2100 | 1939 |
| 2101 private: | 1940 private: |
| 2102 int NotMissMinorKey() { return bit_field_; } | 1941 int NotMissMinorKey() { return bit_field_; } |
| 2103 | 1942 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); | 2019 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); |
| 2181 }; | 2020 }; |
| 2182 | 2021 |
| 2183 | 2022 |
| 2184 class InternalArrayConstructorStubBase : public HydrogenCodeStub { | 2023 class InternalArrayConstructorStubBase : public HydrogenCodeStub { |
| 2185 public: | 2024 public: |
| 2186 explicit InternalArrayConstructorStubBase(ElementsKind kind) { | 2025 explicit InternalArrayConstructorStubBase(ElementsKind kind) { |
| 2187 kind_ = kind; | 2026 kind_ = kind; |
| 2188 } | 2027 } |
| 2189 | 2028 |
| 2190 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
| 2191 static void GenerateStubsAheadOfTime(Isolate* isolate); | 2029 static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2192 static void InstallDescriptors(Isolate* isolate); | 2030 static void InstallDescriptors(Isolate* isolate); |
| 2193 | 2031 |
| 2194 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 2032 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 2195 static const int kConstructor = 0; | 2033 static const int kConstructor = 0; |
| 2196 | 2034 |
| 2197 ElementsKind elements_kind() const { return kind_; } | 2035 ElementsKind elements_kind() const { return kind_; } |
| 2198 | 2036 |
| 2199 private: | 2037 private: |
| 2200 int NotMissMinorKey() { return kind_; } | 2038 int NotMissMinorKey() { return kind_; } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 bool UpdateStatus(Handle<Object> object); | 2163 bool UpdateStatus(Handle<Object> object); |
| 2326 bool NeedsMap() const; | 2164 bool NeedsMap() const; |
| 2327 bool CanBeUndetectable() const; | 2165 bool CanBeUndetectable() const; |
| 2328 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } | 2166 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } |
| 2329 | 2167 |
| 2330 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } | 2168 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
| 2331 }; | 2169 }; |
| 2332 | 2170 |
| 2333 explicit ToBooleanStub(Types types = Types()) | 2171 explicit ToBooleanStub(Types types = Types()) |
| 2334 : types_(types) { } | 2172 : types_(types) { } |
| 2335 explicit ToBooleanStub(Code::ExtraICState state) | 2173 explicit ToBooleanStub(ExtraICState state) |
| 2336 : types_(static_cast<byte>(state)) { } | 2174 : types_(static_cast<byte>(state)) { } |
| 2337 | 2175 |
| 2338 bool UpdateStatus(Handle<Object> object); | 2176 bool UpdateStatus(Handle<Object> object); |
| 2339 Types GetTypes() { return types_; } | 2177 Types GetTypes() { return types_; } |
| 2340 | 2178 |
| 2341 virtual Handle<Code> GenerateCode(Isolate* isolate); | 2179 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 2342 virtual void InitializeInterfaceDescriptor( | 2180 virtual void InitializeInterfaceDescriptor( |
| 2343 Isolate* isolate, | 2181 Isolate* isolate, |
| 2344 CodeStubInterfaceDescriptor* descriptor); | 2182 CodeStubInterfaceDescriptor* descriptor); |
| 2345 | 2183 |
| 2346 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } | 2184 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } |
| 2347 virtual void PrintState(StringStream* stream); | 2185 virtual void PrintState(StringStream* stream); |
| 2348 | 2186 |
| 2349 virtual bool SometimesSetsUpAFrame() { return false; } | 2187 virtual bool SometimesSetsUpAFrame() { return false; } |
| 2350 | 2188 |
| 2351 static void InitializeForIsolate(Isolate* isolate) { | 2189 static void InitializeForIsolate(Isolate* isolate) { |
| 2352 ToBooleanStub stub; | 2190 ToBooleanStub stub; |
| 2353 stub.InitializeInterfaceDescriptor( | 2191 stub.InitializeInterfaceDescriptor( |
| 2354 isolate, | 2192 isolate, |
| 2355 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); | 2193 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); |
| 2356 } | 2194 } |
| 2357 | 2195 |
| 2358 static Handle<Code> GetUninitialized(Isolate* isolate) { | 2196 static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 2359 return ToBooleanStub(UNINITIALIZED).GetCode(isolate); | 2197 return ToBooleanStub(UNINITIALIZED).GetCode(isolate); |
| 2360 } | 2198 } |
| 2361 | 2199 |
| 2362 virtual Code::ExtraICState GetExtraICState() { | 2200 virtual ExtraICState GetExtraICState() { |
| 2363 return types_.ToIntegral(); | 2201 return types_.ToIntegral(); |
| 2364 } | 2202 } |
| 2365 | 2203 |
| 2366 virtual InlineCacheState GetICState() { | 2204 virtual InlineCacheState GetICState() { |
| 2367 if (types_.IsEmpty()) { | 2205 if (types_.IsEmpty()) { |
| 2368 return ::v8::internal::UNINITIALIZED; | 2206 return ::v8::internal::UNINITIALIZED; |
| 2369 } else { | 2207 } else { |
| 2370 return MONOMORPHIC; | 2208 return MONOMORPHIC; |
| 2371 } | 2209 } |
| 2372 } | 2210 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 | 2282 |
| 2445 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); | 2283 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); |
| 2446 }; | 2284 }; |
| 2447 | 2285 |
| 2448 | 2286 |
| 2449 class StubFailureTrampolineStub : public PlatformCodeStub { | 2287 class StubFailureTrampolineStub : public PlatformCodeStub { |
| 2450 public: | 2288 public: |
| 2451 explicit StubFailureTrampolineStub(StubFunctionMode function_mode) | 2289 explicit StubFailureTrampolineStub(StubFunctionMode function_mode) |
| 2452 : fp_registers_(CanUseFPRegisters()), function_mode_(function_mode) {} | 2290 : fp_registers_(CanUseFPRegisters()), function_mode_(function_mode) {} |
| 2453 | 2291 |
| 2454 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
| 2455 | |
| 2456 static void GenerateAheadOfTime(Isolate* isolate); | 2292 static void GenerateAheadOfTime(Isolate* isolate); |
| 2457 | 2293 |
| 2458 private: | 2294 private: |
| 2459 class FPRegisters: public BitField<bool, 0, 1> {}; | 2295 class FPRegisters: public BitField<bool, 0, 1> {}; |
| 2460 class FunctionModeField: public BitField<StubFunctionMode, 1, 1> {}; | 2296 class FunctionModeField: public BitField<StubFunctionMode, 1, 1> {}; |
| 2461 | 2297 |
| 2462 Major MajorKey() { return StubFailureTrampoline; } | 2298 Major MajorKey() { return StubFailureTrampoline; } |
| 2463 int MinorKey() { | 2299 int MinorKey() { |
| 2464 return FPRegisters::encode(fp_registers_) | | 2300 return FPRegisters::encode(fp_registers_) | |
| 2465 FunctionModeField::encode(function_mode_); | 2301 FunctionModeField::encode(function_mode_); |
| 2466 } | 2302 } |
| 2467 | 2303 |
| 2468 void Generate(MacroAssembler* masm); | 2304 void Generate(MacroAssembler* masm); |
| 2469 | 2305 |
| 2470 bool fp_registers_; | 2306 bool fp_registers_; |
| 2471 StubFunctionMode function_mode_; | 2307 StubFunctionMode function_mode_; |
| 2472 | 2308 |
| 2473 DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub); | 2309 DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub); |
| 2474 }; | 2310 }; |
| 2475 | 2311 |
| 2476 | 2312 |
| 2477 class StubFailureTailCallTrampolineStub : public PlatformCodeStub { | 2313 class StubFailureTailCallTrampolineStub : public PlatformCodeStub { |
| 2478 public: | 2314 public: |
| 2479 StubFailureTailCallTrampolineStub() : fp_registers_(CanUseFPRegisters()) {} | 2315 StubFailureTailCallTrampolineStub() : fp_registers_(CanUseFPRegisters()) {} |
| 2480 | 2316 |
| 2481 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
| 2482 | |
| 2483 static void GenerateAheadOfTime(Isolate* isolate); | 2317 static void GenerateAheadOfTime(Isolate* isolate); |
| 2484 | 2318 |
| 2485 private: | 2319 private: |
| 2486 class FPRegisters: public BitField<bool, 0, 1> {}; | 2320 class FPRegisters: public BitField<bool, 0, 1> {}; |
| 2487 Major MajorKey() { return StubFailureTailCallTrampoline; } | 2321 Major MajorKey() { return StubFailureTailCallTrampoline; } |
| 2488 int MinorKey() { return FPRegisters::encode(fp_registers_); } | 2322 int MinorKey() { return FPRegisters::encode(fp_registers_); } |
| 2489 | 2323 |
| 2490 void Generate(MacroAssembler* masm); | 2324 void Generate(MacroAssembler* masm); |
| 2491 | 2325 |
| 2492 bool fp_registers_; | 2326 bool fp_registers_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2514 int MinorKey() { return 0; } | 2348 int MinorKey() { return 0; } |
| 2515 | 2349 |
| 2516 void Generate(MacroAssembler* masm); | 2350 void Generate(MacroAssembler* masm); |
| 2517 | 2351 |
| 2518 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2352 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2519 }; | 2353 }; |
| 2520 | 2354 |
| 2521 } } // namespace v8::internal | 2355 } } // namespace v8::internal |
| 2522 | 2356 |
| 2523 #endif // V8_CODE_STUBS_H_ | 2357 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |