Skip to content

Commit

Permalink
Bug 1686219 - Store chunk information at the start rather than the en…
Browse files Browse the repository at this point in the history
…d of the chunk r=sfink

This moves the chunk metadata to the start of the chunk and defines the data structures in the public header.  This simplifies accessing this data and removes the need for hardcoded offsets.

Requesting review from jandem for JIT updates.

Differential Revision: https://phabricator.services.mozilla.com/D101778
  • Loading branch information
jonco3 committed Jan 20, 2021
1 parent 4149086 commit e9ee99f
Show file tree
Hide file tree
Showing 11 changed files with 412 additions and 412 deletions.
337 changes: 254 additions & 83 deletions js/public/HeapAPI.h

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions js/src/gc/Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ Chunk* GCRuntime::getOrAllocChunk(AutoLockGCBgAlloc& lock) {
}

void GCRuntime::recycleChunk(Chunk* chunk, const AutoLockGC& lock) {
AlwaysPoison(&chunk->trailer, JS_FREED_CHUNK_PATTERN, sizeof(ChunkTrailer),
AlwaysPoison(&chunk->header, JS_FREED_CHUNK_PATTERN, sizeof(ChunkHeader),
MemCheckKind::MakeNoAccess);
emptyChunks(lock).push(chunk);
}
Expand Down Expand Up @@ -861,6 +861,9 @@ void Chunk::init(GCRuntime* gc) {
Poison(this, JS_FRESH_TENURED_PATTERN, ChunkSize,
MemCheckKind::MakeUndefined);

new (&header) ChunkHeader(gc->rt);
info.init();

/*
* We clear the bitmap to guard against JS::GCThingIsMarkedGray being called
* on uninitialized data, which would happen before the first GC cycle.
Expand All @@ -873,10 +876,6 @@ void Chunk::init(GCRuntime* gc) {
*/
decommitAllArenas();

/* Initialize the chunk info. */
info.init();
new (&trailer) ChunkTrailer(gc->rt);

/* The rest of info fields are initialized in pickChunk. */
}

Expand Down
6 changes: 3 additions & 3 deletions js/src/gc/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ MOZ_ALWAYS_INLINE bool Cell::isMarkedAtLeast(gc::MarkColor color) const {
}

inline JSRuntime* Cell::runtimeFromMainThread() const {
JSRuntime* rt = chunk()->trailer.runtime;
JSRuntime* rt = chunk()->header.runtime;
MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
return rt;
}

inline JSRuntime* Cell::runtimeFromAnyThread() const {
return chunk()->trailer.runtime;
return chunk()->header.runtime;
}

inline uintptr_t Cell::address() const {
Expand All @@ -354,7 +354,7 @@ Chunk* Cell::chunk() const {
}

inline StoreBuffer* Cell::storeBuffer() const {
return chunk()->trailer.storeBuffer;
return chunk()->header.storeBuffer;
}

JS::Zone* Cell::zone() const {
Expand Down
4 changes: 0 additions & 4 deletions js/src/gc/GCEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
namespace js {
namespace gc {

// Mark colors. Order is important here: the greater value the 'more marked' a
// cell is.
enum class MarkColor : uint8_t { Gray = 1, Black = 2 };

// The phases of an incremental GC.
#define GCSTATES(D) \
D(NotActive) \
Expand Down
Loading

0 comments on commit e9ee99f

Please sign in to comment.