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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 V(VectorKeyedStoreIC) \ | 60 V(VectorKeyedStoreIC) \ |
61 /* HydrogenCodeStubs */ \ | 61 /* HydrogenCodeStubs */ \ |
62 V(AllocateHeapNumber) \ | 62 V(AllocateHeapNumber) \ |
63 V(AllocateMutableHeapNumber) \ | 63 V(AllocateMutableHeapNumber) \ |
64 V(AllocateInNewSpace) \ | 64 V(AllocateInNewSpace) \ |
65 V(ArrayNArgumentsConstructor) \ | 65 V(ArrayNArgumentsConstructor) \ |
66 V(ArrayNoArgumentConstructor) \ | 66 V(ArrayNoArgumentConstructor) \ |
67 V(ArraySingleArgumentConstructor) \ | 67 V(ArraySingleArgumentConstructor) \ |
68 V(BinaryOpIC) \ | 68 V(BinaryOpIC) \ |
69 V(BinaryOpWithAllocationSite) \ | 69 V(BinaryOpWithAllocationSite) \ |
| 70 V(CompareNilIC) \ |
70 V(CreateAllocationSite) \ | 71 V(CreateAllocationSite) \ |
71 V(CreateWeakCell) \ | 72 V(CreateWeakCell) \ |
72 V(ElementsTransitionAndStore) \ | 73 V(ElementsTransitionAndStore) \ |
73 V(FastCloneRegExp) \ | 74 V(FastCloneRegExp) \ |
74 V(FastCloneShallowArray) \ | 75 V(FastCloneShallowArray) \ |
75 V(FastCloneShallowObject) \ | 76 V(FastCloneShallowObject) \ |
76 V(FastNewClosure) \ | 77 V(FastNewClosure) \ |
77 V(FastNewContext) \ | 78 V(FastNewContext) \ |
78 V(FastNewObject) \ | 79 V(FastNewObject) \ |
79 V(FastNewRestParameter) \ | 80 V(FastNewRestParameter) \ |
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 class RightStateBits : public BitField<CompareICState::State, 7, 4> {}; | 1694 class RightStateBits : public BitField<CompareICState::State, 7, 4> {}; |
1694 class StateBits : public BitField<CompareICState::State, 11, 4> {}; | 1695 class StateBits : public BitField<CompareICState::State, 11, 4> {}; |
1695 | 1696 |
1696 Handle<Map> known_map_; | 1697 Handle<Map> known_map_; |
1697 | 1698 |
1698 DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); | 1699 DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
1699 DEFINE_PLATFORM_CODE_STUB(CompareIC, PlatformCodeStub); | 1700 DEFINE_PLATFORM_CODE_STUB(CompareIC, PlatformCodeStub); |
1700 }; | 1701 }; |
1701 | 1702 |
1702 | 1703 |
| 1704 class CompareNilICStub : public HydrogenCodeStub { |
| 1705 public: |
| 1706 Type* GetType(Zone* zone, Handle<Map> map = Handle<Map>()); |
| 1707 Type* GetInputType(Zone* zone, Handle<Map> map); |
| 1708 |
| 1709 CompareNilICStub(Isolate* isolate, NilValue nil) : HydrogenCodeStub(isolate) { |
| 1710 set_sub_minor_key(NilValueBits::encode(nil)); |
| 1711 } |
| 1712 |
| 1713 CompareNilICStub(Isolate* isolate, ExtraICState ic_state, |
| 1714 InitializationState init_state = INITIALIZED) |
| 1715 : HydrogenCodeStub(isolate, init_state) { |
| 1716 set_sub_minor_key(ic_state); |
| 1717 } |
| 1718 |
| 1719 static Handle<Code> GetUninitialized(Isolate* isolate, |
| 1720 NilValue nil) { |
| 1721 return CompareNilICStub(isolate, nil, UNINITIALIZED).GetCode(); |
| 1722 } |
| 1723 |
| 1724 InlineCacheState GetICState() const override { |
| 1725 State state = this->state(); |
| 1726 if (state.Contains(GENERIC)) { |
| 1727 return MEGAMORPHIC; |
| 1728 } else if (state.Contains(MONOMORPHIC_MAP)) { |
| 1729 return MONOMORPHIC; |
| 1730 } else { |
| 1731 return PREMONOMORPHIC; |
| 1732 } |
| 1733 } |
| 1734 |
| 1735 Code::Kind GetCodeKind() const override { return Code::COMPARE_NIL_IC; } |
| 1736 |
| 1737 ExtraICState GetExtraICState() const override { return sub_minor_key(); } |
| 1738 |
| 1739 void UpdateStatus(Handle<Object> object); |
| 1740 |
| 1741 bool IsMonomorphic() const { return state().Contains(MONOMORPHIC_MAP); } |
| 1742 |
| 1743 NilValue nil_value() const { return NilValueBits::decode(sub_minor_key()); } |
| 1744 |
| 1745 void ClearState() { |
| 1746 set_sub_minor_key(TypesBits::update(sub_minor_key(), 0)); |
| 1747 } |
| 1748 |
| 1749 void PrintState(std::ostream& os) const override; // NOLINT |
| 1750 void PrintBaseName(std::ostream& os) const override; // NOLINT |
| 1751 |
| 1752 private: |
| 1753 CompareNilICStub(Isolate* isolate, NilValue nil, |
| 1754 InitializationState init_state) |
| 1755 : HydrogenCodeStub(isolate, init_state) { |
| 1756 set_sub_minor_key(NilValueBits::encode(nil)); |
| 1757 } |
| 1758 |
| 1759 enum CompareNilType { |
| 1760 UNDEFINED, |
| 1761 NULL_TYPE, |
| 1762 MONOMORPHIC_MAP, |
| 1763 GENERIC, |
| 1764 NUMBER_OF_TYPES |
| 1765 }; |
| 1766 |
| 1767 // At most 6 different types can be distinguished, because the Code object |
| 1768 // only has room for a single byte to hold a set and there are two more |
| 1769 // boolean flags we need to store. :-P |
| 1770 STATIC_ASSERT(NUMBER_OF_TYPES <= 6); |
| 1771 |
| 1772 class State : public EnumSet<CompareNilType, byte> { |
| 1773 public: |
| 1774 State() : EnumSet<CompareNilType, byte>(0) { } |
| 1775 explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { } |
| 1776 }; |
| 1777 friend std::ostream& operator<<(std::ostream& os, const State& s); |
| 1778 |
| 1779 State state() const { return State(TypesBits::decode(sub_minor_key())); } |
| 1780 |
| 1781 class NilValueBits : public BitField<NilValue, 0, 1> {}; |
| 1782 class TypesBits : public BitField<byte, 1, NUMBER_OF_TYPES> {}; |
| 1783 |
| 1784 friend class CompareNilIC; |
| 1785 |
| 1786 DEFINE_CALL_INTERFACE_DESCRIPTOR(CompareNil); |
| 1787 DEFINE_HYDROGEN_CODE_STUB(CompareNilIC, HydrogenCodeStub); |
| 1788 }; |
| 1789 |
| 1790 |
| 1791 std::ostream& operator<<(std::ostream& os, const CompareNilICStub::State& s); |
| 1792 |
| 1793 |
1703 class CEntryStub : public PlatformCodeStub { | 1794 class CEntryStub : public PlatformCodeStub { |
1704 public: | 1795 public: |
1705 CEntryStub(Isolate* isolate, int result_size, | 1796 CEntryStub(Isolate* isolate, int result_size, |
1706 SaveFPRegsMode save_doubles = kDontSaveFPRegs, | 1797 SaveFPRegsMode save_doubles = kDontSaveFPRegs, |
1707 ArgvMode argv_mode = kArgvOnStack) | 1798 ArgvMode argv_mode = kArgvOnStack) |
1708 : PlatformCodeStub(isolate) { | 1799 : PlatformCodeStub(isolate) { |
1709 minor_key_ = SaveDoublesBits::encode(save_doubles == kSaveFPRegs) | | 1800 minor_key_ = SaveDoublesBits::encode(save_doubles == kSaveFPRegs) | |
1710 ArgvMode::encode(argv_mode == kArgvInRegister); | 1801 ArgvMode::encode(argv_mode == kArgvInRegister); |
1711 DCHECK(result_size == 1 || result_size == 2 || result_size == 3); | 1802 DCHECK(result_size == 1 || result_size == 2 || result_size == 3); |
1712 minor_key_ = ResultSizeBits::update(minor_key_, result_size); | 1803 minor_key_ = ResultSizeBits::update(minor_key_, result_size); |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2875 #undef DEFINE_HYDROGEN_CODE_STUB | 2966 #undef DEFINE_HYDROGEN_CODE_STUB |
2876 #undef DEFINE_CODE_STUB | 2967 #undef DEFINE_CODE_STUB |
2877 #undef DEFINE_CODE_STUB_BASE | 2968 #undef DEFINE_CODE_STUB_BASE |
2878 | 2969 |
2879 extern Representation RepresentationFromType(Type* type); | 2970 extern Representation RepresentationFromType(Type* type); |
2880 | 2971 |
2881 } // namespace internal | 2972 } // namespace internal |
2882 } // namespace v8 | 2973 } // namespace v8 |
2883 | 2974 |
2884 #endif // V8_CODE_STUBS_H_ | 2975 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |