Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/code-stubs.h

Issue 1475953002: [stubs] A new approach to TF stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 build Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/bootstrapper.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/compiler/code-stub-assembler.h"
11 #include "src/globals.h" 12 #include "src/globals.h"
12 #include "src/ic/ic-state.h" 13 #include "src/ic/ic-state.h"
13 #include "src/interface-descriptors.h" 14 #include "src/interface-descriptors.h"
14 #include "src/macro-assembler.h" 15 #include "src/macro-assembler.h"
15 #include "src/ostreams.h" 16 #include "src/ostreams.h"
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 20
20 // List of code stubs used on all platforms. 21 // List of code stubs used on all platforms.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 V(RegExpConstructResult) \ 90 V(RegExpConstructResult) \
90 V(StoreFastElement) \ 91 V(StoreFastElement) \
91 V(StoreGlobalViaContext) \ 92 V(StoreGlobalViaContext) \
92 V(StoreScriptContextField) \ 93 V(StoreScriptContextField) \
93 V(StringAdd) \ 94 V(StringAdd) \
94 V(ToBoolean) \ 95 V(ToBoolean) \
95 V(TransitionElementsKind) \ 96 V(TransitionElementsKind) \
96 V(KeyedLoadIC) \ 97 V(KeyedLoadIC) \
97 V(LoadIC) \ 98 V(LoadIC) \
98 /* TurboFanCodeStubs */ \ 99 /* TurboFanCodeStubs */ \
99 V(StringLengthTF) \ 100 V(StringLength) \
100 V(StringAddTF) \
101 /* TurboFanICs */ \
102 V(MathFloor) \
103 /* IC Handler stubs */ \ 101 /* IC Handler stubs */ \
104 V(ArrayBufferViewLoadField) \ 102 V(ArrayBufferViewLoadField) \
105 V(LoadConstant) \ 103 V(LoadConstant) \
106 V(LoadFastElement) \ 104 V(LoadFastElement) \
107 V(LoadField) \ 105 V(LoadField) \
108 V(KeyedLoadSloppyArguments) \ 106 V(KeyedLoadSloppyArguments) \
109 V(KeyedStoreSloppyArguments) \ 107 V(KeyedStoreSloppyArguments) \
110 V(StoreField) \ 108 V(StoreField) \
111 V(StoreGlobal) \ 109 V(StoreGlobal) \
112 V(StoreTransition) \ 110 V(StoreTransition)
113 V(StringLength)
114 111
115 // List of code stubs only used on ARM 32 bits platforms. 112 // List of code stubs only used on ARM 32 bits platforms.
116 #if V8_TARGET_ARCH_ARM 113 #if V8_TARGET_ARCH_ARM
117 #define CODE_STUB_LIST_ARM(V) V(DirectCEntry) 114 #define CODE_STUB_LIST_ARM(V) V(DirectCEntry)
118 115
119 #else 116 #else
120 #define CODE_STUB_LIST_ARM(V) 117 #define CODE_STUB_LIST_ARM(V)
121 #endif 118 #endif
122 119
123 // List of code stubs only used on ARM 64 bits platforms. 120 // List of code stubs only used on ARM 64 bits platforms.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 Handle<Code> GenerateCode() override; \ 339 Handle<Code> GenerateCode() override; \
343 DEFINE_CODE_STUB(NAME, SUPER) 340 DEFINE_CODE_STUB(NAME, SUPER)
344 341
345 #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \ 342 #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \
346 public: \ 343 public: \
347 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ 344 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
348 return DESC##Descriptor(isolate()); \ 345 return DESC##Descriptor(isolate()); \
349 }; \ 346 }; \
350 DEFINE_CODE_STUB(NAME, SUPER) 347 DEFINE_CODE_STUB(NAME, SUPER)
351 348
352 #define DEFINE_TURBOFAN_IC(NAME, SUPER, DESC) \
353 public: \
354 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
355 if (GetCallMode() == CALL_FROM_OPTIMIZED_CODE) { \
356 return DESC##CallFromOptimizedCodeDescriptor(isolate()); \
357 } else { \
358 return DESC##CallFromUnoptimizedCodeDescriptor(isolate()); \
359 } \
360 }; \
361 \
362 protected: \
363 DEFINE_CODE_STUB(NAME, SUPER)
364
365 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ 349 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \
366 public: \ 350 public: \
367 Handle<Code> GenerateCode() override; \ 351 Handle<Code> GenerateCode() override; \
368 DEFINE_CODE_STUB(NAME, SUPER) 352 DEFINE_CODE_STUB(NAME, SUPER)
369 353
370 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ 354 #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \
371 public: \ 355 public: \
372 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ 356 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
373 return NAME##Descriptor(isolate()); \ 357 return NAME##Descriptor(isolate()); \
374 } 358 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 527
544 int GetStackParameterCount() const override { 528 int GetStackParameterCount() const override {
545 return GetCallInterfaceDescriptor().GetStackParameterCount(); 529 return GetCallInterfaceDescriptor().GetStackParameterCount();
546 } 530 }
547 531
548 Code::StubType GetStubType() const override { return Code::FAST; } 532 Code::StubType GetStubType() const override { return Code::FAST; }
549 533
550 protected: 534 protected:
551 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} 535 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {}
552 536
537 virtual void GenerateAssembly(
538 compiler::CodeStubAssembler* assembler) const = 0;
539
553 private: 540 private:
554 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); 541 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub);
555 }; 542 };
556 543
557 544
558 class TurboFanIC : public TurboFanCodeStub {
559 public:
560 enum CallMode { CALL_FROM_UNOPTIMIZED_CODE, CALL_FROM_OPTIMIZED_CODE };
561
562 protected:
563 explicit TurboFanIC(Isolate* isolate, CallMode mode)
564 : TurboFanCodeStub(isolate) {
565 minor_key_ = CallModeBits::encode(mode);
566 }
567
568 CallMode GetCallMode() const { return CallModeBits::decode(minor_key_); }
569
570 void set_sub_minor_key(uint32_t key) {
571 minor_key_ = SubMinorKeyBits::update(minor_key_, key);
572 }
573
574 uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); }
575
576 static const int kSubMinorKeyBits = kStubMinorKeyBits - 1;
577
578 private:
579 class CallModeBits : public BitField<CallMode, 0, 1> {};
580 class SubMinorKeyBits : public BitField<int, 1, kSubMinorKeyBits> {};
581 DEFINE_CODE_STUB_BASE(TurboFanIC, TurboFanCodeStub);
582 };
583
584
585 // Helper interface to prepare to/restore after making runtime calls. 545 // Helper interface to prepare to/restore after making runtime calls.
586 class RuntimeCallHelper { 546 class RuntimeCallHelper {
587 public: 547 public:
588 virtual ~RuntimeCallHelper() {} 548 virtual ~RuntimeCallHelper() {}
589 549
590 virtual void BeforeCall(MacroAssembler* masm) const = 0; 550 virtual void BeforeCall(MacroAssembler* masm) const = 0;
591 551
592 virtual void AfterCall(MacroAssembler* masm) const = 0; 552 virtual void AfterCall(MacroAssembler* masm) const = 0;
593 553
594 protected: 554 protected:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 class NopRuntimeCallHelper : public RuntimeCallHelper { 602 class NopRuntimeCallHelper : public RuntimeCallHelper {
643 public: 603 public:
644 NopRuntimeCallHelper() {} 604 NopRuntimeCallHelper() {}
645 605
646 void BeforeCall(MacroAssembler* masm) const override {} 606 void BeforeCall(MacroAssembler* masm) const override {}
647 607
648 void AfterCall(MacroAssembler* masm) const override {} 608 void AfterCall(MacroAssembler* masm) const override {}
649 }; 609 };
650 610
651 611
652 class MathFloorStub : public TurboFanIC { 612 class StringLengthStub : public TurboFanCodeStub {
653 public: 613 public:
654 explicit MathFloorStub(Isolate* isolate, TurboFanIC::CallMode mode) 614 explicit StringLengthStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
655 : TurboFanIC(isolate, mode) {}
656 Code::Kind GetCodeKind() const override { return Code::CALL_IC; }
657 DEFINE_TURBOFAN_IC(MathFloor, TurboFanIC, MathRoundVariant);
658 };
659
660
661 class StringLengthTFStub : public TurboFanCodeStub {
662 public:
663 explicit StringLengthTFStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
664 615
665 Code::Kind GetCodeKind() const override { return Code::HANDLER; } 616 Code::Kind GetCodeKind() const override { return Code::HANDLER; }
666 InlineCacheState GetICState() const override { return MONOMORPHIC; } 617 InlineCacheState GetICState() const override { return MONOMORPHIC; }
667 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } 618 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; }
668 619
620 void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override;
621
669 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); 622 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
670 DEFINE_CODE_STUB(StringLengthTF, TurboFanCodeStub); 623 DEFINE_CODE_STUB(StringLength, TurboFanCodeStub);
671 }; 624 };
672 625
673 626
674 enum StringAddFlags { 627 enum StringAddFlags {
675 // Omit both parameter checks. 628 // Omit both parameter checks.
676 STRING_ADD_CHECK_NONE = 0, 629 STRING_ADD_CHECK_NONE = 0,
677 // Check left parameter. 630 // Check left parameter.
678 STRING_ADD_CHECK_LEFT = 1 << 0, 631 STRING_ADD_CHECK_LEFT = 1 << 0,
679 // Check right parameter. 632 // Check right parameter.
680 STRING_ADD_CHECK_RIGHT = 1 << 1, 633 STRING_ADD_CHECK_RIGHT = 1 << 1,
681 // Check both parameters. 634 // Check both parameters.
682 STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT, 635 STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT,
683 // Convert parameters when check fails (instead of throwing an exception). 636 // Convert parameters when check fails (instead of throwing an exception).
684 STRING_ADD_CONVERT = 1 << 2, 637 STRING_ADD_CONVERT = 1 << 2,
685 STRING_ADD_CONVERT_LEFT = STRING_ADD_CHECK_LEFT | STRING_ADD_CONVERT, 638 STRING_ADD_CONVERT_LEFT = STRING_ADD_CHECK_LEFT | STRING_ADD_CONVERT,
686 STRING_ADD_CONVERT_RIGHT = STRING_ADD_CHECK_RIGHT | STRING_ADD_CONVERT 639 STRING_ADD_CONVERT_RIGHT = STRING_ADD_CHECK_RIGHT | STRING_ADD_CONVERT
687 }; 640 };
688 641
689 642
690 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags); 643 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);
691 644
692 645
693 class StringAddTFStub : public TurboFanCodeStub {
694 public:
695 StringAddTFStub(Isolate* isolate, StringAddFlags flags,
696 PretenureFlag pretenure_flag)
697 : TurboFanCodeStub(isolate) {
698 minor_key_ = StringAddFlagsBits::encode(flags) |
699 PretenureFlagBits::encode(pretenure_flag);
700 }
701
702 StringAddFlags flags() const {
703 return StringAddFlagsBits::decode(MinorKey());
704 }
705
706 PretenureFlag pretenure_flag() const {
707 return PretenureFlagBits::decode(MinorKey());
708 }
709
710 private:
711 class StringAddFlagsBits : public BitField<StringAddFlags, 0, 3> {};
712 class PretenureFlagBits : public BitField<PretenureFlag, 3, 1> {};
713
714 void PrintBaseName(std::ostream& os) const override; // NOLINT
715
716 DEFINE_CALL_INTERFACE_DESCRIPTOR(StringAdd);
717 DEFINE_CODE_STUB(StringAddTF, TurboFanCodeStub);
718 };
719
720
721 class NumberToStringStub final : public HydrogenCodeStub { 646 class NumberToStringStub final : public HydrogenCodeStub {
722 public: 647 public:
723 explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} 648 explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
724 649
725 // Parameters accessed via CodeStubGraphBuilder::GetParameter() 650 // Parameters accessed via CodeStubGraphBuilder::GetParameter()
726 static const int kNumber = 0; 651 static const int kNumber = 0;
727 652
728 DEFINE_CALL_INTERFACE_DESCRIPTOR(NumberToString); 653 DEFINE_CALL_INTERFACE_DESCRIPTOR(NumberToString);
729 DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub); 654 DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub);
730 }; 655 };
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 Code::Kind kind() const override { return Code::LOAD_IC; } 1098 Code::Kind kind() const override { return Code::LOAD_IC; }
1174 Code::StubType GetStubType() const override { return Code::FAST; } 1099 Code::StubType GetStubType() const override { return Code::FAST; }
1175 1100
1176 private: 1101 private:
1177 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; 1102 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {};
1178 1103
1179 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub); 1104 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub);
1180 }; 1105 };
1181 1106
1182 1107
1183 class StringLengthStub: public HandlerStub {
1184 public:
1185 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {}
1186
1187 protected:
1188 Code::Kind kind() const override { return Code::LOAD_IC; }
1189 Code::StubType GetStubType() const override { return Code::FAST; }
1190
1191 DEFINE_HANDLER_CODE_STUB(StringLength, HandlerStub);
1192 };
1193
1194
1195 class StoreFieldStub : public HandlerStub { 1108 class StoreFieldStub : public HandlerStub {
1196 public: 1109 public:
1197 StoreFieldStub(Isolate* isolate, FieldIndex index, 1110 StoreFieldStub(Isolate* isolate, FieldIndex index,
1198 Representation representation) 1111 Representation representation)
1199 : HandlerStub(isolate) { 1112 : HandlerStub(isolate) {
1200 int property_index_key = index.GetFieldAccessStubKey(); 1113 int property_index_key = index.GetFieldAccessStubKey();
1201 uint8_t repr = PropertyDetails::EncodeRepresentation(representation); 1114 uint8_t repr = PropertyDetails::EncodeRepresentation(representation);
1202 set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) | 1115 set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) |
1203 RepresentationBits::encode(repr)); 1116 RepresentationBits::encode(repr));
1204 } 1117 }
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 #undef DEFINE_HYDROGEN_CODE_STUB 2977 #undef DEFINE_HYDROGEN_CODE_STUB
3065 #undef DEFINE_CODE_STUB 2978 #undef DEFINE_CODE_STUB
3066 #undef DEFINE_CODE_STUB_BASE 2979 #undef DEFINE_CODE_STUB_BASE
3067 2980
3068 extern Representation RepresentationFromType(Type* type); 2981 extern Representation RepresentationFromType(Type* type);
3069 2982
3070 } // namespace internal 2983 } // namespace internal
3071 } // namespace v8 2984 } // namespace v8
3072 2985
3073 #endif // V8_CODE_STUBS_H_ 2986 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698