]>
git.saurik.com Git - apple/javascriptcore.git/blob - heap/MarkStackInlines.h
2 * Copyright (C) 2009, 2011 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.
26 #ifndef MarkStackInlines_h
27 #define MarkStackInlines_h
29 #include "GCThreadSharedData.h"
30 #include "MarkStack.h"
34 inline MarkStackSegment
* MarkStackSegment::create(DeadBlock
* block
)
36 return new (NotNull
, block
) MarkStackSegment(block
->region());
39 inline size_t MarkStackArray::postIncTop()
41 size_t result
= m_top
++;
42 ASSERT(result
== m_segments
.head()->m_top
++);
46 inline size_t MarkStackArray::preDecTop()
48 size_t result
= --m_top
;
49 ASSERT(result
== --m_segments
.head()->m_top
);
53 inline void MarkStackArray::setTopForFullSegment()
55 ASSERT(m_segments
.head()->m_top
== s_segmentCapacity
);
56 m_top
= s_segmentCapacity
;
59 inline void MarkStackArray::setTopForEmptySegment()
61 ASSERT(!m_segments
.head()->m_top
);
65 inline size_t MarkStackArray::top()
67 ASSERT(m_top
== m_segments
.head()->m_top
);
72 inline void MarkStackArray::validatePrevious() { }
74 inline void MarkStackArray::validatePrevious()
77 for (MarkStackSegment
* current
= m_segments
.head(); current
; current
= current
->next())
79 ASSERT(m_segments
.size() == m_numberOfSegments
);
83 inline void MarkStackArray::append(const JSCell
* cell
)
85 if (m_top
== s_segmentCapacity
)
87 m_segments
.head()->data()[postIncTop()] = cell
;
90 inline bool MarkStackArray::canRemoveLast()
95 inline const JSCell
* MarkStackArray::removeLast()
97 return m_segments
.head()->data()[preDecTop()];
100 inline bool MarkStackArray::isEmpty()
104 if (m_segments
.head()->next()) {
105 ASSERT(m_segments
.head()->next()->m_top
== s_segmentCapacity
);
111 inline size_t MarkStackArray::size()
113 return m_top
+ s_segmentCapacity
* (m_numberOfSegments
- 1);
118 #endif // MarkStackInlines_h