| 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(StoreBufferOverflow) \ | 50 V(StoreBufferOverflow) \ |
| 51 V(TranscendentalCache) \ | 51 V(TranscendentalCache) \ |
| 52 V(RecordWrite) \ | 52 V(Instanceof) \ |
| 53 V(ConvertToDouble) \ | 53 V(ConvertToDouble) \ |
| 54 V(WriteInt32ToHeapNumber) \ | 54 V(WriteInt32ToHeapNumber) \ |
| 55 V(IntegerMod) \ | 55 V(IntegerMod) \ |
| 56 V(StackCheck) \ | 56 V(StackCheck) \ |
| 57 V(FastNewClosure) \ | 57 V(FastNewClosure) \ |
| 58 V(FastNewContext) \ | 58 V(FastNewContext) \ |
| 59 V(FastCloneShallowArray) \ | 59 V(FastCloneShallowArray) \ |
| 60 V(GenericUnaryOp) \ | 60 V(GenericUnaryOp) \ |
| 61 V(RevertToNumber) \ | 61 V(RevertToNumber) \ |
| 62 V(ToBoolean) \ | 62 V(ToBoolean) \ |
| 63 V(Instanceof) \ | 63 V(ToNumber) \ |
| 64 V(CounterOp) \ | 64 V(CounterOp) \ |
| 65 V(ArgumentsAccess) \ | 65 V(ArgumentsAccess) \ |
| 66 V(RegExpExec) \ | 66 V(RegExpExec) \ |
| 67 V(RegExpConstructResult) \ | 67 V(RegExpConstructResult) \ |
| 68 V(NumberToString) \ | 68 V(NumberToString) \ |
| 69 V(CEntry) \ | 69 V(CEntry) \ |
| 70 V(JSEntry) \ | 70 V(JSEntry) \ |
| 71 V(DebuggerStatement) | 71 V(DebuggerStatement) |
| 72 | 72 |
| 73 // List of code stubs only used on ARM platforms. | 73 // List of code stubs only used on ARM platforms. |
| 74 #ifdef V8_TARGET_ARCH_ARM | 74 #ifdef V8_TARGET_ARCH_ARM |
| 75 #define CODE_STUB_LIST_ARM(V) \ | 75 #define CODE_STUB_LIST_ARM(V) \ |
| 76 V(GetProperty) \ | 76 V(GetProperty) \ |
| 77 V(SetProperty) \ | 77 V(SetProperty) \ |
| 78 V(InvokeBuiltin) \ | 78 V(InvokeBuiltin) \ |
| 79 V(RegExpCEntry) | 79 V(RegExpCEntry) \ |
| 80 V(DirectCEntry) |
| 80 #else | 81 #else |
| 81 #define CODE_STUB_LIST_ARM(V) | 82 #define CODE_STUB_LIST_ARM(V) |
| 82 #endif | 83 #endif |
| 83 | 84 |
| 84 // Combined list of code stubs. | 85 // Combined list of code stubs. |
| 85 #define CODE_STUB_LIST(V) \ | 86 #define CODE_STUB_LIST(V) \ |
| 86 CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 87 CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 87 CODE_STUB_LIST_ARM(V) | 88 CODE_STUB_LIST_ARM(V) |
| 88 | 89 |
| 89 // Types of uncatchable exceptions. | |
| 90 enum UncatchableExceptionType { OUT_OF_MEMORY, TERMINATION }; | |
| 91 | |
| 92 // Mode to overwrite BinaryExpression values. | 90 // Mode to overwrite BinaryExpression values. |
| 93 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; | 91 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; |
| 94 enum UnaryOverwriteMode { UNARY_OVERWRITE, UNARY_NO_OVERWRITE }; | 92 enum UnaryOverwriteMode { UNARY_OVERWRITE, UNARY_NO_OVERWRITE }; |
| 95 | 93 |
| 96 | 94 |
| 97 // Stub is base classes of all stubs. | 95 // Stub is base classes of all stubs. |
| 98 class CodeStub BASE_EMBEDDED { | 96 class CodeStub BASE_EMBEDDED { |
| 99 public: | 97 public: |
| 100 enum Major { | 98 enum Major { |
| 101 #define DEF_ENUM(name) name, | 99 #define DEF_ENUM(name) name, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 virtual void Print() { PrintF("%s\n", GetName()); } | 172 virtual void Print() { PrintF("%s\n", GetName()); } |
| 175 #endif | 173 #endif |
| 176 | 174 |
| 177 // Computes the key based on major and minor. | 175 // Computes the key based on major and minor. |
| 178 uint32_t GetKey() { | 176 uint32_t GetKey() { |
| 179 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); | 177 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
| 180 return MinorKeyBits::encode(MinorKey()) | | 178 return MinorKeyBits::encode(MinorKey()) | |
| 181 MajorKeyBits::encode(MajorKey()); | 179 MajorKeyBits::encode(MajorKey()); |
| 182 } | 180 } |
| 183 | 181 |
| 184 bool AllowsStubCalls() { return MajorKey() <= RecordWrite; } | 182 bool AllowsStubCalls() { return MajorKey() <= Instanceof; } |
| 185 | 183 |
| 186 class MajorKeyBits: public BitField<uint32_t, 0, kMajorBits> {}; | 184 class MajorKeyBits: public BitField<uint32_t, 0, kMajorBits> {}; |
| 187 class MinorKeyBits: public BitField<uint32_t, kMajorBits, kMinorBits> {}; | 185 class MinorKeyBits: public BitField<uint32_t, kMajorBits, kMinorBits> {}; |
| 188 | 186 |
| 189 friend class BreakPointIterator; | 187 friend class BreakPointIterator; |
| 190 }; | 188 }; |
| 191 | 189 |
| 192 | 190 |
| 193 // Helper interface to prepare to/restore after making runtime calls. | 191 // Helper interface to prepare to/restore after making runtime calls. |
| 194 class RuntimeCallHelper { | 192 class RuntimeCallHelper { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 253 |
| 256 private: | 254 private: |
| 257 | 255 |
| 258 const char* GetName() { return "StackCheckStub"; } | 256 const char* GetName() { return "StackCheckStub"; } |
| 259 | 257 |
| 260 Major MajorKey() { return StackCheck; } | 258 Major MajorKey() { return StackCheck; } |
| 261 int MinorKey() { return 0; } | 259 int MinorKey() { return 0; } |
| 262 }; | 260 }; |
| 263 | 261 |
| 264 | 262 |
| 263 class ToNumberStub: public CodeStub { |
| 264 public: |
| 265 ToNumberStub() { } |
| 266 |
| 267 void Generate(MacroAssembler* masm); |
| 268 |
| 269 private: |
| 270 Major MajorKey() { return ToNumber; } |
| 271 int MinorKey() { return 0; } |
| 272 const char* GetName() { return "ToNumberStub"; } |
| 273 }; |
| 274 |
| 275 |
| 265 class FastNewClosureStub : public CodeStub { | 276 class FastNewClosureStub : public CodeStub { |
| 266 public: | 277 public: |
| 267 void Generate(MacroAssembler* masm); | 278 void Generate(MacroAssembler* masm); |
| 268 | 279 |
| 269 private: | 280 private: |
| 270 const char* GetName() { return "FastNewClosureStub"; } | 281 const char* GetName() { return "FastNewClosureStub"; } |
| 271 Major MajorKey() { return FastNewClosure; } | 282 Major MajorKey() { return FastNewClosure; } |
| 272 int MinorKey() { return 0; } | 283 int MinorKey() { return 0; } |
| 273 }; | 284 }; |
| 274 | 285 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 ASSERT(mode_ == 0 || mode_ == 1); | 332 ASSERT(mode_ == 0 || mode_ == 1); |
| 322 return (length_ << 1) | mode_; | 333 return (length_ << 1) | mode_; |
| 323 } | 334 } |
| 324 }; | 335 }; |
| 325 | 336 |
| 326 | 337 |
| 327 class InstanceofStub: public CodeStub { | 338 class InstanceofStub: public CodeStub { |
| 328 public: | 339 public: |
| 329 enum Flags { | 340 enum Flags { |
| 330 kNoFlags = 0, | 341 kNoFlags = 0, |
| 331 kArgsInRegisters = 1 << 0 | 342 kArgsInRegisters = 1 << 0, |
| 343 kCallSiteInlineCheck = 1 << 1, |
| 344 kReturnTrueFalseObject = 1 << 2 |
| 332 }; | 345 }; |
| 333 | 346 |
| 334 explicit InstanceofStub(Flags flags) : flags_(flags) { } | 347 explicit InstanceofStub(Flags flags) : flags_(flags), name_(NULL) { } |
| 348 |
| 349 static Register left(); |
| 350 static Register right(); |
| 335 | 351 |
| 336 void Generate(MacroAssembler* masm); | 352 void Generate(MacroAssembler* masm); |
| 337 | 353 |
| 338 private: | 354 private: |
| 339 Major MajorKey() { return Instanceof; } | 355 Major MajorKey() { return Instanceof; } |
| 340 int MinorKey() { return args_in_registers() ? 1 : 0; } | 356 int MinorKey() { return static_cast<int>(flags_); } |
| 341 | 357 |
| 342 bool args_in_registers() { | 358 bool HasArgsInRegisters() const { |
| 343 return (flags_ & kArgsInRegisters) != 0; | 359 return (flags_ & kArgsInRegisters) != 0; |
| 344 } | 360 } |
| 345 | 361 |
| 362 bool HasCallSiteInlineCheck() const { |
| 363 return (flags_ & kCallSiteInlineCheck) != 0; |
| 364 } |
| 365 |
| 366 bool ReturnTrueFalseObject() const { |
| 367 return (flags_ & kReturnTrueFalseObject) != 0; |
| 368 } |
| 369 |
| 370 const char* GetName(); |
| 371 |
| 346 Flags flags_; | 372 Flags flags_; |
| 373 char* name_; |
| 347 }; | 374 }; |
| 348 | 375 |
| 349 | 376 |
| 350 enum NegativeZeroHandling { | 377 enum NegativeZeroHandling { |
| 351 kStrictNegativeZero, | 378 kStrictNegativeZero, |
| 352 kIgnoreNegativeZero | 379 kIgnoreNegativeZero |
| 353 }; | 380 }; |
| 354 | 381 |
| 355 | 382 |
| 356 enum UnaryOpFlags { | 383 enum UnaryOpFlags { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 : result_size_(result_size), save_doubles_(save_doubles) { } | 605 : result_size_(result_size), save_doubles_(save_doubles) { } |
| 579 | 606 |
| 580 void Generate(MacroAssembler* masm); | 607 void Generate(MacroAssembler* masm); |
| 581 | 608 |
| 582 private: | 609 private: |
| 583 void GenerateCore(MacroAssembler* masm, | 610 void GenerateCore(MacroAssembler* masm, |
| 584 Label* throw_normal_exception, | 611 Label* throw_normal_exception, |
| 585 Label* throw_termination_exception, | 612 Label* throw_termination_exception, |
| 586 Label* throw_out_of_memory_exception, | 613 Label* throw_out_of_memory_exception, |
| 587 bool do_gc, | 614 bool do_gc, |
| 588 bool always_allocate_scope, | 615 bool always_allocate_scope); |
| 589 int alignment_skew = 0); | |
| 590 void GenerateThrowTOS(MacroAssembler* masm); | 616 void GenerateThrowTOS(MacroAssembler* masm); |
| 591 void GenerateThrowUncatchable(MacroAssembler* masm, | 617 void GenerateThrowUncatchable(MacroAssembler* masm, |
| 592 UncatchableExceptionType type); | 618 UncatchableExceptionType type); |
| 593 | 619 |
| 594 // Number of pointers/values returned. | 620 // Number of pointers/values returned. |
| 595 const int result_size_; | 621 const int result_size_; |
| 596 SaveFPRegsMode save_doubles_; | 622 SaveFPRegsMode save_doubles_; |
| 597 | 623 |
| 598 Major MajorKey() { return CEntry; } | 624 Major MajorKey() { return CEntry; } |
| 599 int MinorKey(); | 625 int MinorKey(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 }; | 727 }; |
| 702 | 728 |
| 703 | 729 |
| 704 class CallFunctionStub: public CodeStub { | 730 class CallFunctionStub: public CodeStub { |
| 705 public: | 731 public: |
| 706 CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags) | 732 CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags) |
| 707 : argc_(argc), in_loop_(in_loop), flags_(flags) { } | 733 : argc_(argc), in_loop_(in_loop), flags_(flags) { } |
| 708 | 734 |
| 709 void Generate(MacroAssembler* masm); | 735 void Generate(MacroAssembler* masm); |
| 710 | 736 |
| 737 static int ExtractArgcFromMinorKey(int minor_key) { |
| 738 return ArgcBits::decode(minor_key); |
| 739 } |
| 740 |
| 711 private: | 741 private: |
| 712 int argc_; | 742 int argc_; |
| 713 InLoopFlag in_loop_; | 743 InLoopFlag in_loop_; |
| 714 CallFunctionFlags flags_; | 744 CallFunctionFlags flags_; |
| 715 | 745 |
| 716 #ifdef DEBUG | 746 #ifdef DEBUG |
| 717 void Print() { | 747 void Print() { |
| 718 PrintF("CallFunctionStub (args %d, in_loop %d, flags %d)\n", | 748 PrintF("CallFunctionStub (args %d, in_loop %d, flags %d)\n", |
| 719 argc_, | 749 argc_, |
| 720 static_cast<int>(in_loop_), | 750 static_cast<int>(in_loop_), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 732 // Encode the parameters in a unique 32 bit value. | 762 // Encode the parameters in a unique 32 bit value. |
| 733 return InLoopBits::encode(in_loop_) | 763 return InLoopBits::encode(in_loop_) |
| 734 | FlagBits::encode(flags_) | 764 | FlagBits::encode(flags_) |
| 735 | ArgcBits::encode(argc_); | 765 | ArgcBits::encode(argc_); |
| 736 } | 766 } |
| 737 | 767 |
| 738 InLoopFlag InLoop() { return in_loop_; } | 768 InLoopFlag InLoop() { return in_loop_; } |
| 739 bool ReceiverMightBeValue() { | 769 bool ReceiverMightBeValue() { |
| 740 return (flags_ & RECEIVER_MIGHT_BE_VALUE) != 0; | 770 return (flags_ & RECEIVER_MIGHT_BE_VALUE) != 0; |
| 741 } | 771 } |
| 742 | |
| 743 public: | |
| 744 static int ExtractArgcFromMinorKey(int minor_key) { | |
| 745 return ArgcBits::decode(minor_key); | |
| 746 } | |
| 747 }; | 772 }; |
| 748 | 773 |
| 749 | 774 |
| 750 enum StringIndexFlags { | 775 enum StringIndexFlags { |
| 751 // Accepts smis or heap numbers. | 776 // Accepts smis or heap numbers. |
| 752 STRING_INDEX_IS_NUMBER, | 777 STRING_INDEX_IS_NUMBER, |
| 753 | 778 |
| 754 // Accepts smis or heap numbers that are valid array indices | 779 // Accepts smis or heap numbers that are valid array indices |
| 755 // (ECMA-262 15.4). Invalid indices are reported as being out of | 780 // (ECMA-262 15.4). Invalid indices are reported as being out of |
| 756 // range. | 781 // range. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 void GenerateSlow(MacroAssembler* masm, | 921 void GenerateSlow(MacroAssembler* masm, |
| 897 const RuntimeCallHelper& call_helper); | 922 const RuntimeCallHelper& call_helper); |
| 898 | 923 |
| 899 private: | 924 private: |
| 900 StringCharCodeAtGenerator char_code_at_generator_; | 925 StringCharCodeAtGenerator char_code_at_generator_; |
| 901 StringCharFromCodeGenerator char_from_code_generator_; | 926 StringCharFromCodeGenerator char_from_code_generator_; |
| 902 | 927 |
| 903 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); | 928 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
| 904 }; | 929 }; |
| 905 | 930 |
| 931 |
| 932 class AllowStubCallsScope { |
| 933 public: |
| 934 AllowStubCallsScope(MacroAssembler* masm, bool allow) |
| 935 : masm_(masm), previous_allow_(masm->allow_stub_calls()) { |
| 936 masm_->set_allow_stub_calls(allow); |
| 937 } |
| 938 ~AllowStubCallsScope() { |
| 939 masm_->set_allow_stub_calls(previous_allow_); |
| 940 } |
| 941 |
| 942 private: |
| 943 MacroAssembler* masm_; |
| 944 bool previous_allow_; |
| 945 |
| 946 DISALLOW_COPY_AND_ASSIGN(AllowStubCallsScope); |
| 947 }; |
| 948 |
| 906 } } // namespace v8::internal | 949 } } // namespace v8::internal |
| 907 | 950 |
| 908 #endif // V8_CODE_STUBS_H_ | 951 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |