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

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

Issue 498283002: Change more PlatformCodeStubs to encode properties in the minor key. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix instanceof Created 6 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « src/arm64/code-stubs-arm64.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"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 735
736 class InstanceofStub: public PlatformCodeStub { 736 class InstanceofStub: public PlatformCodeStub {
737 public: 737 public:
738 enum Flags { 738 enum Flags {
739 kNoFlags = 0, 739 kNoFlags = 0,
740 kArgsInRegisters = 1 << 0, 740 kArgsInRegisters = 1 << 0,
741 kCallSiteInlineCheck = 1 << 1, 741 kCallSiteInlineCheck = 1 << 1,
742 kReturnTrueFalseObject = 1 << 2 742 kReturnTrueFalseObject = 1 << 2
743 }; 743 };
744 744
745 InstanceofStub(Isolate* isolate, Flags flags) 745 InstanceofStub(Isolate* isolate, Flags flags) : PlatformCodeStub(isolate) {
746 : PlatformCodeStub(isolate), flags_(flags) { } 746 minor_key_ = FlagBits::encode(flags);
747 }
748
749 void Generate(MacroAssembler* masm);
747 750
748 static Register left(); 751 static Register left();
749 static Register right(); 752 static Register right();
750 753
751 void Generate(MacroAssembler* masm);
752
753 virtual void InitializeInterfaceDescriptor( 754 virtual void InitializeInterfaceDescriptor(
754 CodeStubInterfaceDescriptor* descriptor); 755 CodeStubInterfaceDescriptor* descriptor);
755 756
756 private: 757 private:
757 Major MajorKey() const { return Instanceof; } 758 Major MajorKey() const { return Instanceof; }
758 uint32_t MinorKey() const { return static_cast<int>(flags_); }
759 759
760 bool HasArgsInRegisters() const { 760 Flags flags() const { return FlagBits::decode(minor_key_); }
761 return (flags_ & kArgsInRegisters) != 0; 761
762 } 762 bool HasArgsInRegisters() const { return (flags() & kArgsInRegisters) != 0; }
763 763
764 bool HasCallSiteInlineCheck() const { 764 bool HasCallSiteInlineCheck() const {
765 return (flags_ & kCallSiteInlineCheck) != 0; 765 return (flags() & kCallSiteInlineCheck) != 0;
766 } 766 }
767 767
768 bool ReturnTrueFalseObject() const { 768 bool ReturnTrueFalseObject() const {
769 return (flags_ & kReturnTrueFalseObject) != 0; 769 return (flags() & kReturnTrueFalseObject) != 0;
770 } 770 }
771 771
772 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT 772 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
773 773
774 Flags flags_; 774 class FlagBits : public BitField<Flags, 0, 3> {};
775
776 DISALLOW_COPY_AND_ASSIGN(InstanceofStub);
775 }; 777 };
776 778
777 779
778 enum AllocationSiteOverrideMode { 780 enum AllocationSiteOverrideMode {
779 DONT_OVERRIDE, 781 DONT_OVERRIDE,
780 DISABLE_ALLOCATION_SITES, 782 DISABLE_ALLOCATION_SITES,
781 LAST_ALLOCATION_SITE_OVERRIDE_MODE = DISABLE_ALLOCATION_SITES 783 LAST_ALLOCATION_SITE_OVERRIDE_MODE = DISABLE_ALLOCATION_SITES
782 }; 784 };
783 785
784 786
785 class ArrayConstructorStub: public PlatformCodeStub { 787 class ArrayConstructorStub: public PlatformCodeStub {
786 public: 788 public:
787 enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE }; 789 enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE };
788 ArrayConstructorStub(Isolate* isolate, int argument_count); 790 ArrayConstructorStub(Isolate* isolate, int argument_count);
791
789 explicit ArrayConstructorStub(Isolate* isolate); 792 explicit ArrayConstructorStub(Isolate* isolate);
790 793
791 void Generate(MacroAssembler* masm); 794 void Generate(MacroAssembler* masm);
792 795
793 private: 796 private:
797 virtual CodeStub::Major MajorKey() const { return ArrayConstructor; }
798
799 ArgumentCountKey argument_count() const {
800 return ArgumentCountBits::decode(minor_key_);
801 }
802
794 void GenerateDispatchToArrayStub(MacroAssembler* masm, 803 void GenerateDispatchToArrayStub(MacroAssembler* masm,
795 AllocationSiteOverrideMode mode); 804 AllocationSiteOverrideMode mode);
805
796 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT 806 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
797 807
798 virtual CodeStub::Major MajorKey() const { return ArrayConstructor; } 808 class ArgumentCountBits : public BitField<ArgumentCountKey, 0, 2> {};
799 virtual uint32_t MinorKey() const { return argument_count_; }
800 809
801 ArgumentCountKey argument_count_; 810 DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStub);
802 }; 811 };
803 812
804 813
805 class InternalArrayConstructorStub: public PlatformCodeStub { 814 class InternalArrayConstructorStub: public PlatformCodeStub {
806 public: 815 public:
807 explicit InternalArrayConstructorStub(Isolate* isolate); 816 explicit InternalArrayConstructorStub(Isolate* isolate);
808 817
809 void Generate(MacroAssembler* masm); 818 void Generate(MacroAssembler* masm);
810 819
811 private: 820 private:
812 virtual CodeStub::Major MajorKey() const { return InternalArrayConstructor; } 821 virtual CodeStub::Major MajorKey() const { return InternalArrayConstructor; }
813 virtual uint32_t MinorKey() const { return 0; }
814 822
815 void GenerateCase(MacroAssembler* masm, ElementsKind kind); 823 void GenerateCase(MacroAssembler* masm, ElementsKind kind);
824
825 DISALLOW_COPY_AND_ASSIGN(InternalArrayConstructorStub);
816 }; 826 };
817 827
818 828
819 class MathPowStub: public PlatformCodeStub { 829 class MathPowStub: public PlatformCodeStub {
820 public: 830 public:
821 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK }; 831 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK };
822 832
823 MathPowStub(Isolate* isolate, ExponentType exponent_type) 833 MathPowStub(Isolate* isolate, ExponentType exponent_type)
824 : PlatformCodeStub(isolate), exponent_type_(exponent_type) { } 834 : PlatformCodeStub(isolate) {
835 minor_key_ = ExponentTypeBits::encode(exponent_type);
836 }
837
825 virtual void Generate(MacroAssembler* masm); 838 virtual void Generate(MacroAssembler* masm);
826 839
827 private: 840 private:
828 virtual CodeStub::Major MajorKey() const { return MathPow; } 841 virtual CodeStub::Major MajorKey() const { return MathPow; }
829 virtual uint32_t MinorKey() const { return exponent_type_; }
830 842
831 ExponentType exponent_type_; 843 ExponentType exponent_type() const {
844 return ExponentTypeBits::decode(minor_key_);
845 }
846
847 class ExponentTypeBits : public BitField<ExponentType, 0, 2> {};
848
849 DISALLOW_COPY_AND_ASSIGN(MathPowStub);
832 }; 850 };
833 851
834 852
835 class CallICStub: public PlatformCodeStub { 853 class CallICStub: public PlatformCodeStub {
836 public: 854 public:
837 CallICStub(Isolate* isolate, const CallIC::State& state) 855 CallICStub(Isolate* isolate, const CallIC::State& state)
838 : PlatformCodeStub(isolate), state_(state) {} 856 : PlatformCodeStub(isolate), state_(state) {}
839 857
840 bool CallAsMethod() const { return state_.CallAsMethod(); } 858 bool CallAsMethod() const { return state_.CallAsMethod(); }
841 859
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 // TODO(verwaest): Translate to hydrogen code stub. 910 // TODO(verwaest): Translate to hydrogen code stub.
893 class FunctionPrototypeStub : public PlatformCodeStub { 911 class FunctionPrototypeStub : public PlatformCodeStub {
894 public: 912 public:
895 explicit FunctionPrototypeStub(Isolate* isolate) 913 explicit FunctionPrototypeStub(Isolate* isolate)
896 : PlatformCodeStub(isolate) {} 914 : PlatformCodeStub(isolate) {}
897 virtual void Generate(MacroAssembler* masm); 915 virtual void Generate(MacroAssembler* masm);
898 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } 916 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
899 917
900 private: 918 private:
901 virtual CodeStub::Major MajorKey() const { return FunctionPrototype; } 919 virtual CodeStub::Major MajorKey() const { return FunctionPrototype; }
902 virtual uint32_t MinorKey() const { return 0; } 920
921 DISALLOW_COPY_AND_ASSIGN(FunctionPrototypeStub);
903 }; 922 };
904 923
905 924
906 class HandlerStub : public HydrogenCodeStub { 925 class HandlerStub : public HydrogenCodeStub {
907 public: 926 public:
908 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } 927 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
909 virtual ExtraICState GetExtraICState() const { return kind(); } 928 virtual ExtraICState GetExtraICState() const { return kind(); }
910 virtual InlineCacheState GetICState() const { return MONOMORPHIC; } 929 virtual InlineCacheState GetICState() const { return MONOMORPHIC; }
911 930
912 virtual void InitializeInterfaceDescriptor( 931 virtual void InitializeInterfaceDescriptor(
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub); 1087 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub);
1069 }; 1088 };
1070 1089
1071 1090
1072 class CallApiFunctionStub : public PlatformCodeStub { 1091 class CallApiFunctionStub : public PlatformCodeStub {
1073 public: 1092 public:
1074 CallApiFunctionStub(Isolate* isolate, 1093 CallApiFunctionStub(Isolate* isolate,
1075 bool is_store, 1094 bool is_store,
1076 bool call_data_undefined, 1095 bool call_data_undefined,
1077 int argc) : PlatformCodeStub(isolate) { 1096 int argc) : PlatformCodeStub(isolate) {
1078 bit_field_ = 1097 minor_key_ = IsStoreBits::encode(is_store) |
1079 IsStoreBits::encode(is_store) | 1098 CallDataUndefinedBits::encode(call_data_undefined) |
1080 CallDataUndefinedBits::encode(call_data_undefined) | 1099 ArgumentBits::encode(argc);
1081 ArgumentBits::encode(argc);
1082 DCHECK(!is_store || argc == 1); 1100 DCHECK(!is_store || argc == 1);
1083 } 1101 }
1084 1102
1085 private: 1103 private:
1086 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; 1104 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE;
1087 virtual Major MajorKey() const V8_OVERRIDE { return CallApiFunction; } 1105 virtual Major MajorKey() const V8_OVERRIDE { return CallApiFunction; }
1088 virtual uint32_t MinorKey() const V8_OVERRIDE { return bit_field_; } 1106
1107 bool is_store() const { return IsStoreBits::decode(minor_key_); }
1108 bool call_data_undefined() const {
1109 return CallDataUndefinedBits::decode(minor_key_);
1110 }
1111 int argc() const { return ArgumentBits::decode(minor_key_); }
1089 1112
1090 class IsStoreBits: public BitField<bool, 0, 1> {}; 1113 class IsStoreBits: public BitField<bool, 0, 1> {};
1091 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; 1114 class CallDataUndefinedBits: public BitField<bool, 1, 1> {};
1092 class ArgumentBits: public BitField<int, 2, Code::kArgumentsBits> {}; 1115 class ArgumentBits: public BitField<int, 2, Code::kArgumentsBits> {};
1093 1116 STATIC_ASSERT(Code::kArgumentsBits + 2 <= kStubMinorKeyBits);
1094 int bit_field_;
1095 1117
1096 DISALLOW_COPY_AND_ASSIGN(CallApiFunctionStub); 1118 DISALLOW_COPY_AND_ASSIGN(CallApiFunctionStub);
1097 }; 1119 };
1098 1120
1099 1121
1100 class CallApiGetterStub : public PlatformCodeStub { 1122 class CallApiGetterStub : public PlatformCodeStub {
1101 public: 1123 public:
1102 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} 1124 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
1103 1125
1104 private: 1126 private:
1105 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; 1127 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE;
1106 virtual Major MajorKey() const V8_OVERRIDE { return CallApiGetter; } 1128 virtual Major MajorKey() const V8_OVERRIDE { return CallApiGetter; }
1107 virtual uint32_t MinorKey() const V8_OVERRIDE { return 0; }
1108 1129
1109 DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub); 1130 DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub);
1110 }; 1131 };
1111 1132
1112 1133
1113 class BinaryOpICStub : public HydrogenCodeStub { 1134 class BinaryOpICStub : public HydrogenCodeStub {
1114 public: 1135 public:
1115 BinaryOpICStub(Isolate* isolate, Token::Value op, 1136 BinaryOpICStub(Isolate* isolate, Token::Value op,
1116 OverwriteMode mode = NO_OVERWRITE) 1137 OverwriteMode mode = NO_OVERWRITE)
1117 : HydrogenCodeStub(isolate, UNINITIALIZED), state_(isolate, op, mode) {} 1138 : HydrogenCodeStub(isolate, UNINITIALIZED), state_(isolate, op, mode) {}
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 1506
1486 bool save_doubles() const { return SaveDoublesBits::decode(minor_key_); } 1507 bool save_doubles() const { return SaveDoublesBits::decode(minor_key_); }
1487 #ifdef _WIN64 1508 #ifdef _WIN64
1488 int result_size() const { return ResultSizeBits::decode(minor_key_); } 1509 int result_size() const { return ResultSizeBits::decode(minor_key_); }
1489 #endif // _WIN64 1510 #endif // _WIN64
1490 1511
1491 bool NeedsImmovableCode(); 1512 bool NeedsImmovableCode();
1492 1513
1493 class SaveDoublesBits : public BitField<bool, 0, 1> {}; 1514 class SaveDoublesBits : public BitField<bool, 0, 1> {};
1494 class ResultSizeBits : public BitField<int, 1, 3> {}; 1515 class ResultSizeBits : public BitField<int, 1, 3> {};
1516
1517 DISALLOW_COPY_AND_ASSIGN(CEntryStub);
1495 }; 1518 };
1496 1519
1497 1520
1498 class JSEntryStub : public PlatformCodeStub { 1521 class JSEntryStub : public PlatformCodeStub {
1499 public: 1522 public:
1500 explicit JSEntryStub(Isolate* isolate) : PlatformCodeStub(isolate) { } 1523 explicit JSEntryStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
1501 1524
1502 void Generate(MacroAssembler* masm) { GenerateBody(masm, false); } 1525 void Generate(MacroAssembler* masm) { GenerateBody(masm, false); }
1503 1526
1504 protected: 1527 protected:
1505 void GenerateBody(MacroAssembler* masm, bool is_construct); 1528 void GenerateBody(MacroAssembler* masm, bool is_construct);
1506 1529
1507 private: 1530 private:
1508 Major MajorKey() const { return JSEntry; } 1531 Major MajorKey() const { return JSEntry; }
1509 uint32_t MinorKey() const { return 0; }
1510 1532
1511 virtual void FinishCode(Handle<Code> code); 1533 virtual void FinishCode(Handle<Code> code);
1512 1534
1513 int handler_offset_; 1535 int handler_offset_;
1536
1537 DISALLOW_COPY_AND_ASSIGN(JSEntryStub);
1514 }; 1538 };
1515 1539
1516 1540
1517 class JSConstructEntryStub : public JSEntryStub { 1541 class JSConstructEntryStub : public JSEntryStub {
1518 public: 1542 public:
1519 explicit JSConstructEntryStub(Isolate* isolate) : JSEntryStub(isolate) { } 1543 explicit JSConstructEntryStub(Isolate* isolate) : JSEntryStub(isolate) {
1544 minor_key_ = 1;
1545 }
1520 1546
1521 void Generate(MacroAssembler* masm) { GenerateBody(masm, true); } 1547 void Generate(MacroAssembler* masm) { GenerateBody(masm, true); }
1522 1548
1523 private: 1549 private:
1524 uint32_t MinorKey() const { return 1; }
1525
1526 virtual void PrintName(OStream& os) const V8_OVERRIDE { // NOLINT 1550 virtual void PrintName(OStream& os) const V8_OVERRIDE { // NOLINT
1527 os << "JSConstructEntryStub"; 1551 os << "JSConstructEntryStub";
1528 } 1552 }
1553
1554 DISALLOW_COPY_AND_ASSIGN(JSConstructEntryStub);
1529 }; 1555 };
1530 1556
1531 1557
1532 class ArgumentsAccessStub: public PlatformCodeStub { 1558 class ArgumentsAccessStub: public PlatformCodeStub {
1533 public: 1559 public:
1534 enum Type { 1560 enum Type {
1535 READ_ELEMENT, 1561 READ_ELEMENT,
1536 NEW_SLOPPY_FAST, 1562 NEW_SLOPPY_FAST,
1537 NEW_SLOPPY_SLOW, 1563 NEW_SLOPPY_SLOW,
1538 NEW_STRICT 1564 NEW_STRICT
1539 }; 1565 };
1540 1566
1541 ArgumentsAccessStub(Isolate* isolate, Type type) 1567 ArgumentsAccessStub(Isolate* isolate, Type type) : PlatformCodeStub(isolate) {
1542 : PlatformCodeStub(isolate), type_(type) { } 1568 minor_key_ = TypeBits::encode(type);
1569 }
1543 1570
1544 private: 1571 private:
1545 Type type_; 1572 Major MajorKey() const { return ArgumentsAccess; }
1546 1573
1547 Major MajorKey() const { return ArgumentsAccess; } 1574 Type type() const { return TypeBits::decode(minor_key_); }
1548 uint32_t MinorKey() const { return type_; }
1549 1575
1550 void Generate(MacroAssembler* masm); 1576 void Generate(MacroAssembler* masm);
1551 void GenerateReadElement(MacroAssembler* masm); 1577 void GenerateReadElement(MacroAssembler* masm);
1552 void GenerateNewStrict(MacroAssembler* masm); 1578 void GenerateNewStrict(MacroAssembler* masm);
1553 void GenerateNewSloppyFast(MacroAssembler* masm); 1579 void GenerateNewSloppyFast(MacroAssembler* masm);
1554 void GenerateNewSloppySlow(MacroAssembler* masm); 1580 void GenerateNewSloppySlow(MacroAssembler* masm);
1555 1581
1556 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT 1582 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
1583
1584 class TypeBits : public BitField<Type, 0, 2> {};
1585
1586 DISALLOW_COPY_AND_ASSIGN(ArgumentsAccessStub);
1557 }; 1587 };
1558 1588
1559 1589
1560 class RegExpExecStub: public PlatformCodeStub { 1590 class RegExpExecStub: public PlatformCodeStub {
1561 public: 1591 public:
1562 explicit RegExpExecStub(Isolate* isolate) : PlatformCodeStub(isolate) { } 1592 explicit RegExpExecStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
1563 1593
1564 private: 1594 private:
1565 Major MajorKey() const { return RegExpExec; } 1595 Major MajorKey() const { return RegExpExec; }
1566 uint32_t MinorKey() const { return 0; }
1567 1596
1568 void Generate(MacroAssembler* masm); 1597 void Generate(MacroAssembler* masm);
1598
1599 DISALLOW_COPY_AND_ASSIGN(RegExpExecStub);
1569 }; 1600 };
1570 1601
1571 1602
1572 class RegExpConstructResultStub V8_FINAL : public HydrogenCodeStub { 1603 class RegExpConstructResultStub V8_FINAL : public HydrogenCodeStub {
1573 public: 1604 public:
1574 explicit RegExpConstructResultStub(Isolate* isolate) 1605 explicit RegExpConstructResultStub(Isolate* isolate)
1575 : HydrogenCodeStub(isolate) { } 1606 : HydrogenCodeStub(isolate) { }
1576 1607
1577 virtual Handle<Code> GenerateCode() V8_OVERRIDE; 1608 virtual Handle<Code> GenerateCode() V8_OVERRIDE;
1578 1609
(...skipping 11 matching lines...) Expand all
1590 static const int kInput = 2; 1621 static const int kInput = 2;
1591 1622
1592 private: 1623 private:
1593 DISALLOW_COPY_AND_ASSIGN(RegExpConstructResultStub); 1624 DISALLOW_COPY_AND_ASSIGN(RegExpConstructResultStub);
1594 }; 1625 };
1595 1626
1596 1627
1597 class CallFunctionStub: public PlatformCodeStub { 1628 class CallFunctionStub: public PlatformCodeStub {
1598 public: 1629 public:
1599 CallFunctionStub(Isolate* isolate, int argc, CallFunctionFlags flags) 1630 CallFunctionStub(Isolate* isolate, int argc, CallFunctionFlags flags)
1600 : PlatformCodeStub(isolate), argc_(argc), flags_(flags) { 1631 : PlatformCodeStub(isolate) {
1601 DCHECK(argc <= Code::kMaxArguments); 1632 DCHECK(argc >= 0 && argc <= Code::kMaxArguments);
1633 minor_key_ = ArgcBits::encode(argc) | FlagBits::encode(flags);
1602 } 1634 }
1603 1635
1604 void Generate(MacroAssembler* masm); 1636 void Generate(MacroAssembler* masm);
1605 1637
1606 static int ExtractArgcFromMinorKey(int minor_key) { 1638 static int ExtractArgcFromMinorKey(int minor_key) {
1607 return ArgcBits::decode(minor_key); 1639 return ArgcBits::decode(minor_key);
1608 } 1640 }
1609 1641
1610 virtual void InitializeInterfaceDescriptor( 1642 virtual void InitializeInterfaceDescriptor(
1611 CodeStubInterfaceDescriptor* descriptor); 1643 CodeStubInterfaceDescriptor* descriptor);
1612 1644
1613 private: 1645 private:
1614 int argc_; 1646 Major MajorKey() const { return CallFunction; }
1615 CallFunctionFlags flags_; 1647
1648 int argc() const { return ArgcBits::decode(minor_key_); }
1649 int flags() const { return FlagBits::decode(minor_key_); }
1650
1651 bool CallAsMethod() const {
1652 return flags() == CALL_AS_METHOD || flags() == WRAP_AND_CALL;
1653 }
1654
1655 bool NeedsChecks() const { return flags() != WRAP_AND_CALL; }
1616 1656
1617 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT 1657 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
1618 1658
1619 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. 1659 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>.
1620 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; 1660 class FlagBits : public BitField<CallFunctionFlags, 0, 2> {};
1621 class ArgcBits : public BitField<unsigned, 2, Code::kArgumentsBits> {}; 1661 class ArgcBits : public BitField<unsigned, 2, Code::kArgumentsBits> {};
1622
1623 STATIC_ASSERT(Code::kArgumentsBits + 2 <= kStubMinorKeyBits); 1662 STATIC_ASSERT(Code::kArgumentsBits + 2 <= kStubMinorKeyBits);
1624 1663
1625 Major MajorKey() const { return CallFunction; } 1664 DISALLOW_COPY_AND_ASSIGN(CallFunctionStub);
1626 uint32_t MinorKey() const {
1627 // Encode the parameters in a unique 32 bit value.
1628 return FlagBits::encode(flags_) | ArgcBits::encode(argc_);
1629 }
1630
1631 bool CallAsMethod() {
1632 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL;
1633 }
1634
1635 bool NeedsChecks() {
1636 return flags_ != WRAP_AND_CALL;
1637 }
1638 }; 1665 };
1639 1666
1640 1667
1641 class CallConstructStub: public PlatformCodeStub { 1668 class CallConstructStub: public PlatformCodeStub {
1642 public: 1669 public:
1643 CallConstructStub(Isolate* isolate, CallConstructorFlags flags) 1670 CallConstructStub(Isolate* isolate, CallConstructorFlags flags)
1644 : PlatformCodeStub(isolate), flags_(flags) {} 1671 : PlatformCodeStub(isolate) {
1672 minor_key_ = FlagBits::encode(flags);
1673 }
1645 1674
1646 void Generate(MacroAssembler* masm); 1675 void Generate(MacroAssembler* masm);
1647 1676
1648 virtual void FinishCode(Handle<Code> code) { 1677 virtual void FinishCode(Handle<Code> code) {
1649 code->set_has_function_cache(RecordCallTarget()); 1678 code->set_has_function_cache(RecordCallTarget());
1650 } 1679 }
1651 1680
1652 virtual void InitializeInterfaceDescriptor( 1681 virtual void InitializeInterfaceDescriptor(
1653 CodeStubInterfaceDescriptor* descriptor); 1682 CodeStubInterfaceDescriptor* descriptor);
1654 1683
1655 private: 1684 private:
1656 CallConstructorFlags flags_; 1685 Major MajorKey() const { return CallConstruct; }
1686
1687 CallConstructorFlags flags() const { return FlagBits::decode(minor_key_); }
1688
1689 bool RecordCallTarget() const {
1690 return (flags() & RECORD_CONSTRUCTOR_TARGET) != 0;
1691 }
1657 1692
1658 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT 1693 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
1659 1694
1660 Major MajorKey() const { return CallConstruct; } 1695 class FlagBits : public BitField<CallConstructorFlags, 0, 1> {};
1661 uint32_t MinorKey() const { return flags_; }
1662 1696
1663 bool RecordCallTarget() const { 1697 DISALLOW_COPY_AND_ASSIGN(CallConstructStub);
1664 return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0;
1665 }
1666 }; 1698 };
1667 1699
1668 1700
1669 enum StringIndexFlags { 1701 enum StringIndexFlags {
1670 // Accepts smis or heap numbers. 1702 // Accepts smis or heap numbers.
1671 STRING_INDEX_IS_NUMBER, 1703 STRING_INDEX_IS_NUMBER,
1672 1704
1673 // Accepts smis or heap numbers that are valid array indices 1705 // Accepts smis or heap numbers that are valid array indices
1674 // (ECMA-262 15.4). Invalid indices are reported as being out of 1706 // (ECMA-262 15.4). Invalid indices are reported as being out of
1675 // range. 1707 // range.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 Major MajorKey() const { return LoadElement; } 1886 Major MajorKey() const { return LoadElement; }
1855 int NotMissMinorKey() const { return DICTIONARY_ELEMENTS; } 1887 int NotMissMinorKey() const { return DICTIONARY_ELEMENTS; }
1856 1888
1857 DISALLOW_COPY_AND_ASSIGN(LoadDictionaryElementStub); 1889 DISALLOW_COPY_AND_ASSIGN(LoadDictionaryElementStub);
1858 }; 1890 };
1859 1891
1860 1892
1861 class LoadDictionaryElementPlatformStub : public PlatformCodeStub { 1893 class LoadDictionaryElementPlatformStub : public PlatformCodeStub {
1862 public: 1894 public:
1863 explicit LoadDictionaryElementPlatformStub(Isolate* isolate) 1895 explicit LoadDictionaryElementPlatformStub(Isolate* isolate)
1864 : PlatformCodeStub(isolate) {} 1896 : PlatformCodeStub(isolate) {
1897 minor_key_ = DICTIONARY_ELEMENTS;
1898 }
1865 1899
1866 void Generate(MacroAssembler* masm); 1900 void Generate(MacroAssembler* masm);
1867 1901
1868 private: 1902 private:
1869 Major MajorKey() const { return LoadElement; } 1903 Major MajorKey() const { return LoadElement; }
1870 uint32_t MinorKey() const { return DICTIONARY_ELEMENTS; }
1871 1904
1872 DISALLOW_COPY_AND_ASSIGN(LoadDictionaryElementPlatformStub); 1905 DISALLOW_COPY_AND_ASSIGN(LoadDictionaryElementPlatformStub);
1873 }; 1906 };
1874 1907
1875 1908
1876 class KeyedLoadGenericStub : public HydrogenCodeStub { 1909 class KeyedLoadGenericStub : public HydrogenCodeStub {
1877 public: 1910 public:
1878 explicit KeyedLoadGenericStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} 1911 explicit KeyedLoadGenericStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
1879 1912
1880 virtual Handle<Code> GenerateCode() V8_OVERRIDE; 1913 virtual Handle<Code> GenerateCode() V8_OVERRIDE;
1881 1914
1882 virtual void InitializeInterfaceDescriptor( 1915 virtual void InitializeInterfaceDescriptor(
1883 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; 1916 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
1884 1917
1885 static void InstallDescriptors(Isolate* isolate); 1918 static void InstallDescriptors(Isolate* isolate);
1886 1919
1887 virtual Code::Kind GetCodeKind() const { return Code::KEYED_LOAD_IC; } 1920 virtual Code::Kind GetCodeKind() const { return Code::KEYED_LOAD_IC; }
1888 virtual InlineCacheState GetICState() const { return GENERIC; } 1921 virtual InlineCacheState GetICState() const { return GENERIC; }
1889 1922
1890 private: 1923 private:
1891 Major MajorKey() const { return KeyedLoadGeneric; } 1924 Major MajorKey() const { return KeyedLoadGeneric; }
1892 int NotMissMinorKey() const { return 0; } 1925 int NotMissMinorKey() const { return 0; }
1893 1926
1894 DISALLOW_COPY_AND_ASSIGN(KeyedLoadGenericStub); 1927 DISALLOW_COPY_AND_ASSIGN(KeyedLoadGenericStub);
1895 }; 1928 };
1896 1929
1897 1930
1898 class DoubleToIStub : public PlatformCodeStub { 1931 class DoubleToIStub : public PlatformCodeStub {
1899 public: 1932 public:
1900 DoubleToIStub(Isolate* isolate, 1933 DoubleToIStub(Isolate* isolate, Register source, Register destination,
1901 Register source, 1934 int offset, bool is_truncating, bool skip_fastpath = false)
1902 Register destination, 1935 : PlatformCodeStub(isolate) {
1903 int offset, 1936 minor_key_ = SourceRegisterBits::encode(source.code()) |
1904 bool is_truncating, 1937 DestinationRegisterBits::encode(destination.code()) |
1905 bool skip_fastpath = false) 1938 OffsetBits::encode(offset) |
1906 : PlatformCodeStub(isolate), bit_field_(0) { 1939 IsTruncatingBits::encode(is_truncating) |
1907 bit_field_ = SourceRegisterBits::encode(source.code()) | 1940 SkipFastPathBits::encode(skip_fastpath) |
1908 DestinationRegisterBits::encode(destination.code()) | 1941 SSE3Bits::encode(CpuFeatures::IsSupported(SSE3) ? 1 : 0);
1909 OffsetBits::encode(offset) |
1910 IsTruncatingBits::encode(is_truncating) |
1911 SkipFastPathBits::encode(skip_fastpath) |
1912 SSE3Bits::encode(CpuFeatures::IsSupported(SSE3) ? 1 : 0);
1913 }
1914
1915 Register source() {
1916 return Register::from_code(SourceRegisterBits::decode(bit_field_));
1917 }
1918
1919 Register destination() {
1920 return Register::from_code(DestinationRegisterBits::decode(bit_field_));
1921 }
1922
1923 bool is_truncating() {
1924 return IsTruncatingBits::decode(bit_field_);
1925 }
1926
1927 bool skip_fastpath() {
1928 return SkipFastPathBits::decode(bit_field_);
1929 }
1930
1931 int offset() {
1932 return OffsetBits::decode(bit_field_);
1933 } 1942 }
1934 1943
1935 void Generate(MacroAssembler* masm); 1944 void Generate(MacroAssembler* masm);
1936 1945
1937 virtual bool SometimesSetsUpAFrame() { return false; } 1946 virtual bool SometimesSetsUpAFrame() { return false; }
1938 1947
1939 private: 1948 private:
1949 Major MajorKey() const { return DoubleToI; }
1950
1951 Register source() const {
1952 return Register::from_code(SourceRegisterBits::decode(minor_key_));
1953 }
1954 Register destination() const {
1955 return Register::from_code(DestinationRegisterBits::decode(minor_key_));
1956 }
1957 bool is_truncating() const { return IsTruncatingBits::decode(minor_key_); }
1958 bool skip_fastpath() const { return SkipFastPathBits::decode(minor_key_); }
1959 int offset() const { return OffsetBits::decode(minor_key_); }
1960
1940 static const int kBitsPerRegisterNumber = 6; 1961 static const int kBitsPerRegisterNumber = 6;
1941 STATIC_ASSERT((1L << kBitsPerRegisterNumber) >= Register::kNumRegisters); 1962 STATIC_ASSERT((1L << kBitsPerRegisterNumber) >= Register::kNumRegisters);
1942 class SourceRegisterBits: 1963 class SourceRegisterBits:
1943 public BitField<int, 0, kBitsPerRegisterNumber> {}; // NOLINT 1964 public BitField<int, 0, kBitsPerRegisterNumber> {}; // NOLINT
1944 class DestinationRegisterBits: 1965 class DestinationRegisterBits:
1945 public BitField<int, kBitsPerRegisterNumber, 1966 public BitField<int, kBitsPerRegisterNumber,
1946 kBitsPerRegisterNumber> {}; // NOLINT 1967 kBitsPerRegisterNumber> {}; // NOLINT
1947 class IsTruncatingBits: 1968 class IsTruncatingBits:
1948 public BitField<bool, 2 * kBitsPerRegisterNumber, 1> {}; // NOLINT 1969 public BitField<bool, 2 * kBitsPerRegisterNumber, 1> {}; // NOLINT
1949 class OffsetBits: 1970 class OffsetBits:
1950 public BitField<int, 2 * kBitsPerRegisterNumber + 1, 3> {}; // NOLINT 1971 public BitField<int, 2 * kBitsPerRegisterNumber + 1, 3> {}; // NOLINT
1951 class SkipFastPathBits: 1972 class SkipFastPathBits:
1952 public BitField<int, 2 * kBitsPerRegisterNumber + 4, 1> {}; // NOLINT 1973 public BitField<int, 2 * kBitsPerRegisterNumber + 4, 1> {}; // NOLINT
1953 class SSE3Bits: 1974 class SSE3Bits:
1954 public BitField<int, 2 * kBitsPerRegisterNumber + 5, 1> {}; // NOLINT 1975 public BitField<int, 2 * kBitsPerRegisterNumber + 5, 1> {}; // NOLINT
1955 1976
1956 Major MajorKey() const { return DoubleToI; }
1957 uint32_t MinorKey() const { return bit_field_; }
1958
1959 int bit_field_;
1960
1961 DISALLOW_COPY_AND_ASSIGN(DoubleToIStub); 1977 DISALLOW_COPY_AND_ASSIGN(DoubleToIStub);
1962 }; 1978 };
1963 1979
1964 1980
1965 class LoadFastElementStub : public HydrogenCodeStub { 1981 class LoadFastElementStub : public HydrogenCodeStub {
1966 public: 1982 public:
1967 LoadFastElementStub(Isolate* isolate, bool is_js_array, 1983 LoadFastElementStub(Isolate* isolate, bool is_js_array,
1968 ElementsKind elements_kind) 1984 ElementsKind elements_kind)
1969 : HydrogenCodeStub(isolate) { 1985 : HydrogenCodeStub(isolate) {
1970 bit_field_ = ElementsKindBits::encode(elements_kind) | 1986 bit_field_ = ElementsKindBits::encode(elements_kind) |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 2291
2276 private: 2292 private:
2277 Major MajorKey() const { return InternalArrayNArgumentsConstructor; } 2293 Major MajorKey() const { return InternalArrayNArgumentsConstructor; }
2278 2294
2279 DISALLOW_COPY_AND_ASSIGN(InternalArrayNArgumentsConstructorStub); 2295 DISALLOW_COPY_AND_ASSIGN(InternalArrayNArgumentsConstructorStub);
2280 }; 2296 };
2281 2297
2282 2298
2283 class StoreElementStub : public PlatformCodeStub { 2299 class StoreElementStub : public PlatformCodeStub {
2284 public: 2300 public:
2285 StoreElementStub(Isolate* isolate, bool is_js_array, 2301 StoreElementStub(Isolate* isolate, ElementsKind elements_kind)
2286 ElementsKind elements_kind, KeyedAccessStoreMode store_mode) 2302 : PlatformCodeStub(isolate) {
2287 : PlatformCodeStub(isolate), 2303 minor_key_ = ElementsKindBits::encode(elements_kind);
2288 is_js_array_(is_js_array),
2289 elements_kind_(elements_kind),
2290 store_mode_(store_mode) {}
2291
2292 Major MajorKey() const { return StoreElement; }
2293 uint32_t MinorKey() const {
2294 return ElementsKindBits::encode(elements_kind_) |
2295 IsJSArrayBits::encode(is_js_array_) |
2296 StoreModeBits::encode(store_mode_);
2297 } 2304 }
2298 2305
2299 void Generate(MacroAssembler* masm); 2306 void Generate(MacroAssembler* masm);
2300 2307
2301 private: 2308 private:
2302 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; 2309 Major MajorKey() const { return StoreElement; }
2303 class StoreModeBits: public BitField<KeyedAccessStoreMode, 8, 4> {};
2304 class IsJSArrayBits: public BitField<bool, 12, 1> {};
2305 2310
2306 bool is_js_array_; 2311 ElementsKind elements_kind() const {
2307 ElementsKind elements_kind_; 2312 return ElementsKindBits::decode(minor_key_);
2308 KeyedAccessStoreMode store_mode_; 2313 }
2314
2315 class ElementsKindBits : public BitField<ElementsKind, 0, 8> {};
2309 2316
2310 DISALLOW_COPY_AND_ASSIGN(StoreElementStub); 2317 DISALLOW_COPY_AND_ASSIGN(StoreElementStub);
2311 }; 2318 };
2312 2319
2313 2320
2314 class ToBooleanStub: public HydrogenCodeStub { 2321 class ToBooleanStub: public HydrogenCodeStub {
2315 public: 2322 public:
2316 enum Type { 2323 enum Type {
2317 UNDEFINED, 2324 UNDEFINED,
2318 BOOLEAN, 2325 BOOLEAN,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 }; 2480 };
2474 2481
2475 2482
2476 class StoreArrayLiteralElementStub : public PlatformCodeStub { 2483 class StoreArrayLiteralElementStub : public PlatformCodeStub {
2477 public: 2484 public:
2478 explicit StoreArrayLiteralElementStub(Isolate* isolate) 2485 explicit StoreArrayLiteralElementStub(Isolate* isolate)
2479 : PlatformCodeStub(isolate) { } 2486 : PlatformCodeStub(isolate) { }
2480 2487
2481 private: 2488 private:
2482 Major MajorKey() const { return StoreArrayLiteralElement; } 2489 Major MajorKey() const { return StoreArrayLiteralElement; }
2483 uint32_t MinorKey() const { return 0; }
2484 2490
2485 void Generate(MacroAssembler* masm); 2491 void Generate(MacroAssembler* masm);
2486 2492
2487 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); 2493 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub);
2488 }; 2494 };
2489 2495
2490 2496
2491 class StubFailureTrampolineStub : public PlatformCodeStub { 2497 class StubFailureTrampolineStub : public PlatformCodeStub {
2492 public: 2498 public:
2493 StubFailureTrampolineStub(Isolate* isolate, StubFunctionMode function_mode) 2499 StubFailureTrampolineStub(Isolate* isolate, StubFunctionMode function_mode)
2494 : PlatformCodeStub(isolate), 2500 : PlatformCodeStub(isolate) {
2495 function_mode_(function_mode) {} 2501 minor_key_ = FunctionModeField::encode(function_mode);
2502 }
2496 2503
2497 static void GenerateAheadOfTime(Isolate* isolate); 2504 static void GenerateAheadOfTime(Isolate* isolate);
2498 2505
2499 private: 2506 private:
2500 class FunctionModeField: public BitField<StubFunctionMode, 0, 1> {}; 2507 Major MajorKey() const { return StubFailureTrampoline; }
2501 2508
2502 Major MajorKey() const { return StubFailureTrampoline; } 2509 StubFunctionMode function_mode() const {
2503 uint32_t MinorKey() const { 2510 return FunctionModeField::decode(minor_key_);
2504 return FunctionModeField::encode(function_mode_);
2505 } 2511 }
2506 2512
2507 void Generate(MacroAssembler* masm); 2513 void Generate(MacroAssembler* masm);
2508 2514
2509 StubFunctionMode function_mode_; 2515 class FunctionModeField : public BitField<StubFunctionMode, 0, 1> {};
2510 2516
2511 DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub); 2517 DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub);
2512 }; 2518 };
2513 2519
2514 2520
2515 class ProfileEntryHookStub : public PlatformCodeStub { 2521 class ProfileEntryHookStub : public PlatformCodeStub {
2516 public: 2522 public:
2517 explicit ProfileEntryHookStub(Isolate* isolate) : PlatformCodeStub(isolate) {} 2523 explicit ProfileEntryHookStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
2518 2524
2519 // The profile entry hook function is not allowed to cause a GC. 2525 // The profile entry hook function is not allowed to cause a GC.
2520 virtual bool SometimesSetsUpAFrame() { return false; } 2526 virtual bool SometimesSetsUpAFrame() { return false; }
2521 2527
2522 // Generates a call to the entry hook if it's enabled. 2528 // Generates a call to the entry hook if it's enabled.
2523 static void MaybeCallEntryHook(MacroAssembler* masm); 2529 static void MaybeCallEntryHook(MacroAssembler* masm);
2524 2530
2525 private: 2531 private:
2526 static void EntryHookTrampoline(intptr_t function, 2532 static void EntryHookTrampoline(intptr_t function,
2527 intptr_t stack_pointer, 2533 intptr_t stack_pointer,
2528 Isolate* isolate); 2534 Isolate* isolate);
2529 2535
2530 Major MajorKey() const { return ProfileEntryHook; } 2536 Major MajorKey() const { return ProfileEntryHook; }
2531 uint32_t MinorKey() const { return 0; }
2532 2537
2533 void Generate(MacroAssembler* masm); 2538 void Generate(MacroAssembler* masm);
2534 2539
2535 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 2540 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
2536 }; 2541 };
2537 2542
2538 2543
2539 class CallDescriptors { 2544 class CallDescriptors {
2540 public: 2545 public:
2541 static void InitializeForIsolate(Isolate* isolate); 2546 static void InitializeForIsolate(Isolate* isolate);
2542 }; 2547 };
2543 2548
2544 } } // namespace v8::internal 2549 } } // namespace v8::internal
2545 2550
2546 #endif // V8_CODE_STUBS_H_ 2551 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/arm64/code-stubs-arm64.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698