]>
Commit | Line | Data |
---|---|---|
81345200 | 1 | /* |
ed1e77d3 | 2 | * Copyright (C) 2013-2015 Apple Inc. All rights reserved. |
81345200 A |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * 1. Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * 2. Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * | |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | |
25 | ||
26 | #ifndef FTLAbstractHeapRepository_h | |
27 | #define FTLAbstractHeapRepository_h | |
28 | ||
29 | #if ENABLE(FTL_JIT) | |
30 | ||
31 | #include "DFGArrayMode.h" | |
32 | #include "FTLAbstractHeap.h" | |
33 | #include "IndexingType.h" | |
34 | ||
35 | namespace JSC { namespace FTL { | |
36 | ||
37 | #define FOR_EACH_ABSTRACT_HEAP(macro) \ | |
ed1e77d3 | 38 | macro(typedArrayProperties) |
81345200 A |
39 | |
40 | #define FOR_EACH_ABSTRACT_FIELD(macro) \ | |
41 | macro(ArrayBuffer_data, ArrayBuffer::offsetOfData()) \ | |
42 | macro(Butterfly_arrayBuffer, Butterfly::offsetOfArrayBuffer()) \ | |
43 | macro(Butterfly_publicLength, Butterfly::offsetOfPublicLength()) \ | |
44 | macro(Butterfly_vectorLength, Butterfly::offsetOfVectorLength()) \ | |
45 | macro(CallFrame_callerFrame, CallFrame::callerFrameOffset()) \ | |
ed1e77d3 A |
46 | macro(DirectArguments_callee, DirectArguments::offsetOfCallee()) \ |
47 | macro(DirectArguments_length, DirectArguments::offsetOfLength()) \ | |
48 | macro(DirectArguments_minCapacity, DirectArguments::offsetOfMinCapacity()) \ | |
49 | macro(DirectArguments_overrides, DirectArguments::offsetOfOverrides()) \ | |
50 | macro(GetterSetter_getter, GetterSetter::offsetOfGetter()) \ | |
51 | macro(GetterSetter_setter, GetterSetter::offsetOfSetter()) \ | |
81345200 A |
52 | macro(JSArrayBufferView_length, JSArrayBufferView::offsetOfLength()) \ |
53 | macro(JSArrayBufferView_mode, JSArrayBufferView::offsetOfMode()) \ | |
54 | macro(JSArrayBufferView_vector, JSArrayBufferView::offsetOfVector()) \ | |
55 | macro(JSCell_structureID, JSCell::structureIDOffset()) \ | |
ed1e77d3 | 56 | macro(JSCell_usefulBytes, JSCell::indexingTypeOffset()) \ |
81345200 A |
57 | macro(JSCell_typeInfoFlags, JSCell::typeInfoFlagsOffset()) \ |
58 | macro(JSCell_typeInfoType, JSCell::typeInfoTypeOffset()) \ | |
59 | macro(JSCell_indexingType, JSCell::indexingTypeOffset()) \ | |
60 | macro(JSCell_gcData, JSCell::gcDataOffset()) \ | |
61 | macro(JSFunction_executable, JSFunction::offsetOfExecutable()) \ | |
62 | macro(JSFunction_scope, JSFunction::offsetOfScopeChain()) \ | |
ed1e77d3 | 63 | macro(JSFunction_rareData, JSFunction::offsetOfRareData()) \ |
81345200 | 64 | macro(JSObject_butterfly, JSObject::butterflyOffset()) \ |
ed1e77d3 A |
65 | macro(JSPropertyNameEnumerator_cachedInlineCapacity, JSPropertyNameEnumerator::cachedInlineCapacityOffset()) \ |
66 | macro(JSPropertyNameEnumerator_cachedPropertyNamesVector, JSPropertyNameEnumerator::cachedPropertyNamesVectorOffset()) \ | |
67 | macro(JSPropertyNameEnumerator_cachedStructureID, JSPropertyNameEnumerator::cachedStructureIDOffset()) \ | |
68 | macro(JSPropertyNameEnumerator_endGenericPropertyIndex, JSPropertyNameEnumerator::endGenericPropertyIndexOffset()) \ | |
69 | macro(JSPropertyNameEnumerator_endStructurePropertyIndex, JSPropertyNameEnumerator::endStructurePropertyIndexOffset()) \ | |
70 | macro(JSPropertyNameEnumerator_indexLength, JSPropertyNameEnumerator::indexedLengthOffset()) \ | |
81345200 A |
71 | macro(JSScope_next, JSScope::offsetOfNext()) \ |
72 | macro(JSString_flags, JSString::offsetOfFlags()) \ | |
73 | macro(JSString_length, JSString::offsetOfLength()) \ | |
74 | macro(JSString_value, JSString::offsetOfValue()) \ | |
ed1e77d3 | 75 | macro(JSSymbolTableObject_symbolTable, JSSymbolTableObject::offsetOfSymbolTable()) \ |
81345200 A |
76 | macro(JSWrapperObject_internalValue, JSWrapperObject::internalValueOffset()) \ |
77 | macro(MarkedAllocator_freeListHead, MarkedAllocator::offsetOfFreeListHead()) \ | |
78 | macro(MarkedBlock_markBits, MarkedBlock::offsetOfMarks()) \ | |
ed1e77d3 A |
79 | macro(ScopedArguments_overrodeThings, ScopedArguments::offsetOfOverrodeThings()) \ |
80 | macro(ScopedArguments_scope, ScopedArguments::offsetOfScope()) \ | |
81 | macro(ScopedArguments_table, ScopedArguments::offsetOfTable()) \ | |
82 | macro(ScopedArguments_totalLength, ScopedArguments::offsetOfTotalLength()) \ | |
83 | macro(ScopedArgumentsTable_arguments, ScopedArgumentsTable::offsetOfArguments()) \ | |
84 | macro(ScopedArgumentsTable_length, ScopedArgumentsTable::offsetOfLength()) \ | |
81345200 A |
85 | macro(StringImpl_data, StringImpl::dataOffset()) \ |
86 | macro(StringImpl_hashAndFlags, StringImpl::flagsOffset()) \ | |
87 | macro(Structure_classInfo, Structure::classInfoOffset()) \ | |
88 | macro(Structure_globalObject, Structure::globalObjectOffset()) \ | |
89 | macro(Structure_prototype, Structure::prototypeOffset()) \ | |
90 | macro(Structure_structureID, Structure::structureIDOffset()) | |
91 | ||
92 | #define FOR_EACH_INDEXED_ABSTRACT_HEAP(macro) \ | |
ed1e77d3 A |
93 | macro(DirectArguments_storage, DirectArguments::storageOffset(), sizeof(EncodedJSValue)) \ |
94 | macro(JSEnvironmentRecord_variables, JSEnvironmentRecord::offsetOfVariables(), sizeof(EncodedJSValue)) \ | |
95 | macro(JSPropertyNameEnumerator_cachedPropertyNamesVectorContents, 0, sizeof(WriteBarrier<JSString>)) \ | |
81345200 | 96 | macro(JSRopeString_fibers, JSRopeString::offsetOfFibers(), sizeof(WriteBarrier<JSString>)) \ |
ed1e77d3 A |
97 | macro(MarkedSpace_Subspace_impreciseAllocators, OBJECT_OFFSETOF(MarkedSpace::Subspace, impreciseAllocators), sizeof(MarkedAllocator)) \ |
98 | macro(MarkedSpace_Subspace_preciseAllocators, OBJECT_OFFSETOF(MarkedSpace::Subspace, preciseAllocators), sizeof(MarkedAllocator)) \ | |
99 | macro(ScopedArguments_overflowStorage, ScopedArguments::overflowStorageOffset(), sizeof(EncodedJSValue)) \ | |
100 | macro(WriteBarrierBuffer_bufferContents, 0, sizeof(JSCell*)) \ | |
81345200 A |
101 | macro(characters8, 0, sizeof(LChar)) \ |
102 | macro(characters16, 0, sizeof(UChar)) \ | |
103 | macro(indexedInt32Properties, 0, sizeof(EncodedJSValue)) \ | |
104 | macro(indexedDoubleProperties, 0, sizeof(double)) \ | |
105 | macro(indexedContiguousProperties, 0, sizeof(EncodedJSValue)) \ | |
106 | macro(indexedArrayStorageProperties, 0, sizeof(EncodedJSValue)) \ | |
ed1e77d3 | 107 | macro(scopedArgumentsTableArguments, 0, sizeof(int32_t)) \ |
81345200 | 108 | macro(singleCharacterStrings, 0, sizeof(JSString*)) \ |
ed1e77d3 | 109 | macro(structureTable, 0, sizeof(Structure*)) \ |
81345200 A |
110 | macro(variables, 0, sizeof(Register)) |
111 | ||
112 | #define FOR_EACH_NUMBERED_ABSTRACT_HEAP(macro) \ | |
113 | macro(properties) | |
114 | ||
115 | // This class is meant to be cacheable between compilations, but it doesn't have to be. | |
116 | // Doing so saves on creation of nodes. But clearing it will save memory. | |
117 | ||
118 | class AbstractHeapRepository { | |
119 | WTF_MAKE_NONCOPYABLE(AbstractHeapRepository); | |
120 | public: | |
121 | AbstractHeapRepository(LContext); | |
122 | ~AbstractHeapRepository(); | |
123 | ||
124 | AbstractHeap root; | |
125 | ||
126 | #define ABSTRACT_HEAP_DECLARATION(name) AbstractHeap name; | |
127 | FOR_EACH_ABSTRACT_HEAP(ABSTRACT_HEAP_DECLARATION) | |
128 | #undef ABSTRACT_HEAP_DECLARATION | |
129 | ||
130 | #define ABSTRACT_FIELD_DECLARATION(name, offset) AbstractField name; | |
131 | FOR_EACH_ABSTRACT_FIELD(ABSTRACT_FIELD_DECLARATION) | |
132 | #undef ABSTRACT_FIELD_DECLARATION | |
133 | ||
134 | AbstractField& JSCell_freeListNext; | |
135 | ||
136 | #define INDEXED_ABSTRACT_HEAP_DECLARATION(name, offset, size) IndexedAbstractHeap name; | |
137 | FOR_EACH_INDEXED_ABSTRACT_HEAP(INDEXED_ABSTRACT_HEAP_DECLARATION) | |
138 | #undef INDEXED_ABSTRACT_HEAP_DECLARATION | |
139 | ||
140 | #define NUMBERED_ABSTRACT_HEAP_DECLARATION(name) NumberedAbstractHeap name; | |
141 | FOR_EACH_NUMBERED_ABSTRACT_HEAP(NUMBERED_ABSTRACT_HEAP_DECLARATION) | |
142 | #undef NUMBERED_ABSTRACT_HEAP_DECLARATION | |
143 | ||
144 | AbsoluteAbstractHeap absolute; | |
145 | ||
146 | IndexedAbstractHeap* forIndexingType(IndexingType indexingType) | |
147 | { | |
148 | switch (indexingType) { | |
149 | case ALL_BLANK_INDEXING_TYPES: | |
150 | case ALL_UNDECIDED_INDEXING_TYPES: | |
151 | return 0; | |
152 | ||
153 | case ALL_INT32_INDEXING_TYPES: | |
154 | return &indexedInt32Properties; | |
155 | ||
156 | case ALL_DOUBLE_INDEXING_TYPES: | |
157 | return &indexedDoubleProperties; | |
158 | ||
159 | case ALL_CONTIGUOUS_INDEXING_TYPES: | |
160 | return &indexedContiguousProperties; | |
161 | ||
162 | case ALL_ARRAY_STORAGE_INDEXING_TYPES: | |
163 | return &indexedArrayStorageProperties; | |
164 | ||
165 | default: | |
166 | RELEASE_ASSERT_NOT_REACHED(); | |
167 | return 0; | |
168 | } | |
169 | } | |
170 | ||
171 | IndexedAbstractHeap& forArrayType(DFG::Array::Type type) | |
172 | { | |
173 | switch (type) { | |
174 | case DFG::Array::Int32: | |
175 | return indexedInt32Properties; | |
176 | case DFG::Array::Double: | |
177 | return indexedDoubleProperties; | |
178 | case DFG::Array::Contiguous: | |
179 | return indexedContiguousProperties; | |
180 | case DFG::Array::ArrayStorage: | |
181 | case DFG::Array::SlowPutArrayStorage: | |
182 | return indexedArrayStorageProperties; | |
183 | default: | |
184 | RELEASE_ASSERT_NOT_REACHED(); | |
185 | return indexedInt32Properties; | |
186 | } | |
187 | } | |
188 | ||
189 | private: | |
190 | friend class AbstractHeap; | |
191 | ||
192 | LContext m_context; | |
193 | unsigned m_tbaaKind; | |
194 | }; | |
195 | ||
196 | } } // namespace JSC::FTL | |
197 | ||
198 | #endif // ENABLE(FTL_JIT) | |
199 | ||
200 | #endif // FTLAbstractHeapRepository_h | |
201 |