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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // result in a traversable stack. | 169 // result in a traversable stack. |
170 virtual bool SometimesSetsUpAFrame() { return true; } | 170 virtual bool SometimesSetsUpAFrame() { return true; } |
171 | 171 |
172 // Lookup the code in the (possibly custom) cache. | 172 // Lookup the code in the (possibly custom) cache. |
173 bool FindCodeInCache(Code** code_out, Isolate* isolate); | 173 bool FindCodeInCache(Code** code_out, Isolate* isolate); |
174 | 174 |
175 // Returns information for computing the number key. | 175 // Returns information for computing the number key. |
176 virtual Major MajorKey() = 0; | 176 virtual Major MajorKey() = 0; |
177 virtual int MinorKey() = 0; | 177 virtual int MinorKey() = 0; |
178 | 178 |
| 179 virtual InlineCacheState GetICState() { |
| 180 return UNINITIALIZED; |
| 181 } |
| 182 virtual Code::ExtraICState GetExtraICState() { |
| 183 return Code::kNoExtraICState; |
| 184 } |
| 185 |
179 protected: | 186 protected: |
180 static bool CanUseFPRegisters(); | 187 static bool CanUseFPRegisters(); |
181 | 188 |
182 // Generates the assembler code for the stub. | 189 // Generates the assembler code for the stub. |
183 virtual Handle<Code> GenerateCode() = 0; | 190 virtual Handle<Code> GenerateCode() = 0; |
184 | 191 |
185 // BinaryOpStub needs to override this. | |
186 virtual InlineCacheState GetICState() { | |
187 return UNINITIALIZED; | |
188 } | |
189 virtual Code::ExtraICState GetExtraICState() { | |
190 return Code::kNoExtraICState; | |
191 } | |
192 virtual Code::StubType GetStubType() { | 192 virtual Code::StubType GetStubType() { |
193 return Code::NORMAL; | 193 return Code::NORMAL; |
194 } | 194 } |
195 | 195 |
196 // Returns whether the code generated for this stub needs to be allocated as | 196 // Returns whether the code generated for this stub needs to be allocated as |
197 // a fixed (non-moveable) code object. | 197 // a fixed (non-moveable) code object. |
198 virtual bool NeedsImmovableCode() { return false; } | 198 virtual bool NeedsImmovableCode() { return false; } |
199 | 199 |
200 private: | 200 private: |
201 // Perform bookkeeping required after code generation when stub code is | 201 // Perform bookkeeping required after code generation when stub code is |
202 // initially generated. | 202 // initially generated. |
203 void RecordCodeGeneration(Code* code, Isolate* isolate); | 203 void RecordCodeGeneration(Code* code, Isolate* isolate); |
204 | 204 |
205 // Finish the code object after it has been generated. | 205 // Finish the code object after it has been generated. |
206 virtual void FinishCode(Handle<Code> code) { } | 206 virtual void FinishCode(Handle<Code> code) { } |
207 | 207 |
208 // Activate newly generated stub. Is called after | 208 // Activate newly generated stub. Is called after |
209 // registering stub in the stub cache. | 209 // registering stub in the stub cache. |
210 virtual void Activate(Code* code) { } | 210 virtual void Activate(Code* code) { } |
211 | 211 |
212 // BinaryOpStub needs to override this. | 212 // BinaryOpStub needs to override this. |
213 virtual int GetCodeKind(); | 213 virtual Code::Kind GetCodeKind() const; |
214 | 214 |
215 // Add the code to a specialized cache, specific to an individual | 215 // Add the code to a specialized cache, specific to an individual |
216 // stub type. Please note, this method must add the code object to a | 216 // stub type. Please note, this method must add the code object to a |
217 // roots object, otherwise we will remove the code during GC. | 217 // roots object, otherwise we will remove the code during GC. |
218 virtual void AddToSpecialCache(Handle<Code> new_object) { } | 218 virtual void AddToSpecialCache(Handle<Code> new_object) { } |
219 | 219 |
220 // Find code in a specialized cache, work is delegated to the specific stub. | 220 // Find code in a specialized cache, work is delegated to the specific stub. |
221 virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { | 221 virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { |
222 return false; | 222 return false; |
223 } | 223 } |
(...skipping 18 matching lines...) Expand all Loading... |
242 | 242 |
243 friend class BreakPointIterator; | 243 friend class BreakPointIterator; |
244 }; | 244 }; |
245 | 245 |
246 | 246 |
247 class PlatformCodeStub : public CodeStub { | 247 class PlatformCodeStub : public CodeStub { |
248 public: | 248 public: |
249 // Retrieve the code for the stub. Generate the code if needed. | 249 // Retrieve the code for the stub. Generate the code if needed. |
250 virtual Handle<Code> GenerateCode(); | 250 virtual Handle<Code> GenerateCode(); |
251 | 251 |
252 virtual int GetCodeKind() { return Code::STUB; } | 252 virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
253 virtual int GetStubFlags() { return -1; } | 253 virtual int GetStubFlags() { return -1; } |
254 | 254 |
255 protected: | 255 protected: |
256 // Generates the assembler code for the stub. | 256 // Generates the assembler code for the stub. |
257 virtual void Generate(MacroAssembler* masm) = 0; | 257 virtual void Generate(MacroAssembler* masm) = 0; |
258 }; | 258 }; |
259 | 259 |
260 | 260 |
261 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 261 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
262 | 262 |
(...skipping 16 matching lines...) Expand all Loading... |
279 return register_param_count_; | 279 return register_param_count_; |
280 } | 280 } |
281 }; | 281 }; |
282 | 282 |
283 | 283 |
284 class HydrogenCodeStub : public CodeStub { | 284 class HydrogenCodeStub : public CodeStub { |
285 public: | 285 public: |
286 // Retrieve the code for the stub. Generate the code if needed. | 286 // Retrieve the code for the stub. Generate the code if needed. |
287 virtual Handle<Code> GenerateCode() = 0; | 287 virtual Handle<Code> GenerateCode() = 0; |
288 | 288 |
289 virtual int GetCodeKind() { return Code::COMPILED_STUB; } | 289 virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
290 | 290 |
291 CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) { | 291 CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) { |
292 return isolate->code_stub_interface_descriptor(MajorKey()); | 292 return isolate->code_stub_interface_descriptor(MajorKey()); |
293 } | 293 } |
294 | 294 |
295 virtual void InitializeInterfaceDescriptor( | 295 virtual void InitializeInterfaceDescriptor( |
296 Isolate* isolate, | 296 Isolate* isolate, |
297 CodeStubInterfaceDescriptor* descriptor) = 0; | 297 CodeStubInterfaceDescriptor* descriptor) = 0; |
298 }; | 298 }; |
299 | 299 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 virtual CodeStub::Major MajorKey() { return MathPow; } | 599 virtual CodeStub::Major MajorKey() { return MathPow; } |
600 virtual int MinorKey() { return exponent_type_; } | 600 virtual int MinorKey() { return exponent_type_; } |
601 | 601 |
602 ExponentType exponent_type_; | 602 ExponentType exponent_type_; |
603 }; | 603 }; |
604 | 604 |
605 | 605 |
606 class ICStub: public PlatformCodeStub { | 606 class ICStub: public PlatformCodeStub { |
607 public: | 607 public: |
608 explicit ICStub(Code::Kind kind) : kind_(kind) { } | 608 explicit ICStub(Code::Kind kind) : kind_(kind) { } |
609 virtual int GetCodeKind() { return kind_; } | 609 virtual Code::Kind GetCodeKind() const { return kind_; } |
610 virtual InlineCacheState GetICState() { return MONOMORPHIC; } | 610 virtual InlineCacheState GetICState() { return MONOMORPHIC; } |
611 | 611 |
612 bool Describes(Code* code) { | 612 bool Describes(Code* code) { |
613 return GetMajorKey(code) == MajorKey() && code->stub_info() == MinorKey(); | 613 return GetMajorKey(code) == MajorKey() && code->stub_info() == MinorKey(); |
614 } | 614 } |
615 | 615 |
616 protected: | 616 protected: |
617 class KindBits: public BitField<Code::Kind, 0, 4> {}; | 617 class KindBits: public BitField<Code::Kind, 0, 4> {}; |
618 virtual void FinishCode(Handle<Code> code) { | 618 virtual void FinishCode(Handle<Code> code) { |
619 code->set_stub_info(MinorKey()); | 619 code->set_stub_info(MinorKey()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 virtual void Generate(MacroAssembler* masm); | 685 virtual void Generate(MacroAssembler* masm); |
686 | 686 |
687 private: | 687 private: |
688 virtual CodeStub::Major MajorKey() { return StoreArrayLength; } | 688 virtual CodeStub::Major MajorKey() { return StoreArrayLength; } |
689 }; | 689 }; |
690 | 690 |
691 | 691 |
692 class HandlerStub: public ICStub { | 692 class HandlerStub: public ICStub { |
693 public: | 693 public: |
694 explicit HandlerStub(Code::Kind kind) : ICStub(kind) { } | 694 explicit HandlerStub(Code::Kind kind) : ICStub(kind) { } |
695 virtual int GetCodeKind() { return Code::STUB; } | 695 virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
696 virtual int GetStubFlags() { return kind(); } | 696 virtual int GetStubFlags() { return kind(); } |
697 }; | 697 }; |
698 | 698 |
699 | 699 |
700 class LoadFieldStub: public HandlerStub { | 700 class LoadFieldStub: public HandlerStub { |
701 public: | 701 public: |
702 LoadFieldStub(Register reg, bool inobject, int index) | 702 LoadFieldStub(Register reg, bool inobject, int index) |
703 : HandlerStub(Code::LOAD_IC), | 703 : HandlerStub(Code::LOAD_IC), |
704 reg_(reg), | 704 reg_(reg), |
705 inobject_(inobject), | 705 inobject_(inobject), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 void GenerateReturn(MacroAssembler* masm); | 823 void GenerateReturn(MacroAssembler* masm); |
824 void GenerateSmiStub(MacroAssembler* masm); | 824 void GenerateSmiStub(MacroAssembler* masm); |
825 void GenerateStringStub(MacroAssembler* masm); | 825 void GenerateStringStub(MacroAssembler* masm); |
826 void GenerateTypeTransition(MacroAssembler* masm); | 826 void GenerateTypeTransition(MacroAssembler* masm); |
827 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); | 827 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); |
828 void GenerateUninitializedStub(MacroAssembler* masm); | 828 void GenerateUninitializedStub(MacroAssembler* masm); |
829 | 829 |
830 // Entirely platform-specific methods are defined as static helper | 830 // Entirely platform-specific methods are defined as static helper |
831 // functions in the <arch>/code-stubs-<arch>.cc files. | 831 // functions in the <arch>/code-stubs-<arch>.cc files. |
832 | 832 |
833 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } | 833 virtual Code::Kind GetCodeKind() const { return Code::BINARY_OP_IC; } |
834 | 834 |
835 virtual InlineCacheState GetICState() { | 835 virtual InlineCacheState GetICState() { |
836 return BinaryOpIC::ToState(Max(left_type_, right_type_)); | 836 return BinaryOpIC::ToState(Max(left_type_, right_type_)); |
837 } | 837 } |
838 | 838 |
839 virtual void FinishCode(Handle<Code> code) { | 839 virtual void FinishCode(Handle<Code> code) { |
840 code->set_stub_info(MinorKey()); | 840 code->set_stub_info(MinorKey()); |
841 } | 841 } |
842 | 842 |
843 friend class CodeGenerator; | 843 friend class CodeGenerator; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 class RightStateField: public BitField<int, 7, 4> { }; | 877 class RightStateField: public BitField<int, 7, 4> { }; |
878 class HandlerStateField: public BitField<int, 11, 4> { }; | 878 class HandlerStateField: public BitField<int, 11, 4> { }; |
879 | 879 |
880 virtual void FinishCode(Handle<Code> code) { | 880 virtual void FinishCode(Handle<Code> code) { |
881 code->set_stub_info(MinorKey()); | 881 code->set_stub_info(MinorKey()); |
882 } | 882 } |
883 | 883 |
884 virtual CodeStub::Major MajorKey() { return CompareIC; } | 884 virtual CodeStub::Major MajorKey() { return CompareIC; } |
885 virtual int MinorKey(); | 885 virtual int MinorKey(); |
886 | 886 |
887 virtual int GetCodeKind() { return Code::COMPARE_IC; } | 887 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_IC; } |
888 | 888 |
889 void GenerateSmis(MacroAssembler* masm); | 889 void GenerateSmis(MacroAssembler* masm); |
890 void GenerateNumbers(MacroAssembler* masm); | 890 void GenerateNumbers(MacroAssembler* masm); |
891 void GenerateInternalizedStrings(MacroAssembler* masm); | 891 void GenerateInternalizedStrings(MacroAssembler* masm); |
892 void GenerateStrings(MacroAssembler* masm); | 892 void GenerateStrings(MacroAssembler* masm); |
893 void GenerateUniqueNames(MacroAssembler* masm); | 893 void GenerateUniqueNames(MacroAssembler* masm); |
894 void GenerateObjects(MacroAssembler* masm); | 894 void GenerateObjects(MacroAssembler* masm); |
895 void GenerateMiss(MacroAssembler* masm); | 895 void GenerateMiss(MacroAssembler* masm); |
896 void GenerateKnownObjects(MacroAssembler* masm); | 896 void GenerateKnownObjects(MacroAssembler* masm); |
897 void GenerateGeneric(MacroAssembler* masm); | 897 void GenerateGeneric(MacroAssembler* masm); |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 EnumSet<Type, byte> set_; | 1541 EnumSet<Type, byte> set_; |
1542 }; | 1542 }; |
1543 | 1543 |
1544 static Types no_types() { return Types(); } | 1544 static Types no_types() { return Types(); } |
1545 static Types all_types() { return Types((1 << NUMBER_OF_TYPES) - 1); } | 1545 static Types all_types() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
1546 | 1546 |
1547 explicit ToBooleanStub(Register tos, Types types = Types()) | 1547 explicit ToBooleanStub(Register tos, Types types = Types()) |
1548 : tos_(tos), types_(types) { } | 1548 : tos_(tos), types_(types) { } |
1549 | 1549 |
1550 void Generate(MacroAssembler* masm); | 1550 void Generate(MacroAssembler* masm); |
1551 virtual int GetCodeKind() { return Code::TO_BOOLEAN_IC; } | 1551 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } |
1552 virtual void PrintName(StringStream* stream); | 1552 virtual void PrintName(StringStream* stream); |
1553 | 1553 |
1554 virtual bool SometimesSetsUpAFrame() { return false; } | 1554 virtual bool SometimesSetsUpAFrame() { return false; } |
1555 | 1555 |
1556 private: | 1556 private: |
1557 Major MajorKey() { return ToBoolean; } | 1557 Major MajorKey() { return ToBoolean; } |
1558 int MinorKey() { return (tos_.code() << NUMBER_OF_TYPES) | types_.ToByte(); } | 1558 int MinorKey() { return (tos_.code() << NUMBER_OF_TYPES) | types_.ToByte(); } |
1559 | 1559 |
1560 virtual void FinishCode(Handle<Code> code) { | 1560 virtual void FinishCode(Handle<Code> code) { |
1561 code->set_to_boolean_state(types_.ToByte()); | 1561 code->set_to_boolean_state(types_.ToByte()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 | 1688 |
1689 // The current function entry hook. | 1689 // The current function entry hook. |
1690 static FunctionEntryHook entry_hook_; | 1690 static FunctionEntryHook entry_hook_; |
1691 | 1691 |
1692 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 1692 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
1693 }; | 1693 }; |
1694 | 1694 |
1695 } } // namespace v8::internal | 1695 } } // namespace v8::internal |
1696 | 1696 |
1697 #endif // V8_CODE_STUBS_H_ | 1697 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |