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

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

Issue 14847004: Turn the load field code stub into a hydrogen code stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | 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 // 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
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
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
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
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 virtual Code::Kind GetCodeKind() const { return kind(); }
763 virtual InlineCacheState GetICState() { return MONOMORPHIC; }
764
765 protected:
766 HICStub() : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) { }
767 class KindBits: public BitField<Code::Kind, 0, 4> {};
768 virtual Code::Kind kind() const = 0;
769 };
770
771
772 class HandlerStub: public HICStub {
773 public:
760 virtual Code::Kind GetCodeKind() const { return Code::STUB; } 774 virtual Code::Kind GetCodeKind() const { return Code::STUB; }
761 virtual int GetStubFlags() { return kind(); } 775 virtual int GetStubFlags() { return kind(); }
776
777 protected:
778 HandlerStub() : HICStub() { }
762 }; 779 };
763 780
764 781
765 class LoadFieldStub: public HandlerStub { 782 class LoadFieldStub: public HandlerStub {
766 public: 783 public:
767 LoadFieldStub(Register reg, bool inobject, int index) 784 LoadFieldStub(bool inobject, int index) : HandlerStub() {
768 : HandlerStub(Code::LOAD_IC), 785 Initialize(Code::LOAD_IC, inobject, index);
769 reg_(reg), 786 }
770 inobject_(inobject), 787
771 index_(index) { } 788 virtual Handle<Code> GenerateCode();
772 virtual void Generate(MacroAssembler* masm); 789
790 virtual void InitializeInterfaceDescriptor(
791 Isolate* isolate,
792 CodeStubInterfaceDescriptor* descriptor);
793
794 Representation representation() {
795 return Representation::Tagged();
796 }
797
798 virtual Code::Kind kind() const {
799 return KindBits::decode(bit_field_);
800 }
801
802 bool is_inobject() {
803 return InobjectBits::decode(bit_field_);
804 }
805
806 int offset() {
807 int index = IndexBits::decode(bit_field_);
808 int offset = index * kPointerSize;
809 if (is_inobject()) return offset;
810 return FixedArray::kHeaderSize + offset;
811 }
812
813 virtual Code::StubType GetStubType() { return Code::FIELD; }
773 814
774 protected: 815 protected:
775 virtual Code::StubType GetStubType() { return Code::FIELD; } 816 LoadFieldStub() : HandlerStub() { }
817
818 void Initialize(Code::Kind kind, bool inobject, int index) {
819 bit_field_ = KindBits::encode(kind)
820 | InobjectBits::encode(inobject)
821 | IndexBits::encode(index);
822 }
776 823
777 private: 824 private:
778 STATIC_ASSERT(KindBits::kSize == 4); 825 STATIC_ASSERT(KindBits::kSize == 4);
779 class RegisterBits: public BitField<int, 4, 6> {}; 826 class InobjectBits: public BitField<bool, 4, 1> {};
780 class InobjectBits: public BitField<bool, 10, 1> {}; 827 class IndexBits: public BitField<int, 5, 11> {};
781 class IndexBits: public BitField<int, 11, 11> {};
782 virtual CodeStub::Major MajorKey() { return LoadField; } 828 virtual CodeStub::Major MajorKey() { return LoadField; }
783 virtual int MinorKey() { 829 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 830
790 Register reg_; 831 int bit_field_;
791 bool inobject_;
792 int index_;
793 }; 832 };
794 833
795 834
835 class KeyedLoadFieldStub: public LoadFieldStub {
836 public:
837 KeyedLoadFieldStub(bool inobject, int index) : LoadFieldStub() {
838 Initialize(Code::KEYED_LOAD_IC, inobject, index);
839 }
840
841 virtual void InitializeInterfaceDescriptor(
842 Isolate* isolate,
843 CodeStubInterfaceDescriptor* descriptor);
844
845 virtual Handle<Code> GenerateCode();
846
847 private:
848 virtual CodeStub::Major MajorKey() { return KeyedLoadField; }
849 };
850
851
796 class BinaryOpStub: public PlatformCodeStub { 852 class BinaryOpStub: public PlatformCodeStub {
797 public: 853 public:
798 BinaryOpStub(Token::Value op, OverwriteMode mode) 854 BinaryOpStub(Token::Value op, OverwriteMode mode)
799 : op_(op), 855 : op_(op),
800 mode_(mode), 856 mode_(mode),
801 platform_specific_bit_(false), 857 platform_specific_bit_(false),
802 left_type_(BinaryOpIC::UNINITIALIZED), 858 left_type_(BinaryOpIC::UNINITIALIZED),
803 right_type_(BinaryOpIC::UNINITIALIZED), 859 right_type_(BinaryOpIC::UNINITIALIZED),
804 result_type_(BinaryOpIC::UNINITIALIZED) { 860 result_type_(BinaryOpIC::UNINITIALIZED) {
805 Initialize(); 861 Initialize();
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 1950
1895 // The current function entry hook. 1951 // The current function entry hook.
1896 static FunctionEntryHook entry_hook_; 1952 static FunctionEntryHook entry_hook_;
1897 1953
1898 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 1954 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
1899 }; 1955 };
1900 1956
1901 } } // namespace v8::internal 1957 } } // namespace v8::internal
1902 1958
1903 #endif // V8_CODE_STUBS_H_ 1959 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698