summaryrefslogtreecommitdiffstats
path: root/js/public/HeapAPI.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /js/public/HeapAPI.h
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/public/HeapAPI.h')
-rw-r--r--js/public/HeapAPI.h49
1 files changed, 42 insertions, 7 deletions
diff --git a/js/public/HeapAPI.h b/js/public/HeapAPI.h
index 26cca9e1c3..cabadeb75d 100644
--- a/js/public/HeapAPI.h
+++ b/js/public/HeapAPI.h
@@ -45,7 +45,7 @@ const size_t ArenaShift = 12;
const size_t ArenaSize = size_t(1) << ArenaShift;
const size_t ArenaMask = ArenaSize - 1;
-#if defined(XP_MACOSX) && defined(__aarch64__)
+#if defined(XP_DARWIN) && defined(__aarch64__)
const size_t PageShift = 14;
#else
const size_t PageShift = 12;
@@ -82,28 +82,61 @@ const size_t ArenaBitmapBits = ArenaSize / CellBytesPerMarkBit;
const size_t ArenaBitmapBytes = HowMany(ArenaBitmapBits, 8);
const size_t ArenaBitmapWords = HowMany(ArenaBitmapBits, JS_BITS_PER_WORD);
+enum class ChunkKind : uint8_t {
+ Invalid = 0,
+ TenuredHeap,
+ NurseryToSpace,
+ NurseryFromSpace
+};
+
// The base class for all GC chunks, either in the nursery or in the tenured
// heap memory. This structure is locatable from any GC pointer by aligning to
// the chunk size.
-class alignas(CellAlignBytes) ChunkBase {
+class ChunkBase {
protected:
- ChunkBase(JSRuntime* rt, StoreBuffer* sb) {
+ // Initialize a tenured heap chunk.
+ explicit ChunkBase(JSRuntime* rt) {
MOZ_ASSERT((uintptr_t(this) & ChunkMask) == 0);
- initBase(rt, sb);
+ initBaseForTenuredChunk(rt);
}
- void initBase(JSRuntime* rt, StoreBuffer* sb) {
+ void initBaseForTenuredChunk(JSRuntime* rt) {
runtime = rt;
- storeBuffer = sb;
+ storeBuffer = nullptr;
+ kind = ChunkKind::TenuredHeap;
+ nurseryChunkIndex = UINT8_MAX;
+ }
+
+ // Initialize a nursery chunk.
+ ChunkBase(JSRuntime* rt, StoreBuffer* sb, ChunkKind kind, uint8_t chunkIndex)
+ : storeBuffer(sb),
+ runtime(rt),
+ kind(kind),
+ nurseryChunkIndex(chunkIndex) {
+ MOZ_ASSERT(kind == ChunkKind::NurseryFromSpace ||
+ kind == ChunkKind::NurseryToSpace);
+ MOZ_ASSERT((uintptr_t(this) & ChunkMask) == 0);
+ MOZ_ASSERT(storeBuffer);
}
public:
+ ChunkKind getKind() const {
+ MOZ_ASSERT_IF(storeBuffer, kind == ChunkKind::NurseryToSpace ||
+ kind == ChunkKind::NurseryFromSpace);
+ MOZ_ASSERT_IF(!storeBuffer, kind == ChunkKind::TenuredHeap);
+ return kind;
+ }
+
// The store buffer for pointers from tenured things to things in this
// chunk. Will be non-null if and only if this is a nursery chunk.
StoreBuffer* storeBuffer;
// Provide quick access to the runtime from absolutely anywhere.
JSRuntime* runtime;
+
+ ChunkKind kind;
+
+ uint8_t nurseryChunkIndex;
};
// Information about tenured heap chunks.
@@ -234,7 +267,7 @@ class TenuredChunkBase : public ChunkBase {
ChunkPageBitmap decommittedPages;
protected:
- explicit TenuredChunkBase(JSRuntime* runtime) : ChunkBase(runtime, nullptr) {
+ explicit TenuredChunkBase(JSRuntime* runtime) : ChunkBase(runtime) {
info.numArenasFree = ArenasPerChunk;
}
@@ -523,6 +556,7 @@ static MOZ_ALWAYS_INLINE ChunkBase* GetCellChunkBase(const Cell* cell) {
MOZ_ASSERT(cell);
auto* chunk = reinterpret_cast<ChunkBase*>(uintptr_t(cell) & ~ChunkMask);
MOZ_ASSERT(chunk->runtime);
+ MOZ_ASSERT(chunk->kind != ChunkKind::Invalid);
return chunk;
}
@@ -532,6 +566,7 @@ static MOZ_ALWAYS_INLINE TenuredChunkBase* GetCellChunkBase(
auto* chunk =
reinterpret_cast<TenuredChunkBase*>(uintptr_t(cell) & ~ChunkMask);
MOZ_ASSERT(chunk->runtime);
+ MOZ_ASSERT(chunk->kind == ChunkKind::TenuredHeap);
return chunk;
}