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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 V(KeyedStoreElement) \ | 80 V(KeyedStoreElement) \ |
81 V(DebuggerStatement) \ | 81 V(DebuggerStatement) \ |
82 V(NameDictionaryLookup) \ | 82 V(NameDictionaryLookup) \ |
83 V(ElementsTransitionAndStore) \ | 83 V(ElementsTransitionAndStore) \ |
84 V(TransitionElementsKind) \ | 84 V(TransitionElementsKind) \ |
85 V(StoreArrayLiteralElement) \ | 85 V(StoreArrayLiteralElement) \ |
86 V(StubFailureTrampoline) \ | 86 V(StubFailureTrampoline) \ |
87 V(ArrayConstructor) \ | 87 V(ArrayConstructor) \ |
88 V(ProfileEntryHook) \ | 88 V(ProfileEntryHook) \ |
89 /* IC Handler stubs */ \ | 89 /* IC Handler stubs */ \ |
90 V(LoadField) | 90 V(LoadField) \ |
91 V(KeyedLoadField) | |
91 | 92 |
92 // List of code stubs only used on ARM platforms. | 93 // List of code stubs only used on ARM platforms. |
93 #ifdef V8_TARGET_ARCH_ARM | 94 #ifdef V8_TARGET_ARCH_ARM |
94 #define CODE_STUB_LIST_ARM(V) \ | 95 #define CODE_STUB_LIST_ARM(V) \ |
95 V(GetProperty) \ | 96 V(GetProperty) \ |
96 V(SetProperty) \ | 97 V(SetProperty) \ |
97 V(InvokeBuiltin) \ | 98 V(InvokeBuiltin) \ |
98 V(RegExpCEntry) \ | 99 V(RegExpCEntry) \ |
99 V(DirectCEntry) | 100 V(DirectCEntry) |
100 #else | 101 #else |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 // Returns information for computing the number key. | 179 // Returns information for computing the number key. |
179 virtual Major MajorKey() = 0; | 180 virtual Major MajorKey() = 0; |
180 virtual int MinorKey() = 0; | 181 virtual int MinorKey() = 0; |
181 | 182 |
182 virtual InlineCacheState GetICState() { | 183 virtual InlineCacheState GetICState() { |
183 return UNINITIALIZED; | 184 return UNINITIALIZED; |
184 } | 185 } |
185 virtual Code::ExtraICState GetExtraICState() { | 186 virtual Code::ExtraICState GetExtraICState() { |
186 return Code::kNoExtraICState; | 187 return Code::kNoExtraICState; |
187 } | 188 } |
189 virtual Code::StubType GetStubType() { | |
190 return Code::NORMAL; | |
191 } | |
192 virtual int GetStubFlags() { | |
193 return -1; | |
194 } | |
188 | 195 |
189 protected: | 196 protected: |
190 static bool CanUseFPRegisters(); | 197 static bool CanUseFPRegisters(); |
191 | 198 |
192 // Generates the assembler code for the stub. | 199 // Generates the assembler code for the stub. |
193 virtual Handle<Code> GenerateCode() = 0; | 200 virtual Handle<Code> GenerateCode() = 0; |
194 | 201 |
195 virtual Code::StubType GetStubType() { | |
196 return Code::NORMAL; | |
197 } | |
198 | 202 |
199 // Returns whether the code generated for this stub needs to be allocated as | 203 // Returns whether the code generated for this stub needs to be allocated as |
200 // a fixed (non-moveable) code object. | 204 // a fixed (non-moveable) code object. |
201 virtual bool NeedsImmovableCode() { return false; } | 205 virtual bool NeedsImmovableCode() { return false; } |
202 | 206 |
203 private: | 207 private: |
204 // Perform bookkeeping required after code generation when stub code is | 208 // Perform bookkeeping required after code generation when stub code is |
205 // initially generated. | 209 // initially generated. |
206 void RecordCodeGeneration(Code* code, Isolate* isolate); | 210 void RecordCodeGeneration(Code* code, Isolate* isolate); |
207 | 211 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 friend class BreakPointIterator; | 250 friend class BreakPointIterator; |
247 }; | 251 }; |
248 | 252 |
249 | 253 |
250 class PlatformCodeStub : public CodeStub { | 254 class PlatformCodeStub : public CodeStub { |
251 public: | 255 public: |
252 // Retrieve the code for the stub. Generate the code if needed. | 256 // Retrieve the code for the stub. Generate the code if needed. |
253 virtual Handle<Code> GenerateCode(); | 257 virtual Handle<Code> GenerateCode(); |
254 | 258 |
255 virtual Code::Kind GetCodeKind() const { return Code::STUB; } | 259 virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
256 virtual int GetStubFlags() { return -1; } | |
257 | 260 |
258 protected: | 261 protected: |
259 // Generates the assembler code for the stub. | 262 // Generates the assembler code for the stub. |
260 virtual void Generate(MacroAssembler* masm) = 0; | 263 virtual void Generate(MacroAssembler* masm) = 0; |
261 }; | 264 }; |
262 | 265 |
263 | 266 |
264 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 267 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
265 | 268 |
266 | 269 |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 public: | 750 public: |
748 explicit StoreArrayLengthStub(Code::Kind kind, StrictModeFlag strict_mode) | 751 explicit StoreArrayLengthStub(Code::Kind kind, StrictModeFlag strict_mode) |
749 : StoreICStub(kind, strict_mode) { } | 752 : StoreICStub(kind, strict_mode) { } |
750 virtual void Generate(MacroAssembler* masm); | 753 virtual void Generate(MacroAssembler* masm); |
751 | 754 |
752 private: | 755 private: |
753 virtual CodeStub::Major MajorKey() { return StoreArrayLength; } | 756 virtual CodeStub::Major MajorKey() { return StoreArrayLength; } |
754 }; | 757 }; |
755 | 758 |
756 | 759 |
757 class HandlerStub: public ICStub { | 760 class HICStub: public HydrogenCodeStub { |
758 public: | 761 public: |
759 explicit HandlerStub(Code::Kind kind) : ICStub(kind) { } | 762 explicit HICStub(Code::Kind kind) |
763 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS), kind_(kind) { } | |
764 virtual Code::Kind GetCodeKind() const { return kind_; } | |
765 virtual InlineCacheState GetICState() { return MONOMORPHIC; } | |
766 | |
767 protected: | |
768 class KindBits: public BitField<Code::Kind, 0, 4> {}; | |
769 Code::Kind kind() { return kind_; } | |
danno
2013/05/02 15:32:36
Either make virtual or remove.
| |
770 | |
771 private: | |
772 Code::Kind kind_; | |
773 }; | |
774 | |
775 | |
776 class HandlerStub: public HICStub { | |
777 public: | |
778 explicit HandlerStub(Code::Kind kind) : HICStub(kind) { } | |
760 virtual Code::Kind GetCodeKind() const { return Code::STUB; } | 779 virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
761 virtual int GetStubFlags() { return kind(); } | 780 virtual int GetStubFlags() { return kind(); } |
762 }; | 781 }; |
763 | 782 |
764 | 783 |
765 class LoadFieldStub: public HandlerStub { | 784 class LoadFieldStub: public HandlerStub { |
766 public: | 785 public: |
767 LoadFieldStub(Register reg, bool inobject, int index) | 786 LoadFieldStub(bool inobject, |
768 : HandlerStub(Code::LOAD_IC), | 787 int index, |
769 reg_(reg), | 788 Code::Kind kind = Code::LOAD_IC) |
770 inobject_(inobject), | 789 : HandlerStub(kind) { |
771 index_(index) { } | 790 bit_field_ = KindBits::encode(kind) |
772 virtual void Generate(MacroAssembler* masm); | 791 | InobjectBits::encode(inobject) |
792 | IndexBits::encode(index); | |
793 } | |
794 virtual Handle<Code> GenerateCode(); | |
773 | 795 |
774 protected: | 796 virtual void InitializeInterfaceDescriptor( |
797 Isolate* isolate, | |
798 CodeStubInterfaceDescriptor* descriptor); | |
799 | |
800 Representation representation() { | |
801 return Representation::Tagged(); | |
802 } | |
803 | |
804 bool is_inobject() { | |
805 return InobjectBits::decode(bit_field_); | |
806 } | |
807 | |
808 int offset() { | |
809 int index = IndexBits::decode(bit_field_); | |
810 int offset = index * kPointerSize; | |
811 if (is_inobject()) return offset; | |
812 return FixedArray::kHeaderSize + offset; | |
813 } | |
814 | |
775 virtual Code::StubType GetStubType() { return Code::FIELD; } | 815 virtual Code::StubType GetStubType() { return Code::FIELD; } |
776 | 816 |
777 private: | 817 private: |
778 STATIC_ASSERT(KindBits::kSize == 4); | 818 STATIC_ASSERT(KindBits::kSize == 4); |
779 class RegisterBits: public BitField<int, 4, 6> {}; | 819 class InobjectBits: public BitField<bool, 4, 1> {}; |
780 class InobjectBits: public BitField<bool, 10, 1> {}; | 820 class IndexBits: public BitField<int, 5, 11> {}; |
781 class IndexBits: public BitField<int, 11, 11> {}; | |
782 virtual CodeStub::Major MajorKey() { return LoadField; } | 821 virtual CodeStub::Major MajorKey() { return LoadField; } |
783 virtual int MinorKey() { | 822 virtual int NotMissMinorKey() { return bit_field_; } |
784 return KindBits::encode(kind()) | |
785 | RegisterBits::encode(reg_.code()) | |
786 | InobjectBits::encode(inobject_) | |
787 | IndexBits::encode(index_); | |
788 } | |
789 | 823 |
790 Register reg_; | 824 int bit_field_; |
791 bool inobject_; | |
792 int index_; | |
793 }; | 825 }; |
794 | 826 |
795 | 827 |
828 class KeyedLoadFieldStub: public LoadFieldStub { | |
829 public: | |
830 KeyedLoadFieldStub(bool inobject, | |
831 int index) | |
832 : LoadFieldStub(inobject, index, Code::KEYED_LOAD_IC) { } | |
833 | |
834 virtual void InitializeInterfaceDescriptor( | |
835 Isolate* isolate, | |
836 CodeStubInterfaceDescriptor* descriptor); | |
837 | |
838 virtual Handle<Code> GenerateCode(); | |
839 | |
840 private: | |
841 virtual CodeStub::Major MajorKey() { return KeyedLoadField; } | |
842 }; | |
843 | |
844 | |
796 class BinaryOpStub: public PlatformCodeStub { | 845 class BinaryOpStub: public PlatformCodeStub { |
797 public: | 846 public: |
798 BinaryOpStub(Token::Value op, OverwriteMode mode) | 847 BinaryOpStub(Token::Value op, OverwriteMode mode) |
799 : op_(op), | 848 : op_(op), |
800 mode_(mode), | 849 mode_(mode), |
801 platform_specific_bit_(false), | 850 platform_specific_bit_(false), |
802 left_type_(BinaryOpIC::UNINITIALIZED), | 851 left_type_(BinaryOpIC::UNINITIALIZED), |
803 right_type_(BinaryOpIC::UNINITIALIZED), | 852 right_type_(BinaryOpIC::UNINITIALIZED), |
804 result_type_(BinaryOpIC::UNINITIALIZED) { | 853 result_type_(BinaryOpIC::UNINITIALIZED) { |
805 Initialize(); | 854 Initialize(); |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1894 | 1943 |
1895 // The current function entry hook. | 1944 // The current function entry hook. |
1896 static FunctionEntryHook entry_hook_; | 1945 static FunctionEntryHook entry_hook_; |
1897 | 1946 |
1898 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 1947 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
1899 }; | 1948 }; |
1900 | 1949 |
1901 } } // namespace v8::internal | 1950 } } // namespace v8::internal |
1902 | 1951 |
1903 #endif // V8_CODE_STUBS_H_ | 1952 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |