Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 V(BinaryOpIC) \ | 44 V(BinaryOpIC) \ |
| 45 V(BinaryOpICWithAllocationSite) \ | 45 V(BinaryOpICWithAllocationSite) \ |
| 46 V(BinaryOpWithAllocationSite) \ | 46 V(BinaryOpWithAllocationSite) \ |
| 47 V(StringAdd) \ | 47 V(StringAdd) \ |
| 48 V(SubString) \ | 48 V(SubString) \ |
| 49 V(StringCompare) \ | 49 V(StringCompare) \ |
| 50 V(Compare) \ | 50 V(Compare) \ |
| 51 V(CompareIC) \ | 51 V(CompareIC) \ |
| 52 V(CompareNilIC) \ | 52 V(CompareNilIC) \ |
| 53 V(MathPow) \ | 53 V(MathPow) \ |
| 54 V(CallIC) \ | |
| 54 V(FunctionPrototype) \ | 55 V(FunctionPrototype) \ |
| 55 V(RecordWrite) \ | 56 V(RecordWrite) \ |
| 56 V(StoreBufferOverflow) \ | 57 V(StoreBufferOverflow) \ |
| 57 V(RegExpExec) \ | 58 V(RegExpExec) \ |
| 58 V(Instanceof) \ | 59 V(Instanceof) \ |
| 59 V(ConvertToDouble) \ | 60 V(ConvertToDouble) \ |
| 60 V(WriteInt32ToHeapNumber) \ | 61 V(WriteInt32ToHeapNumber) \ |
| 61 V(StackCheck) \ | 62 V(StackCheck) \ |
| 62 V(Interrupt) \ | 63 V(Interrupt) \ |
| 63 V(FastNewClosure) \ | 64 V(FastNewClosure) \ |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 | 819 |
| 819 virtual int MinorKey() { | 820 virtual int MinorKey() { |
| 820 return KindBits::encode(kind_); | 821 return KindBits::encode(kind_); |
| 821 } | 822 } |
| 822 | 823 |
| 823 private: | 824 private: |
| 824 Code::Kind kind_; | 825 Code::Kind kind_; |
| 825 }; | 826 }; |
| 826 | 827 |
| 827 | 828 |
| 829 class CallICStub: public PlatformCodeStub { | |
| 830 public: | |
| 831 explicit CallICStub(const CallIC::State& state) | |
| 832 : state_(state) {} | |
| 833 | |
| 834 bool CallAsMethod() const { return state_.CallAsMethod(); } | |
| 835 bool IsGeneric() const { | |
| 836 return state_.IsGeneric(); | |
| 837 } | |
| 838 bool ArgumentsMustMatch() const { | |
| 839 return state_.ArgumentsMustMatch(); | |
| 840 } | |
| 841 bool IsSloppyOrNonNative() const { | |
| 842 return state_.IsSloppyOrNonNative(); | |
|
Toon Verwaest
2014/03/27 16:02:25
IsSloppyNonNative()
It's and, not or.
That, or IsS
mvstanton
2014/04/01 13:01:49
Done.
| |
| 843 } | |
| 844 | |
| 845 static int ExtractArgcFromMinorKey(int minor_key) { | |
| 846 CallIC::State state((ExtraICState) minor_key); | |
| 847 return state.arg_count(); | |
| 848 } | |
| 849 | |
| 850 virtual void Generate(MacroAssembler* masm); | |
| 851 | |
| 852 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { | |
| 853 return Code::CALL_IC; | |
| 854 } | |
| 855 | |
| 856 virtual InlineCacheState GetICState() V8_FINAL V8_OVERRIDE { | |
| 857 return state_.GetICState(); | |
| 858 } | |
| 859 | |
| 860 virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE { | |
| 861 return state_.GetExtraICState(); | |
| 862 } | |
| 863 | |
| 864 static void GenerateAheadOfTime(Isolate* isolate); | |
| 865 | |
| 866 protected: | |
| 867 virtual int MinorKey() { return GetExtraICState(); } | |
| 868 virtual void PrintState(StringStream* stream) V8_FINAL V8_OVERRIDE; | |
| 869 | |
| 870 private: | |
| 871 virtual CodeStub::Major MajorKey() { return CallIC; } | |
| 872 | |
| 873 // Code generation helpers. | |
| 874 void GenerateMonomorphicCall(MacroAssembler* masm); | |
| 875 void GenerateSlowCall(MacroAssembler* masm); | |
| 876 void GenerateMiss(MacroAssembler* masm); | |
| 877 | |
| 878 CallIC::State state_; | |
| 879 }; | |
| 880 | |
| 881 | |
| 828 class FunctionPrototypeStub: public ICStub { | 882 class FunctionPrototypeStub: public ICStub { |
| 829 public: | 883 public: |
| 830 explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { } | 884 explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { } |
| 831 virtual void Generate(MacroAssembler* masm); | 885 virtual void Generate(MacroAssembler* masm); |
| 832 | 886 |
| 833 private: | 887 private: |
| 834 virtual CodeStub::Major MajorKey() { return FunctionPrototype; } | 888 virtual CodeStub::Major MajorKey() { return FunctionPrototype; } |
| 835 }; | 889 }; |
| 836 | 890 |
| 837 | 891 |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1606 static const int kInput = 2; | 1660 static const int kInput = 2; |
| 1607 | 1661 |
| 1608 private: | 1662 private: |
| 1609 DISALLOW_COPY_AND_ASSIGN(RegExpConstructResultStub); | 1663 DISALLOW_COPY_AND_ASSIGN(RegExpConstructResultStub); |
| 1610 }; | 1664 }; |
| 1611 | 1665 |
| 1612 | 1666 |
| 1613 class CallFunctionStub: public PlatformCodeStub { | 1667 class CallFunctionStub: public PlatformCodeStub { |
| 1614 public: | 1668 public: |
| 1615 CallFunctionStub(int argc, CallFunctionFlags flags) | 1669 CallFunctionStub(int argc, CallFunctionFlags flags) |
| 1616 : argc_(argc), flags_(flags) { } | 1670 : argc_(argc), flags_(flags) { |
| 1671 } | |
|
Toon Verwaest
2014/03/27 16:02:25
Spurious change
mvstanton
2014/04/01 13:01:49
Done.
| |
| 1617 | 1672 |
| 1618 void Generate(MacroAssembler* masm); | 1673 void Generate(MacroAssembler* masm); |
| 1619 | 1674 |
| 1620 virtual void FinishCode(Handle<Code> code) { | |
| 1621 code->set_has_function_cache(RecordCallTarget()); | |
| 1622 } | |
| 1623 | |
| 1624 static int ExtractArgcFromMinorKey(int minor_key) { | 1675 static int ExtractArgcFromMinorKey(int minor_key) { |
| 1625 return ArgcBits::decode(minor_key); | 1676 return ArgcBits::decode(minor_key); |
| 1626 } | 1677 } |
| 1627 | 1678 |
| 1628 private: | 1679 private: |
| 1629 int argc_; | 1680 int argc_; |
| 1630 CallFunctionFlags flags_; | 1681 CallFunctionFlags flags_; |
| 1631 | 1682 |
| 1632 virtual void PrintName(StringStream* stream); | 1683 virtual void PrintName(StringStream* stream); |
| 1633 | 1684 |
| 1634 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. | 1685 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. |
| 1635 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; | 1686 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; |
| 1636 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; | 1687 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; |
| 1637 | 1688 |
| 1638 Major MajorKey() { return CallFunction; } | 1689 Major MajorKey() { return CallFunction; } |
| 1639 int MinorKey() { | 1690 int MinorKey() { |
| 1640 // Encode the parameters in a unique 32 bit value. | 1691 // Encode the parameters in a unique 32 bit value. |
| 1641 return FlagBits::encode(flags_) | ArgcBits::encode(argc_); | 1692 return FlagBits::encode(flags_) | ArgcBits::encode(argc_); |
| 1642 } | 1693 } |
| 1643 | 1694 |
| 1644 bool RecordCallTarget() { | |
| 1645 return flags_ == RECORD_CALL_TARGET; | |
| 1646 } | |
| 1647 | |
| 1648 bool CallAsMethod() { | 1695 bool CallAsMethod() { |
| 1649 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL; | 1696 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL; |
| 1650 } | 1697 } |
| 1651 | 1698 |
| 1652 bool NeedsChecks() { | 1699 bool NeedsChecks() { |
| 1653 return flags_ != WRAP_AND_CALL; | 1700 return flags_ != WRAP_AND_CALL; |
| 1654 } | 1701 } |
| 1655 }; | 1702 }; |
| 1656 | 1703 |
| 1657 | 1704 |
| 1658 class CallConstructStub: public PlatformCodeStub { | 1705 class CallConstructStub: public PlatformCodeStub { |
| 1659 public: | 1706 public: |
| 1660 explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} | 1707 explicit CallConstructStub(CallConstructorFlags flags) : flags_(flags) {} |
| 1661 | 1708 |
| 1662 void Generate(MacroAssembler* masm); | 1709 void Generate(MacroAssembler* masm); |
| 1663 | 1710 |
| 1664 virtual void FinishCode(Handle<Code> code) { | 1711 virtual void FinishCode(Handle<Code> code) { |
| 1665 code->set_has_function_cache(RecordCallTarget()); | 1712 code->set_has_function_cache(RecordCallTarget()); |
| 1666 } | 1713 } |
| 1667 | 1714 |
| 1668 private: | 1715 private: |
| 1669 CallFunctionFlags flags_; | 1716 CallConstructorFlags flags_; |
| 1670 | 1717 |
| 1671 virtual void PrintName(StringStream* stream); | 1718 virtual void PrintName(StringStream* stream); |
| 1672 | 1719 |
| 1673 Major MajorKey() { return CallConstruct; } | 1720 Major MajorKey() { return CallConstruct; } |
| 1674 int MinorKey() { return flags_; } | 1721 int MinorKey() { return flags_; } |
| 1675 | 1722 |
| 1676 bool RecordCallTarget() { | 1723 bool RecordCallTarget() { |
| 1677 return (flags_ & RECORD_CALL_TARGET) != 0; | 1724 return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0; |
| 1678 } | |
| 1679 | |
| 1680 bool CallAsMethod() { | |
| 1681 return (flags_ & CALL_AS_METHOD) != 0; | |
| 1682 } | 1725 } |
| 1683 }; | 1726 }; |
| 1684 | 1727 |
| 1685 | 1728 |
| 1686 enum StringIndexFlags { | 1729 enum StringIndexFlags { |
| 1687 // Accepts smis or heap numbers. | 1730 // Accepts smis or heap numbers. |
| 1688 STRING_INDEX_IS_NUMBER, | 1731 STRING_INDEX_IS_NUMBER, |
| 1689 | 1732 |
| 1690 // Accepts smis or heap numbers that are valid array indices | 1733 // Accepts smis or heap numbers that are valid array indices |
| 1691 // (ECMA-262 15.4). Invalid indices are reported as being out of | 1734 // (ECMA-262 15.4). Invalid indices are reported as being out of |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2511 | 2554 |
| 2512 | 2555 |
| 2513 class CallDescriptors { | 2556 class CallDescriptors { |
| 2514 public: | 2557 public: |
| 2515 static void InitializeForIsolate(Isolate* isolate); | 2558 static void InitializeForIsolate(Isolate* isolate); |
| 2516 }; | 2559 }; |
| 2517 | 2560 |
| 2518 } } // namespace v8::internal | 2561 } } // namespace v8::internal |
| 2519 | 2562 |
| 2520 #endif // V8_CODE_STUBS_H_ | 2563 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |