OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 V(StoreFastElement) \ | 87 V(StoreFastElement) \ |
88 V(StoreScriptContextField) \ | 88 V(StoreScriptContextField) \ |
89 V(StringAdd) \ | 89 V(StringAdd) \ |
90 V(ToBoolean) \ | 90 V(ToBoolean) \ |
91 V(TransitionElementsKind) \ | 91 V(TransitionElementsKind) \ |
92 V(KeyedLoadIC) \ | 92 V(KeyedLoadIC) \ |
93 V(LoadIC) \ | 93 V(LoadIC) \ |
94 /* TurboFanCodeStubs */ \ | 94 /* TurboFanCodeStubs */ \ |
95 V(StringLengthTF) \ | 95 V(StringLengthTF) \ |
96 V(StringAddTF) \ | 96 V(StringAddTF) \ |
| 97 /* TurboFanICs */ \ |
97 V(MathFloor) \ | 98 V(MathFloor) \ |
98 /* IC Handler stubs */ \ | 99 /* IC Handler stubs */ \ |
99 V(ArrayBufferViewLoadField) \ | 100 V(ArrayBufferViewLoadField) \ |
100 V(LoadConstant) \ | 101 V(LoadConstant) \ |
101 V(LoadFastElement) \ | 102 V(LoadFastElement) \ |
102 V(LoadField) \ | 103 V(LoadField) \ |
103 V(KeyedLoadSloppyArguments) \ | 104 V(KeyedLoadSloppyArguments) \ |
104 V(KeyedStoreSloppyArguments) \ | 105 V(KeyedStoreSloppyArguments) \ |
105 V(StoreField) \ | 106 V(StoreField) \ |
106 V(StoreGlobal) \ | 107 V(StoreGlobal) \ |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // true, which will cause an assertion if we try to call something that can | 210 // true, which will cause an assertion if we try to call something that can |
210 // GC or if we try to put a stack frame on top of the junk, which would not | 211 // GC or if we try to put a stack frame on top of the junk, which would not |
211 // result in a traversable stack. | 212 // result in a traversable stack. |
212 virtual bool SometimesSetsUpAFrame() { return true; } | 213 virtual bool SometimesSetsUpAFrame() { return true; } |
213 | 214 |
214 // Lookup the code in the (possibly custom) cache. | 215 // Lookup the code in the (possibly custom) cache. |
215 bool FindCodeInCache(Code** code_out); | 216 bool FindCodeInCache(Code** code_out); |
216 | 217 |
217 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0; | 218 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0; |
218 | 219 |
219 virtual int GetStackParameterCount() const { return 0; } | 220 virtual int GetStackParameterCount() const { |
| 221 return GetCallInterfaceDescriptor().GetStackParameterCount(); |
| 222 } |
220 | 223 |
221 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} | 224 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} |
222 | 225 |
223 static void InitializeDescriptor(Isolate* isolate, uint32_t key, | 226 static void InitializeDescriptor(Isolate* isolate, uint32_t key, |
224 CodeStubDescriptor* desc); | 227 CodeStubDescriptor* desc); |
225 | 228 |
226 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); | 229 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); |
227 | 230 |
228 // Returns information for computing the number key. | 231 // Returns information for computing the number key. |
229 virtual Major MajorKey() const = 0; | 232 virtual Major MajorKey() const = 0; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 void Generate(MacroAssembler* masm) override; \ | 356 void Generate(MacroAssembler* masm) override; \ |
354 DEFINE_CODE_STUB(NAME, SUPER) | 357 DEFINE_CODE_STUB(NAME, SUPER) |
355 | 358 |
356 | 359 |
357 #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ | 360 #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ |
358 public: \ | 361 public: \ |
359 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ | 362 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ |
360 Handle<Code> GenerateCode() override; \ | 363 Handle<Code> GenerateCode() override; \ |
361 DEFINE_CODE_STUB(NAME, SUPER) | 364 DEFINE_CODE_STUB(NAME, SUPER) |
362 | 365 |
| 366 #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \ |
| 367 public: \ |
| 368 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ |
| 369 return DESC##Descriptor(isolate()); \ |
| 370 }; \ |
| 371 DEFINE_CODE_STUB(NAME, SUPER) |
| 372 |
| 373 #define DEFINE_TURBOFAN_IC(NAME, SUPER, DESC) \ |
| 374 public: \ |
| 375 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ |
| 376 if (GetCallMode() == CALL_FROM_OPTIMIZED_CODE) { \ |
| 377 return DESC##CallFromOptimizedCodeDescriptor(isolate()); \ |
| 378 } else { \ |
| 379 return DESC##CallFromUnoptimizedCodeDescriptor(isolate()); \ |
| 380 } \ |
| 381 }; \ |
| 382 \ |
| 383 protected: \ |
| 384 DEFINE_CODE_STUB(NAME, SUPER) |
| 385 |
363 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ | 386 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ |
364 public: \ | 387 public: \ |
365 Handle<Code> GenerateCode() override; \ | 388 Handle<Code> GenerateCode() override; \ |
366 DEFINE_CODE_STUB(NAME, SUPER) | 389 DEFINE_CODE_STUB(NAME, SUPER) |
367 | 390 |
368 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ | 391 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ |
369 public: \ | 392 public: \ |
370 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ | 393 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ |
371 return NAME##Descriptor(isolate()); \ | 394 return NAME##Descriptor(isolate()); \ |
372 } | 395 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 Code::StubType GetStubType() const override { return Code::FAST; } | 560 Code::StubType GetStubType() const override { return Code::FAST; } |
538 | 561 |
539 protected: | 562 protected: |
540 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} | 563 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} |
541 | 564 |
542 private: | 565 private: |
543 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); | 566 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); |
544 }; | 567 }; |
545 | 568 |
546 | 569 |
| 570 class TurboFanIC : public TurboFanCodeStub { |
| 571 public: |
| 572 enum CallMode { CALL_FROM_UNOPTIMIZED_CODE, CALL_FROM_OPTIMIZED_CODE }; |
| 573 |
| 574 protected: |
| 575 explicit TurboFanIC(Isolate* isolate, CallMode mode) |
| 576 : TurboFanCodeStub(isolate) { |
| 577 minor_key_ = CallModeBits::encode(mode); |
| 578 } |
| 579 |
| 580 CallMode GetCallMode() const { return CallModeBits::decode(minor_key_); } |
| 581 |
| 582 void set_sub_minor_key(uint32_t key) { |
| 583 minor_key_ = SubMinorKeyBits::update(minor_key_, key); |
| 584 } |
| 585 |
| 586 uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); } |
| 587 |
| 588 static const int kSubMinorKeyBits = kStubMinorKeyBits - 1; |
| 589 |
| 590 private: |
| 591 class CallModeBits : public BitField<CallMode, 0, 1> {}; |
| 592 class SubMinorKeyBits : public BitField<int, 1, kSubMinorKeyBits> {}; |
| 593 DEFINE_CODE_STUB_BASE(TurboFanIC, TurboFanCodeStub); |
| 594 }; |
| 595 |
| 596 |
547 // Helper interface to prepare to/restore after making runtime calls. | 597 // Helper interface to prepare to/restore after making runtime calls. |
548 class RuntimeCallHelper { | 598 class RuntimeCallHelper { |
549 public: | 599 public: |
550 virtual ~RuntimeCallHelper() {} | 600 virtual ~RuntimeCallHelper() {} |
551 | 601 |
552 virtual void BeforeCall(MacroAssembler* masm) const = 0; | 602 virtual void BeforeCall(MacroAssembler* masm) const = 0; |
553 | 603 |
554 virtual void AfterCall(MacroAssembler* masm) const = 0; | 604 virtual void AfterCall(MacroAssembler* masm) const = 0; |
555 | 605 |
556 protected: | 606 protected: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 class NopRuntimeCallHelper : public RuntimeCallHelper { | 653 class NopRuntimeCallHelper : public RuntimeCallHelper { |
604 public: | 654 public: |
605 NopRuntimeCallHelper() {} | 655 NopRuntimeCallHelper() {} |
606 | 656 |
607 virtual void BeforeCall(MacroAssembler* masm) const {} | 657 virtual void BeforeCall(MacroAssembler* masm) const {} |
608 | 658 |
609 virtual void AfterCall(MacroAssembler* masm) const {} | 659 virtual void AfterCall(MacroAssembler* masm) const {} |
610 }; | 660 }; |
611 | 661 |
612 | 662 |
613 class MathFloorStub : public TurboFanCodeStub { | 663 class MathFloorStub : public TurboFanIC { |
614 public: | 664 public: |
615 explicit MathFloorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | 665 explicit MathFloorStub(Isolate* isolate, TurboFanIC::CallMode mode) |
616 int GetStackParameterCount() const override { return 1; } | 666 : TurboFanIC(isolate, mode) {} |
617 | 667 Code::Kind GetCodeKind() const override { return Code::CALL_IC; } |
618 DEFINE_CALL_INTERFACE_DESCRIPTOR(MathRoundVariant); | 668 DEFINE_TURBOFAN_IC(MathFloor, TurboFanIC, MathRoundVariant); |
619 DEFINE_CODE_STUB(MathFloor, TurboFanCodeStub); | |
620 }; | 669 }; |
621 | 670 |
622 | 671 |
623 class StringLengthTFStub : public TurboFanCodeStub { | 672 class StringLengthTFStub : public TurboFanCodeStub { |
624 public: | 673 public: |
625 explicit StringLengthTFStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | 674 explicit StringLengthTFStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
626 | 675 |
627 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 676 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
628 InlineCacheState GetICState() const override { return MONOMORPHIC; } | 677 InlineCacheState GetICState() const override { return MONOMORPHIC; } |
629 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } | 678 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
(...skipping 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 #undef DEFINE_PLATFORM_CODE_STUB | 3035 #undef DEFINE_PLATFORM_CODE_STUB |
2987 #undef DEFINE_HANDLER_CODE_STUB | 3036 #undef DEFINE_HANDLER_CODE_STUB |
2988 #undef DEFINE_HYDROGEN_CODE_STUB | 3037 #undef DEFINE_HYDROGEN_CODE_STUB |
2989 #undef DEFINE_CODE_STUB | 3038 #undef DEFINE_CODE_STUB |
2990 #undef DEFINE_CODE_STUB_BASE | 3039 #undef DEFINE_CODE_STUB_BASE |
2991 | 3040 |
2992 extern Representation RepresentationFromType(Type* type); | 3041 extern Representation RepresentationFromType(Type* type); |
2993 } } // namespace v8::internal | 3042 } } // namespace v8::internal |
2994 | 3043 |
2995 #endif // V8_CODE_STUBS_H_ | 3044 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |