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 V(MathFloor) \ | |
98 /* IC Handler stubs */ \ | 97 /* IC Handler stubs */ \ |
99 V(ArrayBufferViewLoadField) \ | 98 V(ArrayBufferViewLoadField) \ |
100 V(LoadConstant) \ | 99 V(LoadConstant) \ |
101 V(LoadFastElement) \ | 100 V(LoadFastElement) \ |
102 V(LoadField) \ | 101 V(LoadField) \ |
102 V(MathFloor) \ | |
mvstanton
2015/07/08 09:42:29
Why is this now listed as an IC handler stub?
danno
2015/07/08 13:08:40
Done.
| |
103 V(KeyedLoadSloppyArguments) \ | 103 V(KeyedLoadSloppyArguments) \ |
104 V(KeyedStoreSloppyArguments) \ | 104 V(KeyedStoreSloppyArguments) \ |
105 V(StoreField) \ | 105 V(StoreField) \ |
106 V(StoreGlobal) \ | 106 V(StoreGlobal) \ |
107 V(StoreTransition) \ | 107 V(StoreTransition) \ |
108 V(StringLength) \ | 108 V(StringLength) \ |
109 V(RestParamAccess) | 109 V(RestParamAccess) |
110 | 110 |
111 // List of code stubs only used on ARM 32 bits platforms. | 111 // List of code stubs only used on ARM 32 bits platforms. |
112 #if V8_TARGET_ARCH_ARM | 112 #if V8_TARGET_ARCH_ARM |
(...skipping 96 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 | 209 // 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 | 210 // GC or if we try to put a stack frame on top of the junk, which would not |
211 // result in a traversable stack. | 211 // result in a traversable stack. |
212 virtual bool SometimesSetsUpAFrame() { return true; } | 212 virtual bool SometimesSetsUpAFrame() { return true; } |
213 | 213 |
214 // Lookup the code in the (possibly custom) cache. | 214 // Lookup the code in the (possibly custom) cache. |
215 bool FindCodeInCache(Code** code_out); | 215 bool FindCodeInCache(Code** code_out); |
216 | 216 |
217 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0; | 217 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0; |
218 | 218 |
219 virtual int GetStackParameterCount() const { return 0; } | 219 virtual int GetStackParameterCount() const { |
220 return GetCallInterfaceDescriptor().GetStackParameterCount(); | |
221 } | |
220 | 222 |
221 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} | 223 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} |
222 | 224 |
223 static void InitializeDescriptor(Isolate* isolate, uint32_t key, | 225 static void InitializeDescriptor(Isolate* isolate, uint32_t key, |
224 CodeStubDescriptor* desc); | 226 CodeStubDescriptor* desc); |
225 | 227 |
226 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); | 228 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); |
227 | 229 |
228 // Returns information for computing the number key. | 230 // Returns information for computing the number key. |
229 virtual Major MajorKey() const = 0; | 231 virtual Major MajorKey() const = 0; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 void Generate(MacroAssembler* masm) override; \ | 355 void Generate(MacroAssembler* masm) override; \ |
354 DEFINE_CODE_STUB(NAME, SUPER) | 356 DEFINE_CODE_STUB(NAME, SUPER) |
355 | 357 |
356 | 358 |
357 #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ | 359 #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ |
358 public: \ | 360 public: \ |
359 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ | 361 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ |
360 Handle<Code> GenerateCode() override; \ | 362 Handle<Code> GenerateCode() override; \ |
361 DEFINE_CODE_STUB(NAME, SUPER) | 363 DEFINE_CODE_STUB(NAME, SUPER) |
362 | 364 |
365 #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \ | |
366 public: \ | |
367 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ | |
368 return DESC##Descriptor(isolate()); \ | |
369 }; \ | |
370 DEFINE_CODE_STUB(NAME, SUPER) | |
371 | |
372 #define DEFINE_TURBOFAN_IC(NAME, SUPER, DESC) \ | |
373 public: \ | |
374 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ | |
375 if (GetCallMode() == CALL_FROM_OPTIMIZED_CODE) { \ | |
376 return DESC##CallFromOptimizedCodeDescriptor(isolate()); \ | |
377 } else { \ | |
378 return DESC##CallFromUnoptimizedCodeDescriptor(isolate()); \ | |
379 } \ | |
380 }; \ | |
381 \ | |
382 protected: \ | |
383 DEFINE_CODE_STUB(NAME, SUPER) | |
384 | |
363 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ | 385 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ |
364 public: \ | 386 public: \ |
365 Handle<Code> GenerateCode() override; \ | 387 Handle<Code> GenerateCode() override; \ |
366 DEFINE_CODE_STUB(NAME, SUPER) | 388 DEFINE_CODE_STUB(NAME, SUPER) |
367 | 389 |
368 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ | 390 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ |
369 public: \ | 391 public: \ |
370 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ | 392 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ |
371 return NAME##Descriptor(isolate()); \ | 393 return NAME##Descriptor(isolate()); \ |
372 } | 394 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 Code::StubType GetStubType() const override { return Code::FAST; } | 559 Code::StubType GetStubType() const override { return Code::FAST; } |
538 | 560 |
539 protected: | 561 protected: |
540 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} | 562 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} |
541 | 563 |
542 private: | 564 private: |
543 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); | 565 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); |
544 }; | 566 }; |
545 | 567 |
546 | 568 |
569 class TurboFanIC : public TurboFanCodeStub { | |
570 public: | |
571 enum CallMode { CALL_FROM_UNOPTIMIZED_CODE, CALL_FROM_OPTIMIZED_CODE }; | |
572 | |
573 protected: | |
574 explicit TurboFanIC(Isolate* isolate, CallMode mode) | |
575 : TurboFanCodeStub(isolate) { | |
576 minor_key_ = CallModeBits::encode(mode); | |
577 } | |
578 | |
579 CallMode GetCallMode() const { return CallModeBits::decode(minor_key_); } | |
580 | |
581 void set_sub_minor_key(uint32_t key) { | |
582 minor_key_ = SubMinorKeyBits::update(minor_key_, key); | |
583 } | |
584 | |
585 uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); } | |
586 | |
587 static const int kSubMinorKeyBits = kStubMinorKeyBits - 1; | |
588 | |
589 private: | |
590 class CallModeBits : public BitField<CallMode, 0, 1> {}; | |
591 class SubMinorKeyBits : public BitField<int, 1, kSubMinorKeyBits> {}; | |
592 DEFINE_CODE_STUB_BASE(TurboFanIC, TurboFanCodeStub); | |
593 }; | |
594 | |
595 | |
547 // Helper interface to prepare to/restore after making runtime calls. | 596 // Helper interface to prepare to/restore after making runtime calls. |
548 class RuntimeCallHelper { | 597 class RuntimeCallHelper { |
549 public: | 598 public: |
550 virtual ~RuntimeCallHelper() {} | 599 virtual ~RuntimeCallHelper() {} |
551 | 600 |
552 virtual void BeforeCall(MacroAssembler* masm) const = 0; | 601 virtual void BeforeCall(MacroAssembler* masm) const = 0; |
553 | 602 |
554 virtual void AfterCall(MacroAssembler* masm) const = 0; | 603 virtual void AfterCall(MacroAssembler* masm) const = 0; |
555 | 604 |
556 protected: | 605 protected: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 class NopRuntimeCallHelper : public RuntimeCallHelper { | 652 class NopRuntimeCallHelper : public RuntimeCallHelper { |
604 public: | 653 public: |
605 NopRuntimeCallHelper() {} | 654 NopRuntimeCallHelper() {} |
606 | 655 |
607 virtual void BeforeCall(MacroAssembler* masm) const {} | 656 virtual void BeforeCall(MacroAssembler* masm) const {} |
608 | 657 |
609 virtual void AfterCall(MacroAssembler* masm) const {} | 658 virtual void AfterCall(MacroAssembler* masm) const {} |
610 }; | 659 }; |
611 | 660 |
612 | 661 |
613 class MathFloorStub : public TurboFanCodeStub { | 662 class MathFloorStub : public TurboFanIC { |
614 public: | 663 public: |
615 explicit MathFloorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | 664 explicit MathFloorStub(Isolate* isolate, TurboFanIC::CallMode mode) |
616 int GetStackParameterCount() const override { return 1; } | 665 : TurboFanIC(isolate, mode) {} |
617 | 666 Code::Kind GetCodeKind() const override { return Code::CALL_IC; } |
618 DEFINE_CALL_INTERFACE_DESCRIPTOR(MathRoundVariant); | 667 DEFINE_TURBOFAN_IC(MathFloor, TurboFanIC, MathRoundVariant); |
619 DEFINE_CODE_STUB(MathFloor, TurboFanCodeStub); | |
620 }; | 668 }; |
621 | 669 |
622 | 670 |
623 class StringLengthTFStub : public TurboFanCodeStub { | 671 class StringLengthTFStub : public TurboFanCodeStub { |
624 public: | 672 public: |
625 explicit StringLengthTFStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | 673 explicit StringLengthTFStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
626 | 674 |
627 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 675 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
628 InlineCacheState GetICState() const override { return MONOMORPHIC; } | 676 InlineCacheState GetICState() const override { return MONOMORPHIC; } |
629 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } | 677 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 | 3034 #undef DEFINE_PLATFORM_CODE_STUB |
2987 #undef DEFINE_HANDLER_CODE_STUB | 3035 #undef DEFINE_HANDLER_CODE_STUB |
2988 #undef DEFINE_HYDROGEN_CODE_STUB | 3036 #undef DEFINE_HYDROGEN_CODE_STUB |
2989 #undef DEFINE_CODE_STUB | 3037 #undef DEFINE_CODE_STUB |
2990 #undef DEFINE_CODE_STUB_BASE | 3038 #undef DEFINE_CODE_STUB_BASE |
2991 | 3039 |
2992 extern Representation RepresentationFromType(Type* type); | 3040 extern Representation RepresentationFromType(Type* type); |
2993 } } // namespace v8::internal | 3041 } } // namespace v8::internal |
2994 | 3042 |
2995 #endif // V8_CODE_STUBS_H_ | 3043 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |