1 | /* |
2 | * Copyright (C) 2016 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 | #pragma once |
27 | |
28 | #include "CellContainer.h" |
29 | #include "JSCast.h" |
30 | #include "LargeAllocation.h" |
31 | #include "MarkedBlock.h" |
32 | #include "VM.h" |
33 | |
34 | namespace JSC { |
35 | |
36 | inline VM* CellContainer::vm() const |
37 | { |
38 | if (isLargeAllocation()) |
39 | return largeAllocation().vm(); |
40 | return markedBlock().vm(); |
41 | } |
42 | |
43 | inline Heap* CellContainer::heap() const |
44 | { |
45 | return &vm()->heap; |
46 | } |
47 | |
48 | inline bool CellContainer::isMarked(HeapCell* cell) const |
49 | { |
50 | if (isLargeAllocation()) |
51 | return largeAllocation().isMarked(); |
52 | return markedBlock().isMarked(cell); |
53 | } |
54 | |
55 | inline bool CellContainer::isMarked(HeapVersion markingVersion, HeapCell* cell) const |
56 | { |
57 | if (isLargeAllocation()) |
58 | return largeAllocation().isMarked(); |
59 | return markedBlock().isMarked(markingVersion, cell); |
60 | } |
61 | |
62 | inline void CellContainer::noteMarked() |
63 | { |
64 | if (!isLargeAllocation()) |
65 | markedBlock().noteMarked(); |
66 | } |
67 | |
68 | inline void CellContainer::assertValidCell(VM& vm, HeapCell* cell) const |
69 | { |
70 | if (isLargeAllocation()) |
71 | largeAllocation().assertValidCell(vm, cell); |
72 | else |
73 | markedBlock().assertValidCell(vm, cell); |
74 | } |
75 | |
76 | inline size_t CellContainer::cellSize() const |
77 | { |
78 | if (isLargeAllocation()) |
79 | return largeAllocation().cellSize(); |
80 | return markedBlock().cellSize(); |
81 | } |
82 | |
83 | inline WeakSet& CellContainer::weakSet() const |
84 | { |
85 | if (isLargeAllocation()) |
86 | return largeAllocation().weakSet(); |
87 | return markedBlock().weakSet(); |
88 | } |
89 | |
90 | inline void CellContainer::aboutToMark(HeapVersion markingVersion) |
91 | { |
92 | if (!isLargeAllocation()) |
93 | markedBlock().aboutToMark(markingVersion); |
94 | } |
95 | |
96 | inline bool CellContainer::() const |
97 | { |
98 | if (isLargeAllocation()) |
99 | return false; |
100 | return markedBlock().areMarksStale(); |
101 | } |
102 | |
103 | } // namespace JSC |
104 | |
105 | |