1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef gc_StoreBuffer_inl_h
8 #define gc_StoreBuffer_inl_h
10 #include "gc/StoreBuffer.h"
15 #include "gc/Heap-inl.h"
20 inline /* static */ size_t ArenaCellSet::getCellIndex(const TenuredCell
* cell
) {
21 uintptr_t cellOffset
= uintptr_t(cell
) & ArenaMask
;
22 MOZ_ASSERT(cellOffset
% ArenaCellIndexBytes
== 0);
23 return cellOffset
/ ArenaCellIndexBytes
;
26 inline /* static */ void ArenaCellSet::getWordIndexAndMask(size_t cellIndex
,
29 BitArray
<MaxArenaCellIndex
>::getIndexAndMask(cellIndex
, wordp
, maskp
);
32 inline bool ArenaCellSet::hasCell(size_t cellIndex
) const {
33 MOZ_ASSERT(cellIndex
< MaxArenaCellIndex
);
34 return bits
.get(cellIndex
);
37 inline void ArenaCellSet::putCell(size_t cellIndex
) {
38 MOZ_ASSERT(cellIndex
< MaxArenaCellIndex
);
45 inline void ArenaCellSet::check() const {
47 bool bitsZero
= bits
.isAllClear();
48 MOZ_ASSERT(isEmpty() == bitsZero
);
49 MOZ_ASSERT(isEmpty() == !arena
);
51 MOZ_ASSERT(IsCellPointerValid(arena
));
52 JSRuntime
* runtime
= arena
->zone
->runtimeFromMainThread();
53 uint64_t minorGCCount
= runtime
->gc
.minorGCCount();
54 MOZ_ASSERT(minorGCCount
== minorGCNumberAtCreation
||
55 minorGCCount
== minorGCNumberAtCreation
+ 1);
60 inline void StoreBuffer::WholeCellBuffer::put(const Cell
* cell
) {
62 putDontCheckLast(cell
);
66 inline void StoreBuffer::WholeCellBuffer::putDontCheckLast(const Cell
* cell
) {
67 // This can still be called when |cell == last_| if the caller didn't check
70 MOZ_ASSERT(cell
->isTenured());
72 // BigInts don't have any children, so shouldn't show up here.
73 MOZ_ASSERT(cell
->getTraceKind() != JS::TraceKind::BigInt
);
75 Arena
* arena
= cell
->asTenured().arena();
76 ArenaCellSet
* cells
= arena
->bufferedCells();
77 if (cells
->isEmpty()) {
78 cells
= allocateCellSet(arena
);
84 cells
->putCell(&cell
->asTenured());
90 inline void StoreBuffer::putWholeCell(Cell
* cell
) { bufferWholeCell
.put(cell
); }
91 inline void StoreBuffer::putWholeCellDontCheckLast(Cell
* cell
) {
92 bufferWholeCell
.putDontCheckLast(cell
);
98 #endif // gc_StoreBuffer_inl_h