]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | /* |
2 | * Copyright (C) 2013 Apple Inc. All rights reserved. | |
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) \ | |
38 | macro(length) \ | |
39 | macro(structureTable) \ | |
40 | macro(typedArrayProperties) \ | |
41 | macro(WriteBarrierBuffer_bufferContents) | |
42 | ||
43 | #define FOR_EACH_ABSTRACT_FIELD(macro) \ | |
44 | macro(ArrayBuffer_data, ArrayBuffer::offsetOfData()) \ | |
45 | macro(Butterfly_arrayBuffer, Butterfly::offsetOfArrayBuffer()) \ | |
46 | macro(Butterfly_publicLength, Butterfly::offsetOfPublicLength()) \ | |
47 | macro(Butterfly_vectorLength, Butterfly::offsetOfVectorLength()) \ | |
48 | macro(CallFrame_callerFrame, CallFrame::callerFrameOffset()) \ | |
49 | macro(JSArrayBufferView_length, JSArrayBufferView::offsetOfLength()) \ | |
50 | macro(JSArrayBufferView_mode, JSArrayBufferView::offsetOfMode()) \ | |
51 | macro(JSArrayBufferView_vector, JSArrayBufferView::offsetOfVector()) \ | |
52 | macro(JSCell_structureID, JSCell::structureIDOffset()) \ | |
53 | macro(JSCell_typeInfoFlags, JSCell::typeInfoFlagsOffset()) \ | |
54 | macro(JSCell_typeInfoType, JSCell::typeInfoTypeOffset()) \ | |
55 | macro(JSCell_indexingType, JSCell::indexingTypeOffset()) \ | |
56 | macro(JSCell_gcData, JSCell::gcDataOffset()) \ | |
57 | macro(JSFunction_executable, JSFunction::offsetOfExecutable()) \ | |
58 | macro(JSFunction_scope, JSFunction::offsetOfScopeChain()) \ | |
59 | macro(JSObject_butterfly, JSObject::butterflyOffset()) \ | |
60 | macro(JSScope_next, JSScope::offsetOfNext()) \ | |
61 | macro(JSString_flags, JSString::offsetOfFlags()) \ | |
62 | macro(JSString_length, JSString::offsetOfLength()) \ | |
63 | macro(JSString_value, JSString::offsetOfValue()) \ | |
64 | macro(JSVariableObject_registers, JSVariableObject::offsetOfRegisters()) \ | |
65 | macro(JSWrapperObject_internalValue, JSWrapperObject::internalValueOffset()) \ | |
66 | macro(MarkedAllocator_freeListHead, MarkedAllocator::offsetOfFreeListHead()) \ | |
67 | macro(MarkedBlock_markBits, MarkedBlock::offsetOfMarks()) \ | |
68 | macro(StringImpl_data, StringImpl::dataOffset()) \ | |
69 | macro(StringImpl_hashAndFlags, StringImpl::flagsOffset()) \ | |
70 | macro(Structure_classInfo, Structure::classInfoOffset()) \ | |
71 | macro(Structure_globalObject, Structure::globalObjectOffset()) \ | |
72 | macro(Structure_prototype, Structure::prototypeOffset()) \ | |
73 | macro(Structure_structureID, Structure::structureIDOffset()) | |
74 | ||
75 | #define FOR_EACH_INDEXED_ABSTRACT_HEAP(macro) \ | |
76 | macro(JSRopeString_fibers, JSRopeString::offsetOfFibers(), sizeof(WriteBarrier<JSString>)) \ | |
77 | macro(characters8, 0, sizeof(LChar)) \ | |
78 | macro(characters16, 0, sizeof(UChar)) \ | |
79 | macro(indexedInt32Properties, 0, sizeof(EncodedJSValue)) \ | |
80 | macro(indexedDoubleProperties, 0, sizeof(double)) \ | |
81 | macro(indexedContiguousProperties, 0, sizeof(EncodedJSValue)) \ | |
82 | macro(indexedArrayStorageProperties, 0, sizeof(EncodedJSValue)) \ | |
83 | macro(singleCharacterStrings, 0, sizeof(JSString*)) \ | |
84 | macro(variables, 0, sizeof(Register)) | |
85 | ||
86 | #define FOR_EACH_NUMBERED_ABSTRACT_HEAP(macro) \ | |
87 | macro(properties) | |
88 | ||
89 | // This class is meant to be cacheable between compilations, but it doesn't have to be. | |
90 | // Doing so saves on creation of nodes. But clearing it will save memory. | |
91 | ||
92 | class AbstractHeapRepository { | |
93 | WTF_MAKE_NONCOPYABLE(AbstractHeapRepository); | |
94 | public: | |
95 | AbstractHeapRepository(LContext); | |
96 | ~AbstractHeapRepository(); | |
97 | ||
98 | AbstractHeap root; | |
99 | ||
100 | #define ABSTRACT_HEAP_DECLARATION(name) AbstractHeap name; | |
101 | FOR_EACH_ABSTRACT_HEAP(ABSTRACT_HEAP_DECLARATION) | |
102 | #undef ABSTRACT_HEAP_DECLARATION | |
103 | ||
104 | #define ABSTRACT_FIELD_DECLARATION(name, offset) AbstractField name; | |
105 | FOR_EACH_ABSTRACT_FIELD(ABSTRACT_FIELD_DECLARATION) | |
106 | #undef ABSTRACT_FIELD_DECLARATION | |
107 | ||
108 | AbstractField& JSCell_freeListNext; | |
109 | ||
110 | #define INDEXED_ABSTRACT_HEAP_DECLARATION(name, offset, size) IndexedAbstractHeap name; | |
111 | FOR_EACH_INDEXED_ABSTRACT_HEAP(INDEXED_ABSTRACT_HEAP_DECLARATION) | |
112 | #undef INDEXED_ABSTRACT_HEAP_DECLARATION | |
113 | ||
114 | #define NUMBERED_ABSTRACT_HEAP_DECLARATION(name) NumberedAbstractHeap name; | |
115 | FOR_EACH_NUMBERED_ABSTRACT_HEAP(NUMBERED_ABSTRACT_HEAP_DECLARATION) | |
116 | #undef NUMBERED_ABSTRACT_HEAP_DECLARATION | |
117 | ||
118 | AbsoluteAbstractHeap absolute; | |
119 | ||
120 | IndexedAbstractHeap* forIndexingType(IndexingType indexingType) | |
121 | { | |
122 | switch (indexingType) { | |
123 | case ALL_BLANK_INDEXING_TYPES: | |
124 | case ALL_UNDECIDED_INDEXING_TYPES: | |
125 | return 0; | |
126 | ||
127 | case ALL_INT32_INDEXING_TYPES: | |
128 | return &indexedInt32Properties; | |
129 | ||
130 | case ALL_DOUBLE_INDEXING_TYPES: | |
131 | return &indexedDoubleProperties; | |
132 | ||
133 | case ALL_CONTIGUOUS_INDEXING_TYPES: | |
134 | return &indexedContiguousProperties; | |
135 | ||
136 | case ALL_ARRAY_STORAGE_INDEXING_TYPES: | |
137 | return &indexedArrayStorageProperties; | |
138 | ||
139 | default: | |
140 | RELEASE_ASSERT_NOT_REACHED(); | |
141 | return 0; | |
142 | } | |
143 | } | |
144 | ||
145 | IndexedAbstractHeap& forArrayType(DFG::Array::Type type) | |
146 | { | |
147 | switch (type) { | |
148 | case DFG::Array::Int32: | |
149 | return indexedInt32Properties; | |
150 | case DFG::Array::Double: | |
151 | return indexedDoubleProperties; | |
152 | case DFG::Array::Contiguous: | |
153 | return indexedContiguousProperties; | |
154 | case DFG::Array::ArrayStorage: | |
155 | case DFG::Array::SlowPutArrayStorage: | |
156 | return indexedArrayStorageProperties; | |
157 | default: | |
158 | RELEASE_ASSERT_NOT_REACHED(); | |
159 | return indexedInt32Properties; | |
160 | } | |
161 | } | |
162 | ||
163 | private: | |
164 | friend class AbstractHeap; | |
165 | ||
166 | LContext m_context; | |
167 | unsigned m_tbaaKind; | |
168 | }; | |
169 | ||
170 | } } // namespace JSC::FTL | |
171 | ||
172 | #endif // ENABLE(FTL_JIT) | |
173 | ||
174 | #endif // FTLAbstractHeapRepository_h | |
175 |