Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / js / src / gc / StoreBuffer-inl.h
blob343b953e3a7bb899b371da8709e9ce860511cc4c
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"
12 #include "gc/Cell.h"
13 #include "gc/Heap.h"
15 #include "gc/Heap-inl.h"
17 namespace js {
18 namespace gc {
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,
27 size_t* wordp,
28 uint32_t* maskp) {
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);
39 MOZ_ASSERT(arena);
41 bits.set(cellIndex);
42 check();
45 inline void ArenaCellSet::check() const {
46 #ifdef DEBUG
47 bool bitsZero = bits.isAllClear();
48 MOZ_ASSERT(isEmpty() == bitsZero);
49 MOZ_ASSERT(isEmpty() == !arena);
50 if (!isEmpty()) {
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);
57 #endif
60 inline void StoreBuffer::WholeCellBuffer::put(const Cell* cell) {
61 if (cell != last_) {
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
68 // and that's OK.
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);
79 if (!cells) {
80 return;
84 cells->putCell(&cell->asTenured());
85 cells->check();
87 last_ = cell;
90 inline void StoreBuffer::putWholeCell(Cell* cell) { bufferWholeCell.put(cell); }
91 inline void StoreBuffer::putWholeCellDontCheckLast(Cell* cell) {
92 bufferWholeCell.putDontCheckLast(cell);
95 } // namespace gc
96 } // namespace js
98 #endif // gc_StoreBuffer_inl_h