1/*
2 * Copyright (C) 2012, 2013, 2015 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. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef SlotVisitorInlines_h
27#define SlotVisitorInlines_h
28
29#include "SlotVisitor.h"
30#include "Weak.h"
31#include "WeakInlines.h"
32
33namespace JSC {
34
35template<typename T>
36inline void SlotVisitor::appendUnbarrieredPointer(T** slot)
37{
38 ASSERT(slot);
39 append(*slot);
40}
41
42template<typename T>
43inline void SlotVisitor::appendUnbarrieredReadOnlyPointer(T* cell)
44{
45 append(cell);
46}
47
48inline void SlotVisitor::appendUnbarrieredValue(JSValue* slot)
49{
50 ASSERT(slot);
51 append(*slot);
52}
53
54inline void SlotVisitor::appendUnbarrieredReadOnlyValue(JSValue value)
55{
56 append(value);
57}
58
59template<typename T>
60inline void SlotVisitor::appendUnbarrieredWeak(Weak<T>* weak)
61{
62 ASSERT(weak);
63 append(weak->get());
64}
65
66template<typename T>
67inline void SlotVisitor::append(WriteBarrierBase<T>* slot)
68{
69 append(slot->get());
70}
71
72template<typename Iterator>
73inline void SlotVisitor::append(Iterator begin, Iterator end)
74{
75 for (auto it = begin; it != end; ++it)
76 append(&*it);
77}
78
79inline void SlotVisitor::appendValues(WriteBarrierBase<Unknown>* barriers, size_t count)
80{
81 for (size_t i = 0; i < count; ++i)
82 append(&barriers[i]);
83}
84
85inline void SlotVisitor::addWeakReferenceHarvester(WeakReferenceHarvester* weakReferenceHarvester)
86{
87 m_heap.m_weakReferenceHarvesters.addThreadSafe(weakReferenceHarvester);
88}
89
90inline void SlotVisitor::addUnconditionalFinalizer(UnconditionalFinalizer* unconditionalFinalizer)
91{
92 m_heap.m_unconditionalFinalizers.addThreadSafe(unconditionalFinalizer);
93}
94
95inline void SlotVisitor::reportExtraMemoryVisited(size_t size)
96{
97 heap()->reportExtraMemoryVisited(m_currentObjectCellStateBeforeVisiting, size);
98}
99
100inline Heap* SlotVisitor::heap() const
101{
102 return &m_heap;
103}
104
105inline VM& SlotVisitor::vm()
106{
107 return *m_heap.m_vm;
108}
109
110inline const VM& SlotVisitor::vm() const
111{
112 return *m_heap.m_vm;
113}
114
115} // namespace JSC
116
117#endif // SlotVisitorInlines_h
118
119