2 * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "FTLAbstractHeapRepository.h"
31 #include "B3CCallValue.h"
32 #include "B3MemoryValue.h"
33 #include "B3PatchpointValue.h"
34 #include "B3ValueInlines.h"
35 #include "DirectArguments.h"
37 #include "GetterSetter.h"
38 #include "JSEnvironmentRecord.h"
39 #include "JSPropertyNameEnumerator.h"
41 #include "JSCInlines.h"
42 #include "ScopedArguments.h"
43 #include "ScopedArgumentsTable.h"
45 namespace JSC { namespace FTL {
49 AbstractHeapRepository::AbstractHeapRepository()
50 : root(nullptr, "jscRoot")
52 #define ABSTRACT_HEAP_INITIALIZATION(name) , name(&root, #name)
53 FOR_EACH_ABSTRACT_HEAP(ABSTRACT_HEAP_INITIALIZATION)
54 #undef ABSTRACT_HEAP_INITIALIZATION
56 #define ABSTRACT_FIELD_INITIALIZATION(name, offset) , name(&root, #name, offset)
57 FOR_EACH_ABSTRACT_FIELD(ABSTRACT_FIELD_INITIALIZATION)
58 #undef ABSTRACT_FIELD_INITIALIZATION
60 , JSCell_freeListNext(JSCell_structureID)
62 #define INDEXED_ABSTRACT_HEAP_INITIALIZATION(name, offset, size) , name(&root, #name, offset, size)
63 FOR_EACH_INDEXED_ABSTRACT_HEAP(INDEXED_ABSTRACT_HEAP_INITIALIZATION)
64 #undef INDEXED_ABSTRACT_HEAP_INITIALIZATION
66 #define NUMBERED_ABSTRACT_HEAP_INITIALIZATION(name) , name(&root, #name)
67 FOR_EACH_NUMBERED_ABSTRACT_HEAP(NUMBERED_ABSTRACT_HEAP_INITIALIZATION)
68 #undef NUMBERED_ABSTRACT_HEAP_INITIALIZATION
70 , absolute(&root, "absolute")
72 // Make sure that our explicit assumptions about the StructureIDBlob match reality.
73 RELEASE_ASSERT(!(JSCell_indexingType.offset() & (sizeof(int32_t) - 1)));
74 RELEASE_ASSERT(JSCell_indexingType.offset() + 1 == JSCell_typeInfoType.offset());
75 RELEASE_ASSERT(JSCell_indexingType.offset() + 2 == JSCell_typeInfoFlags.offset());
76 RELEASE_ASSERT(JSCell_indexingType.offset() + 3 == JSCell_cellState.offset());
78 JSCell_indexingType.changeParent(&JSCell_usefulBytes);
79 JSCell_typeInfoType.changeParent(&JSCell_usefulBytes);
80 JSCell_typeInfoFlags.changeParent(&JSCell_usefulBytes);
81 JSCell_cellState.changeParent(&JSCell_usefulBytes);
83 RELEASE_ASSERT(!JSCell_freeListNext.offset());
86 AbstractHeapRepository::~AbstractHeapRepository()
90 void AbstractHeapRepository::decorateMemory(const AbstractHeap* heap, Value* value)
92 m_heapForMemory.append(HeapForValue(heap, value));
95 void AbstractHeapRepository::decorateCCallRead(const AbstractHeap* heap, Value* value)
97 m_heapForCCallRead.append(HeapForValue(heap, value));
100 void AbstractHeapRepository::decorateCCallWrite(const AbstractHeap* heap, Value* value)
102 m_heapForCCallWrite.append(HeapForValue(heap, value));
105 void AbstractHeapRepository::decoratePatchpointRead(const AbstractHeap* heap, Value* value)
107 m_heapForPatchpointRead.append(HeapForValue(heap, value));
110 void AbstractHeapRepository::decoratePatchpointWrite(const AbstractHeap* heap, Value* value)
112 m_heapForPatchpointWrite.append(HeapForValue(heap, value));
115 void AbstractHeapRepository::computeRangesAndDecorateInstructions()
119 if (verboseCompilationEnabled()) {
120 dataLog("Abstract Heap Repository:\n");
121 root.deepDump(WTF::dataFile());
124 for (HeapForValue entry : m_heapForMemory)
125 entry.value->as<MemoryValue>()->setRange(entry.heap->range());
126 for (HeapForValue entry : m_heapForCCallRead)
127 entry.value->as<CCallValue>()->effects.reads = entry.heap->range();
128 for (HeapForValue entry : m_heapForCCallWrite)
129 entry.value->as<CCallValue>()->effects.writes = entry.heap->range();
130 for (HeapForValue entry : m_heapForPatchpointRead)
131 entry.value->as<CCallValue>()->effects.reads = entry.heap->range();
132 for (HeapForValue entry : m_heapForPatchpointWrite)
133 entry.value->as<CCallValue>()->effects.writes = entry.heap->range();
136 } } // namespace JSC::FTL
138 #endif // ENABLE(FTL_JIT)