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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 | 832 |
832 virtual int MinorKey() { | 833 virtual int MinorKey() { |
833 return KindBits::encode(kind_); | 834 return KindBits::encode(kind_); |
834 } | 835 } |
835 | 836 |
836 private: | 837 private: |
837 Code::Kind kind_; | 838 Code::Kind kind_; |
838 }; | 839 }; |
839 | 840 |
840 | 841 |
| 842 class CallICStub: public PlatformCodeStub { |
| 843 public: |
| 844 explicit CallICStub(const CallIC::State& state) |
| 845 : state_(state) {} |
| 846 |
| 847 bool CallAsMethod() const { return state_.CallAsMethod(); } |
| 848 |
| 849 int arg_count() const { return state_.arg_count(); } |
| 850 |
| 851 static int ExtractArgcFromMinorKey(int minor_key) { |
| 852 CallIC::State state((ExtraICState) minor_key); |
| 853 return state.arg_count(); |
| 854 } |
| 855 |
| 856 virtual void Generate(MacroAssembler* masm); |
| 857 |
| 858 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { |
| 859 return Code::CALL_IC; |
| 860 } |
| 861 |
| 862 virtual InlineCacheState GetICState() V8_FINAL V8_OVERRIDE { |
| 863 return state_.GetICState(); |
| 864 } |
| 865 |
| 866 virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE { |
| 867 return state_.GetExtraICState(); |
| 868 } |
| 869 |
| 870 protected: |
| 871 virtual int MinorKey() { return GetExtraICState(); } |
| 872 virtual void PrintState(StringStream* stream) V8_FINAL V8_OVERRIDE; |
| 873 |
| 874 private: |
| 875 virtual CodeStub::Major MajorKey() { return CallIC; } |
| 876 |
| 877 // Code generation helpers. |
| 878 void GenerateMiss(MacroAssembler* masm); |
| 879 |
| 880 CallIC::State state_; |
| 881 }; |
| 882 |
| 883 |
841 class FunctionPrototypeStub: public ICStub { | 884 class FunctionPrototypeStub: public ICStub { |
842 public: | 885 public: |
843 explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { } | 886 explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { } |
844 virtual void Generate(MacroAssembler* masm); | 887 virtual void Generate(MacroAssembler* masm); |
845 | 888 |
846 private: | 889 private: |
847 virtual CodeStub::Major MajorKey() { return FunctionPrototype; } | 890 virtual CodeStub::Major MajorKey() { return FunctionPrototype; } |
848 }; | 891 }; |
849 | 892 |
850 | 893 |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 }; | 1635 }; |
1593 | 1636 |
1594 | 1637 |
1595 class CallFunctionStub: public PlatformCodeStub { | 1638 class CallFunctionStub: public PlatformCodeStub { |
1596 public: | 1639 public: |
1597 CallFunctionStub(int argc, CallFunctionFlags flags) | 1640 CallFunctionStub(int argc, CallFunctionFlags flags) |
1598 : argc_(argc), flags_(flags) { } | 1641 : argc_(argc), flags_(flags) { } |
1599 | 1642 |
1600 void Generate(MacroAssembler* masm); | 1643 void Generate(MacroAssembler* masm); |
1601 | 1644 |
1602 virtual void FinishCode(Handle<Code> code) { | |
1603 code->set_has_function_cache(RecordCallTarget()); | |
1604 } | |
1605 | |
1606 static int ExtractArgcFromMinorKey(int minor_key) { | 1645 static int ExtractArgcFromMinorKey(int minor_key) { |
1607 return ArgcBits::decode(minor_key); | 1646 return ArgcBits::decode(minor_key); |
1608 } | 1647 } |
1609 | 1648 |
1610 private: | 1649 private: |
1611 int argc_; | 1650 int argc_; |
1612 CallFunctionFlags flags_; | 1651 CallFunctionFlags flags_; |
1613 | 1652 |
1614 virtual void PrintName(StringStream* stream); | 1653 virtual void PrintName(StringStream* stream); |
1615 | 1654 |
1616 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. | 1655 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. |
1617 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; | 1656 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; |
1618 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; | 1657 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; |
1619 | 1658 |
1620 Major MajorKey() { return CallFunction; } | 1659 Major MajorKey() { return CallFunction; } |
1621 int MinorKey() { | 1660 int MinorKey() { |
1622 // Encode the parameters in a unique 32 bit value. | 1661 // Encode the parameters in a unique 32 bit value. |
1623 return FlagBits::encode(flags_) | ArgcBits::encode(argc_); | 1662 return FlagBits::encode(flags_) | ArgcBits::encode(argc_); |
1624 } | 1663 } |
1625 | 1664 |
1626 bool RecordCallTarget() { | |
1627 return flags_ == RECORD_CALL_TARGET; | |
1628 } | |
1629 | |
1630 bool CallAsMethod() { | 1665 bool CallAsMethod() { |
1631 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL; | 1666 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL; |
1632 } | 1667 } |
1633 | 1668 |
1634 bool NeedsChecks() { | 1669 bool NeedsChecks() { |
1635 return flags_ != WRAP_AND_CALL; | 1670 return flags_ != WRAP_AND_CALL; |
1636 } | 1671 } |
1637 }; | 1672 }; |
1638 | 1673 |
1639 | 1674 |
1640 class CallConstructStub: public PlatformCodeStub { | 1675 class CallConstructStub: public PlatformCodeStub { |
1641 public: | 1676 public: |
1642 explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} | 1677 explicit CallConstructStub(CallConstructorFlags flags) : flags_(flags) {} |
1643 | 1678 |
1644 void Generate(MacroAssembler* masm); | 1679 void Generate(MacroAssembler* masm); |
1645 | 1680 |
1646 virtual void FinishCode(Handle<Code> code) { | 1681 virtual void FinishCode(Handle<Code> code) { |
1647 code->set_has_function_cache(RecordCallTarget()); | 1682 code->set_has_function_cache(RecordCallTarget()); |
1648 } | 1683 } |
1649 | 1684 |
1650 private: | 1685 private: |
1651 CallFunctionFlags flags_; | 1686 CallConstructorFlags flags_; |
1652 | 1687 |
1653 virtual void PrintName(StringStream* stream); | 1688 virtual void PrintName(StringStream* stream); |
1654 | 1689 |
1655 Major MajorKey() { return CallConstruct; } | 1690 Major MajorKey() { return CallConstruct; } |
1656 int MinorKey() { return flags_; } | 1691 int MinorKey() { return flags_; } |
1657 | 1692 |
1658 bool RecordCallTarget() { | 1693 bool RecordCallTarget() { |
1659 return (flags_ & RECORD_CALL_TARGET) != 0; | 1694 return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0; |
1660 } | |
1661 | |
1662 bool CallAsMethod() { | |
1663 return (flags_ & CALL_AS_METHOD) != 0; | |
1664 } | 1695 } |
1665 }; | 1696 }; |
1666 | 1697 |
1667 | 1698 |
1668 enum StringIndexFlags { | 1699 enum StringIndexFlags { |
1669 // Accepts smis or heap numbers. | 1700 // Accepts smis or heap numbers. |
1670 STRING_INDEX_IS_NUMBER, | 1701 STRING_INDEX_IS_NUMBER, |
1671 | 1702 |
1672 // Accepts smis or heap numbers that are valid array indices | 1703 // Accepts smis or heap numbers that are valid array indices |
1673 // (ECMA-262 15.4). Invalid indices are reported as being out of | 1704 // (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... |
2493 | 2524 |
2494 | 2525 |
2495 class CallDescriptors { | 2526 class CallDescriptors { |
2496 public: | 2527 public: |
2497 static void InitializeForIsolate(Isolate* isolate); | 2528 static void InitializeForIsolate(Isolate* isolate); |
2498 }; | 2529 }; |
2499 | 2530 |
2500 } } // namespace v8::internal | 2531 } } // namespace v8::internal |
2501 | 2532 |
2502 #endif // V8_CODE_STUBS_H_ | 2533 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |