OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 15 matching lines...) Expand all Loading... |
27 | 27 |
28 #ifndef V8_CODE_STUBS_H_ | 28 #ifndef V8_CODE_STUBS_H_ |
29 #define V8_CODE_STUBS_H_ | 29 #define V8_CODE_STUBS_H_ |
30 | 30 |
31 #include "globals.h" | 31 #include "globals.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 // List of code stubs used on all platforms. The order in this list is important | 36 // List of code stubs used on all platforms. The order in this list is important |
37 // as only the stubs up to and including RecordWrite allows nested stub calls. | 37 // as only the stubs up to and including Instanceof allows nested stub calls. |
38 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 38 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
39 V(CallFunction) \ | 39 V(CallFunction) \ |
40 V(GenericBinaryOp) \ | 40 V(GenericBinaryOp) \ |
41 V(TypeRecordingBinaryOp) \ | 41 V(TypeRecordingBinaryOp) \ |
42 V(StringAdd) \ | 42 V(StringAdd) \ |
43 V(StringCharAt) \ | 43 V(StringCharAt) \ |
44 V(SubString) \ | 44 V(SubString) \ |
45 V(StringCompare) \ | 45 V(StringCompare) \ |
46 V(SmiOp) \ | 46 V(SmiOp) \ |
47 V(Compare) \ | 47 V(Compare) \ |
48 V(CompareIC) \ | 48 V(CompareIC) \ |
49 V(MathPow) \ | 49 V(MathPow) \ |
50 V(TranscendentalCache) \ | 50 V(TranscendentalCache) \ |
51 V(RecordWrite) \ | 51 V(Instanceof) \ |
52 V(ConvertToDouble) \ | 52 V(ConvertToDouble) \ |
53 V(WriteInt32ToHeapNumber) \ | 53 V(WriteInt32ToHeapNumber) \ |
54 V(IntegerMod) \ | 54 V(IntegerMod) \ |
55 V(StackCheck) \ | 55 V(StackCheck) \ |
56 V(FastNewClosure) \ | 56 V(FastNewClosure) \ |
57 V(FastNewContext) \ | 57 V(FastNewContext) \ |
58 V(FastCloneShallowArray) \ | 58 V(FastCloneShallowArray) \ |
59 V(GenericUnaryOp) \ | 59 V(GenericUnaryOp) \ |
60 V(RevertToNumber) \ | 60 V(RevertToNumber) \ |
61 V(ToBoolean) \ | 61 V(ToBoolean) \ |
62 V(Instanceof) \ | |
63 V(CounterOp) \ | 62 V(CounterOp) \ |
64 V(ArgumentsAccess) \ | 63 V(ArgumentsAccess) \ |
65 V(RegExpExec) \ | 64 V(RegExpExec) \ |
66 V(RegExpConstructResult) \ | 65 V(RegExpConstructResult) \ |
67 V(NumberToString) \ | 66 V(NumberToString) \ |
68 V(CEntry) \ | 67 V(CEntry) \ |
69 V(JSEntry) \ | 68 V(JSEntry) \ |
70 V(DebuggerStatement) | 69 V(DebuggerStatement) |
71 | 70 |
72 // List of code stubs only used on ARM platforms. | 71 // List of code stubs only used on ARM platforms. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 virtual void Print() { PrintF("%s\n", GetName()); } | 172 virtual void Print() { PrintF("%s\n", GetName()); } |
174 #endif | 173 #endif |
175 | 174 |
176 // Computes the key based on major and minor. | 175 // Computes the key based on major and minor. |
177 uint32_t GetKey() { | 176 uint32_t GetKey() { |
178 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); | 177 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
179 return MinorKeyBits::encode(MinorKey()) | | 178 return MinorKeyBits::encode(MinorKey()) | |
180 MajorKeyBits::encode(MajorKey()); | 179 MajorKeyBits::encode(MajorKey()); |
181 } | 180 } |
182 | 181 |
183 bool AllowsStubCalls() { return MajorKey() <= RecordWrite; } | 182 bool AllowsStubCalls() { return MajorKey() <= Instanceof; } |
184 | 183 |
185 class MajorKeyBits: public BitField<uint32_t, 0, kMajorBits> {}; | 184 class MajorKeyBits: public BitField<uint32_t, 0, kMajorBits> {}; |
186 class MinorKeyBits: public BitField<uint32_t, kMajorBits, kMinorBits> {}; | 185 class MinorKeyBits: public BitField<uint32_t, kMajorBits, kMinorBits> {}; |
187 | 186 |
188 friend class BreakPointIterator; | 187 friend class BreakPointIterator; |
189 }; | 188 }; |
190 | 189 |
191 | 190 |
192 // Helper interface to prepare to/restore after making runtime calls. | 191 // Helper interface to prepare to/restore after making runtime calls. |
193 class RuntimeCallHelper { | 192 class RuntimeCallHelper { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 ASSERT(mode_ == 0 || mode_ == 1); | 319 ASSERT(mode_ == 0 || mode_ == 1); |
321 return (length_ << 1) | mode_; | 320 return (length_ << 1) | mode_; |
322 } | 321 } |
323 }; | 322 }; |
324 | 323 |
325 | 324 |
326 class InstanceofStub: public CodeStub { | 325 class InstanceofStub: public CodeStub { |
327 public: | 326 public: |
328 enum Flags { | 327 enum Flags { |
329 kNoFlags = 0, | 328 kNoFlags = 0, |
330 kArgsInRegisters = 1 << 0 | 329 kArgsInRegisters = 1 << 0, |
| 330 kCallSiteInlineCheck = 1 << 1, |
| 331 kReturnTrueFalseObject = 1 << 2 |
331 }; | 332 }; |
332 | 333 |
333 explicit InstanceofStub(Flags flags) : flags_(flags) { } | 334 explicit InstanceofStub(Flags flags) : flags_(flags), name_(NULL) { } |
| 335 |
| 336 static Register left(); |
| 337 static Register right(); |
334 | 338 |
335 void Generate(MacroAssembler* masm); | 339 void Generate(MacroAssembler* masm); |
336 | 340 |
337 private: | 341 private: |
338 Major MajorKey() { return Instanceof; } | 342 Major MajorKey() { return Instanceof; } |
339 int MinorKey() { return args_in_registers() ? 1 : 0; } | 343 int MinorKey() { return static_cast<int>(flags_); } |
340 | 344 |
341 bool args_in_registers() { | 345 bool HasArgsInRegisters() const { |
342 return (flags_ & kArgsInRegisters) != 0; | 346 return (flags_ & kArgsInRegisters) != 0; |
343 } | 347 } |
344 | 348 |
| 349 bool HasCallSiteInlineCheck() const { |
| 350 return (flags_ & kCallSiteInlineCheck) != 0; |
| 351 } |
| 352 |
| 353 bool ReturnTrueFalseObject() const { |
| 354 return (flags_ & kReturnTrueFalseObject) != 0; |
| 355 } |
| 356 |
| 357 const char* GetName(); |
| 358 |
345 Flags flags_; | 359 Flags flags_; |
| 360 char* name_; |
346 }; | 361 }; |
347 | 362 |
348 | 363 |
349 enum NegativeZeroHandling { | 364 enum NegativeZeroHandling { |
350 kStrictNegativeZero, | 365 kStrictNegativeZero, |
351 kIgnoreNegativeZero | 366 kIgnoreNegativeZero |
352 }; | 367 }; |
353 | 368 |
354 | 369 |
355 enum UnaryOpFlags { | 370 enum UnaryOpFlags { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 }; | 715 }; |
701 | 716 |
702 | 717 |
703 class CallFunctionStub: public CodeStub { | 718 class CallFunctionStub: public CodeStub { |
704 public: | 719 public: |
705 CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags) | 720 CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags) |
706 : argc_(argc), in_loop_(in_loop), flags_(flags) { } | 721 : argc_(argc), in_loop_(in_loop), flags_(flags) { } |
707 | 722 |
708 void Generate(MacroAssembler* masm); | 723 void Generate(MacroAssembler* masm); |
709 | 724 |
| 725 static int ExtractArgcFromMinorKey(int minor_key) { |
| 726 return ArgcBits::decode(minor_key); |
| 727 } |
| 728 |
710 private: | 729 private: |
711 int argc_; | 730 int argc_; |
712 InLoopFlag in_loop_; | 731 InLoopFlag in_loop_; |
713 CallFunctionFlags flags_; | 732 CallFunctionFlags flags_; |
714 | 733 |
715 #ifdef DEBUG | 734 #ifdef DEBUG |
716 void Print() { | 735 void Print() { |
717 PrintF("CallFunctionStub (args %d, in_loop %d, flags %d)\n", | 736 PrintF("CallFunctionStub (args %d, in_loop %d, flags %d)\n", |
718 argc_, | 737 argc_, |
719 static_cast<int>(in_loop_), | 738 static_cast<int>(in_loop_), |
(...skipping 11 matching lines...) Expand all Loading... |
731 // Encode the parameters in a unique 32 bit value. | 750 // Encode the parameters in a unique 32 bit value. |
732 return InLoopBits::encode(in_loop_) | 751 return InLoopBits::encode(in_loop_) |
733 | FlagBits::encode(flags_) | 752 | FlagBits::encode(flags_) |
734 | ArgcBits::encode(argc_); | 753 | ArgcBits::encode(argc_); |
735 } | 754 } |
736 | 755 |
737 InLoopFlag InLoop() { return in_loop_; } | 756 InLoopFlag InLoop() { return in_loop_; } |
738 bool ReceiverMightBeValue() { | 757 bool ReceiverMightBeValue() { |
739 return (flags_ & RECEIVER_MIGHT_BE_VALUE) != 0; | 758 return (flags_ & RECEIVER_MIGHT_BE_VALUE) != 0; |
740 } | 759 } |
741 | |
742 public: | |
743 static int ExtractArgcFromMinorKey(int minor_key) { | |
744 return ArgcBits::decode(minor_key); | |
745 } | |
746 }; | 760 }; |
747 | 761 |
748 | 762 |
749 enum StringIndexFlags { | 763 enum StringIndexFlags { |
750 // Accepts smis or heap numbers. | 764 // Accepts smis or heap numbers. |
751 STRING_INDEX_IS_NUMBER, | 765 STRING_INDEX_IS_NUMBER, |
752 | 766 |
753 // Accepts smis or heap numbers that are valid array indices | 767 // Accepts smis or heap numbers that are valid array indices |
754 // (ECMA-262 15.4). Invalid indices are reported as being out of | 768 // (ECMA-262 15.4). Invalid indices are reported as being out of |
755 // range. | 769 // range. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 void GenerateSlow(MacroAssembler* masm, | 909 void GenerateSlow(MacroAssembler* masm, |
896 const RuntimeCallHelper& call_helper); | 910 const RuntimeCallHelper& call_helper); |
897 | 911 |
898 private: | 912 private: |
899 StringCharCodeAtGenerator char_code_at_generator_; | 913 StringCharCodeAtGenerator char_code_at_generator_; |
900 StringCharFromCodeGenerator char_from_code_generator_; | 914 StringCharFromCodeGenerator char_from_code_generator_; |
901 | 915 |
902 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); | 916 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
903 }; | 917 }; |
904 | 918 |
| 919 |
| 920 class AllowStubCallsScope { |
| 921 public: |
| 922 AllowStubCallsScope(MacroAssembler* masm, bool allow) |
| 923 : masm_(masm), previous_allow_(masm->allow_stub_calls()) { |
| 924 masm_->set_allow_stub_calls(allow); |
| 925 } |
| 926 ~AllowStubCallsScope() { |
| 927 masm_->set_allow_stub_calls(previous_allow_); |
| 928 } |
| 929 |
| 930 private: |
| 931 MacroAssembler* masm_; |
| 932 bool previous_allow_; |
| 933 |
| 934 DISALLOW_COPY_AND_ASSIGN(AllowStubCallsScope); |
| 935 }; |
| 936 |
905 } } // namespace v8::internal | 937 } } // namespace v8::internal |
906 | 938 |
907 #endif // V8_CODE_STUBS_H_ | 939 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |