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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 V(NameDictionaryLookup) \ | 81 V(NameDictionaryLookup) \ |
82 V(NumberToString) \ | 82 V(NumberToString) \ |
83 V(RegExpConstructResult) \ | 83 V(RegExpConstructResult) \ |
84 V(StoreFastElement) \ | 84 V(StoreFastElement) \ |
85 V(StoreScriptContextField) \ | 85 V(StoreScriptContextField) \ |
86 V(StringAdd) \ | 86 V(StringAdd) \ |
87 V(ToBoolean) \ | 87 V(ToBoolean) \ |
88 V(TransitionElementsKind) \ | 88 V(TransitionElementsKind) \ |
89 V(VectorRawKeyedLoad) \ | 89 V(VectorRawKeyedLoad) \ |
90 V(VectorRawLoad) \ | 90 V(VectorRawLoad) \ |
| 91 /* TurboFanCodeStubs */ \ |
| 92 V(StringLengthTF) \ |
| 93 V(MathFloor) \ |
91 /* IC Handler stubs */ \ | 94 /* IC Handler stubs */ \ |
92 V(ArrayBufferViewLoadField) \ | 95 V(ArrayBufferViewLoadField) \ |
93 V(LoadConstant) \ | 96 V(LoadConstant) \ |
94 V(LoadField) \ | 97 V(LoadField) \ |
95 V(KeyedLoadSloppyArguments) \ | 98 V(KeyedLoadSloppyArguments) \ |
96 V(StoreField) \ | 99 V(StoreField) \ |
97 V(StoreGlobal) \ | 100 V(StoreGlobal) \ |
98 V(StoreTransition) \ | 101 V(StoreTransition) \ |
99 V(StringLength) \ | 102 V(StringLength) \ |
100 V(RestParamAccess) | 103 V(RestParamAccess) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 #endif | 147 #endif |
145 | 148 |
146 // Combined list of code stubs. | 149 // Combined list of code stubs. |
147 #define CODE_STUB_LIST(V) \ | 150 #define CODE_STUB_LIST(V) \ |
148 CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 151 CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
149 CODE_STUB_LIST_ARM(V) \ | 152 CODE_STUB_LIST_ARM(V) \ |
150 CODE_STUB_LIST_ARM64(V) \ | 153 CODE_STUB_LIST_ARM64(V) \ |
151 CODE_STUB_LIST_PPC(V) \ | 154 CODE_STUB_LIST_PPC(V) \ |
152 CODE_STUB_LIST_MIPS(V) | 155 CODE_STUB_LIST_MIPS(V) |
153 | 156 |
| 157 static const int kHasReturnedMinusZeroSentinel = 1; |
| 158 |
154 // Stub is base classes of all stubs. | 159 // Stub is base classes of all stubs. |
155 class CodeStub BASE_EMBEDDED { | 160 class CodeStub BASE_EMBEDDED { |
156 public: | 161 public: |
157 enum Major { | 162 enum Major { |
158 // TODO(mvstanton): eliminate the NoCache key by getting rid | 163 // TODO(mvstanton): eliminate the NoCache key by getting rid |
159 // of the non-monomorphic-cache. | 164 // of the non-monomorphic-cache. |
160 NoCache = 0, // marker for stubs that do custom caching] | 165 NoCache = 0, // marker for stubs that do custom caching] |
161 #define DEF_ENUM(name) name, | 166 #define DEF_ENUM(name) name, |
162 CODE_STUB_LIST(DEF_ENUM) | 167 CODE_STUB_LIST(DEF_ENUM) |
163 #undef DEF_ENUM | 168 #undef DEF_ENUM |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // true, which will cause an assertion if we try to call something that can | 203 // true, which will cause an assertion if we try to call something that can |
199 // GC or if we try to put a stack frame on top of the junk, which would not | 204 // GC or if we try to put a stack frame on top of the junk, which would not |
200 // result in a traversable stack. | 205 // result in a traversable stack. |
201 virtual bool SometimesSetsUpAFrame() { return true; } | 206 virtual bool SometimesSetsUpAFrame() { return true; } |
202 | 207 |
203 // Lookup the code in the (possibly custom) cache. | 208 // Lookup the code in the (possibly custom) cache. |
204 bool FindCodeInCache(Code** code_out); | 209 bool FindCodeInCache(Code** code_out); |
205 | 210 |
206 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() = 0; | 211 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() = 0; |
207 | 212 |
| 213 virtual int GetStackParameterCount() const { return 0; } |
| 214 |
208 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} | 215 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} |
209 | 216 |
210 static void InitializeDescriptor(Isolate* isolate, uint32_t key, | 217 static void InitializeDescriptor(Isolate* isolate, uint32_t key, |
211 CodeStubDescriptor* desc); | 218 CodeStubDescriptor* desc); |
212 | 219 |
213 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); | 220 static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); |
214 | 221 |
215 // Returns information for computing the number key. | 222 // Returns information for computing the number key. |
216 virtual Major MajorKey() const = 0; | 223 virtual Major MajorKey() const = 0; |
217 uint32_t MinorKey() const { return minor_key_; } | 224 uint32_t MinorKey() const { return minor_key_; } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 void Generate(MacroAssembler* masm) override; \ | 347 void Generate(MacroAssembler* masm) override; \ |
341 DEFINE_CODE_STUB(NAME, SUPER) | 348 DEFINE_CODE_STUB(NAME, SUPER) |
342 | 349 |
343 | 350 |
344 #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ | 351 #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ |
345 public: \ | 352 public: \ |
346 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ | 353 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ |
347 Handle<Code> GenerateCode() override; \ | 354 Handle<Code> GenerateCode() override; \ |
348 DEFINE_CODE_STUB(NAME, SUPER) | 355 DEFINE_CODE_STUB(NAME, SUPER) |
349 | 356 |
| 357 #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER, DESC, STACK_PARAMS) \ |
| 358 public: \ |
| 359 NAME##Stub(Isolate* isolate) : SUPER(isolate) {} \ |
| 360 CallInterfaceDescriptor GetCallInterfaceDescriptor() override { \ |
| 361 return DESC(isolate()); \ |
| 362 }; \ |
| 363 virtual const char* GetFunctionName() const override { \ |
| 364 return #NAME "_STUB"; \ |
| 365 } \ |
| 366 int GetStackParameterCount() const override { return STACK_PARAMS; } \ |
| 367 Code::StubType GetStubType() const override { return Code::FAST; } \ |
| 368 DEFINE_CODE_STUB(NAME, SUPER); |
| 369 |
350 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ | 370 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ |
351 public: \ | 371 public: \ |
352 Handle<Code> GenerateCode() override; \ | 372 Handle<Code> GenerateCode() override; \ |
353 DEFINE_CODE_STUB(NAME, SUPER) | 373 DEFINE_CODE_STUB(NAME, SUPER) |
354 | 374 |
355 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ | 375 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ |
356 public: \ | 376 public: \ |
357 CallInterfaceDescriptor GetCallInterfaceDescriptor() override { \ | 377 CallInterfaceDescriptor GetCallInterfaceDescriptor() override { \ |
358 return NAME##Descriptor(isolate()); \ | 378 return NAME##Descriptor(isolate()); \ |
359 } | 379 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 private: | 530 private: |
511 class IsMissBits : public BitField<bool, kSubMinorKeyBits, 1> {}; | 531 class IsMissBits : public BitField<bool, kSubMinorKeyBits, 1> {}; |
512 class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {}; | 532 class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {}; |
513 | 533 |
514 void GenerateLightweightMiss(MacroAssembler* masm, ExternalReference miss); | 534 void GenerateLightweightMiss(MacroAssembler* masm, ExternalReference miss); |
515 | 535 |
516 DEFINE_CODE_STUB_BASE(HydrogenCodeStub, CodeStub); | 536 DEFINE_CODE_STUB_BASE(HydrogenCodeStub, CodeStub); |
517 }; | 537 }; |
518 | 538 |
519 | 539 |
| 540 class TurboFanCodeStub : public CodeStub { |
| 541 public: |
| 542 Code::Kind GetCodeKind() const override { return Code::STUB; } |
| 543 |
| 544 // Retrieve the code for the stub. Generate the code if needed. |
| 545 Handle<Code> GenerateCode() override; |
| 546 |
| 547 virtual const char* GetFunctionName() const = 0; |
| 548 |
| 549 protected: |
| 550 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} |
| 551 |
| 552 private: |
| 553 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); |
| 554 }; |
| 555 |
| 556 |
520 // Helper interface to prepare to/restore after making runtime calls. | 557 // Helper interface to prepare to/restore after making runtime calls. |
521 class RuntimeCallHelper { | 558 class RuntimeCallHelper { |
522 public: | 559 public: |
523 virtual ~RuntimeCallHelper() {} | 560 virtual ~RuntimeCallHelper() {} |
524 | 561 |
525 virtual void BeforeCall(MacroAssembler* masm) const = 0; | 562 virtual void BeforeCall(MacroAssembler* masm) const = 0; |
526 | 563 |
527 virtual void AfterCall(MacroAssembler* masm) const = 0; | 564 virtual void AfterCall(MacroAssembler* masm) const = 0; |
528 | 565 |
529 protected: | 566 protected: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 class NopRuntimeCallHelper : public RuntimeCallHelper { | 613 class NopRuntimeCallHelper : public RuntimeCallHelper { |
577 public: | 614 public: |
578 NopRuntimeCallHelper() {} | 615 NopRuntimeCallHelper() {} |
579 | 616 |
580 virtual void BeforeCall(MacroAssembler* masm) const {} | 617 virtual void BeforeCall(MacroAssembler* masm) const {} |
581 | 618 |
582 virtual void AfterCall(MacroAssembler* masm) const {} | 619 virtual void AfterCall(MacroAssembler* masm) const {} |
583 }; | 620 }; |
584 | 621 |
585 | 622 |
| 623 class MathFloorStub : public TurboFanCodeStub { |
| 624 DEFINE_TURBOFAN_CODE_STUB(MathFloor, TurboFanCodeStub, |
| 625 MathRoundVariantDescriptor, 1); |
| 626 }; |
| 627 |
| 628 |
| 629 class StringLengthTFStub : public TurboFanCodeStub { |
| 630 DEFINE_TURBOFAN_CODE_STUB(StringLengthTF, TurboFanCodeStub, LoadDescriptor, |
| 631 0); |
| 632 |
| 633 public: |
| 634 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 635 InlineCacheState GetICState() const override { return MONOMORPHIC; } |
| 636 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
| 637 }; |
| 638 |
| 639 |
586 class NumberToStringStub final : public HydrogenCodeStub { | 640 class NumberToStringStub final : public HydrogenCodeStub { |
587 public: | 641 public: |
588 explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} | 642 explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
589 | 643 |
590 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 644 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
591 static const int kNumber = 0; | 645 static const int kNumber = 0; |
592 | 646 |
593 DEFINE_CALL_INTERFACE_DESCRIPTOR(NumberToString); | 647 DEFINE_CALL_INTERFACE_DESCRIPTOR(NumberToString); |
594 DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub); | 648 DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub); |
595 }; | 649 }; |
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2820 | 2874 |
2821 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR | 2875 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR |
2822 #undef DEFINE_PLATFORM_CODE_STUB | 2876 #undef DEFINE_PLATFORM_CODE_STUB |
2823 #undef DEFINE_HANDLER_CODE_STUB | 2877 #undef DEFINE_HANDLER_CODE_STUB |
2824 #undef DEFINE_HYDROGEN_CODE_STUB | 2878 #undef DEFINE_HYDROGEN_CODE_STUB |
2825 #undef DEFINE_CODE_STUB | 2879 #undef DEFINE_CODE_STUB |
2826 #undef DEFINE_CODE_STUB_BASE | 2880 #undef DEFINE_CODE_STUB_BASE |
2827 } } // namespace v8::internal | 2881 } } // namespace v8::internal |
2828 | 2882 |
2829 #endif // V8_CODE_STUBS_H_ | 2883 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |