Bug 1909527 - Split background allocations to a dedicated arena r=iain,sfink
Differential Revision: https://phabricator.services.mozilla.com/D217480
This commit is contained in:
@@ -25,8 +25,7 @@ class FrontendContext;
|
||||
|
||||
enum class AllocFunction { Malloc, Calloc, Realloc };
|
||||
|
||||
/* Base class allocation policies providing allocation methods. */
|
||||
class AllocPolicyBase {
|
||||
class ArenaAllocPolicyBase {
|
||||
public:
|
||||
template <typename T>
|
||||
T* maybe_pod_arena_malloc(arena_id_t arenaId, size_t numElems) {
|
||||
@@ -54,7 +53,11 @@ class AllocPolicyBase {
|
||||
size_t newSize) {
|
||||
return maybe_pod_arena_realloc<T>(arenaId, p, oldSize, newSize);
|
||||
}
|
||||
};
|
||||
|
||||
/* Base class allocation policies providing allocation methods. */
|
||||
class AllocPolicyBase : public ArenaAllocPolicyBase {
|
||||
public:
|
||||
template <typename T>
|
||||
T* maybe_pod_malloc(size_t numElems) {
|
||||
return maybe_pod_arena_malloc<T>(js::MallocArena, numElems);
|
||||
@@ -86,6 +89,44 @@ class AllocPolicyBase {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Base class allocation policies providing allocation methods for allocations
|
||||
* off the main thread.
|
||||
*/
|
||||
class BackgroundAllocPolicyBase : ArenaAllocPolicyBase {
|
||||
public:
|
||||
template <typename T>
|
||||
T* maybe_pod_malloc(size_t numElems) {
|
||||
return maybe_pod_arena_malloc<T>(js::BackgroundMallocArena, numElems);
|
||||
}
|
||||
template <typename T>
|
||||
T* maybe_pod_calloc(size_t numElems) {
|
||||
return maybe_pod_arena_calloc<T>(js::BackgroundMallocArena, numElems);
|
||||
}
|
||||
template <typename T>
|
||||
T* maybe_pod_realloc(T* p, size_t oldSize, size_t newSize) {
|
||||
return maybe_pod_arena_realloc<T>(js::BackgroundMallocArena, p, oldSize,
|
||||
newSize);
|
||||
}
|
||||
template <typename T>
|
||||
T* pod_malloc(size_t numElems) {
|
||||
return pod_arena_malloc<T>(js::BackgroundMallocArena, numElems);
|
||||
}
|
||||
template <typename T>
|
||||
T* pod_calloc(size_t numElems) {
|
||||
return pod_arena_calloc<T>(js::BackgroundMallocArena, numElems);
|
||||
}
|
||||
template <typename T>
|
||||
T* pod_realloc(T* p, size_t oldSize, size_t newSize) {
|
||||
return pod_arena_realloc<T>(js::BackgroundMallocArena, p, oldSize, newSize);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void free_(T* p, size_t numElems = 0) {
|
||||
js_free(p);
|
||||
}
|
||||
};
|
||||
|
||||
/* Policy for using system memory functions and doing no error reporting. */
|
||||
class SystemAllocPolicy : public AllocPolicyBase {
|
||||
public:
|
||||
@@ -93,6 +134,12 @@ class SystemAllocPolicy : public AllocPolicyBase {
|
||||
bool checkSimulatedOOM() const { return !js::oom::ShouldFailWithOOM(); }
|
||||
};
|
||||
|
||||
class BackgroundSystemAllocPolicy : public BackgroundAllocPolicyBase {
|
||||
public:
|
||||
void reportAllocOverflow() const {}
|
||||
bool checkSimulatedOOM() const { return !js::oom::ShouldFailWithOOM(); }
|
||||
};
|
||||
|
||||
MOZ_COLD JS_PUBLIC_API void ReportOutOfMemory(JSContext* cx);
|
||||
MOZ_COLD JS_PUBLIC_API void ReportOutOfMemory(FrontendContext* fc);
|
||||
|
||||
|
||||
@@ -352,7 +352,21 @@ struct MOZ_RAII JS_PUBLIC_DATA AutoEnterOOMUnsafeRegion {
|
||||
|
||||
namespace js {
|
||||
|
||||
// The following two arenas require a little bit of clarification. We have
|
||||
// observed that, particularly on devices with heterogeneous CPU architectures
|
||||
// where background work can run on significantly slower cores than main thread
|
||||
// work, the lock contention in the allocator can be a big problem for the
|
||||
// main thread. So we introduced an arena for background allocations which can
|
||||
// reduce that contention.
|
||||
//
|
||||
// The general rule for these is: if it's easy to determine at the time of
|
||||
// authorship that an allocation will be *off* the main thread, use the
|
||||
// BackgroundMallocArena, and vice versa. If it is hard to determine, just make
|
||||
// a guess, and that will be fine. Do not spend too much time on this, and
|
||||
// don't do anything fancy at runtime to try to determine which to use.
|
||||
extern JS_PUBLIC_DATA arena_id_t MallocArena;
|
||||
extern JS_PUBLIC_DATA arena_id_t BackgroundMallocArena;
|
||||
|
||||
extern JS_PUBLIC_DATA arena_id_t ArrayBufferContentsArena;
|
||||
extern JS_PUBLIC_DATA arena_id_t StringBufferArena;
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace js {
|
||||
namespace detail {
|
||||
|
||||
/* static */
|
||||
UniquePtr<BumpChunk> BumpChunk::newWithCapacity(size_t size) {
|
||||
UniquePtr<BumpChunk> BumpChunk::newWithCapacity(size_t size, arena_id_t arena) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(size >= sizeof(BumpChunk));
|
||||
void* mem = js_malloc(size);
|
||||
void* mem = js_arena_malloc(arena, size);
|
||||
if (!mem) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -185,7 +185,8 @@ LifoAlloc::UniqueBumpChunk LifoAlloc::newChunkWithCapacity(size_t n,
|
||||
: NextSize(defaultChunkSize_, smallAllocsSize_);
|
||||
|
||||
// Create a new BumpChunk, and allocate space for it.
|
||||
UniqueBumpChunk result = detail::BumpChunk::newWithCapacity(chunkSize);
|
||||
UniqueBumpChunk result =
|
||||
detail::BumpChunk::newWithCapacity(chunkSize, arena_);
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -370,6 +371,13 @@ void LifoAlloc::transferFrom(LifoAlloc* other) {
|
||||
MOZ_ASSERT(!markCount);
|
||||
MOZ_ASSERT(!other->markCount);
|
||||
|
||||
// This assertion is not really necessary, and if it is getting in your way
|
||||
// please feel free to just delete it, but it should generally point you in
|
||||
// a decent direction. LifoAllocs are entirely capable of having a mix of
|
||||
// allocations from different arenas, this is just a heuristic that we
|
||||
// expect will yield better performance.
|
||||
MOZ_ASSERT(arena_ == other->arena_);
|
||||
|
||||
// Transferred chunks are not counted as part of |smallAllocsSize| as this
|
||||
// could introduce bias in the |NextSize| heuristics, leading to
|
||||
// over-allocations in *this* LifoAlloc. As well, to avoid interference with
|
||||
|
||||
@@ -516,7 +516,7 @@ class BumpChunk : public SingleLinkedListElement<BumpChunk> {
|
||||
// This function is the only way to allocate and construct a chunk. It
|
||||
// returns a UniquePtr to the newly allocated chunk. The size given as
|
||||
// argument includes the space needed for the header of the chunk.
|
||||
static UniquePtr<BumpChunk> newWithCapacity(size_t size);
|
||||
static UniquePtr<BumpChunk> newWithCapacity(size_t size, arena_id_t arena);
|
||||
|
||||
// Report allocation.
|
||||
size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
@@ -699,6 +699,17 @@ class LifoAlloc {
|
||||
// now-unused, or transferred (which followed their own growth patterns).
|
||||
size_t smallAllocsSize_;
|
||||
|
||||
// Arena to use for the allocations from this LifoAlloc. This is typically
|
||||
// MallocArena for main-thread-focused LifoAllocs and BackgroundMallocArena
|
||||
// for background-thread-focused LifoAllocs.
|
||||
// If you are unsure at the time of authorship whether this LifoAlloc will be
|
||||
// mostly on or mostly off the main thread, just take a guess, and that
|
||||
// will be fine. There should be no serious consequences for getting this
|
||||
// wrong unless your system is very hot and makes heavy use of its LifoAlloc.
|
||||
// In that case, run both options through a try run of Speedometer 3 or
|
||||
// whatever is most current and pick whichever performs better.
|
||||
arena_id_t arena_;
|
||||
|
||||
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
|
||||
bool fallibleScope_;
|
||||
#endif
|
||||
@@ -766,8 +777,9 @@ class LifoAlloc {
|
||||
[[nodiscard]] bool ensureUnusedApproximateColdPath(size_t n, size_t total);
|
||||
|
||||
public:
|
||||
explicit LifoAlloc(size_t defaultChunkSize)
|
||||
: peakSize_(0)
|
||||
LifoAlloc(size_t defaultChunkSize, arena_id_t arena)
|
||||
: peakSize_(0),
|
||||
arena_(arena)
|
||||
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
|
||||
,
|
||||
fallibleScope_(true)
|
||||
|
||||
@@ -1223,7 +1223,7 @@ struct CompilationStencil {
|
||||
|
||||
// Construct a CompilationStencil
|
||||
explicit CompilationStencil(ScriptSource* source)
|
||||
: alloc(LifoAllocChunkSize), source(source) {}
|
||||
: alloc(LifoAllocChunkSize, js::BackgroundMallocArena), source(source) {}
|
||||
|
||||
// Take the ownership of on-heap ExtensibleCompilationStencil and
|
||||
// borrow from it.
|
||||
@@ -1389,7 +1389,8 @@ struct ExtensibleCompilationStencil {
|
||||
ExtensibleCompilationStencil(ExtensibleCompilationStencil&& other) noexcept
|
||||
: canLazilyParse(other.canLazilyParse),
|
||||
functionKey(other.functionKey),
|
||||
alloc(CompilationStencil::LifoAllocChunkSize),
|
||||
alloc(CompilationStencil::LifoAllocChunkSize,
|
||||
js::BackgroundMallocArena),
|
||||
source(std::move(other.source)),
|
||||
scriptData(std::move(other.scriptData)),
|
||||
scriptExtra(std::move(other.scriptExtra)),
|
||||
|
||||
@@ -99,7 +99,8 @@ static already_AddRefed<JS::Stencil> CompileGlobalScriptToStencilImpl(
|
||||
frontend::CompilationInput compilationInput(options);
|
||||
|
||||
frontend::NoScopeBindingCache scopeCache;
|
||||
LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena);
|
||||
RefPtr<JS::Stencil> stencil_ = frontend::CompileGlobalScriptToStencil(
|
||||
nullptr, fc, tempLifoAlloc, compilationInput, &scopeCache, data,
|
||||
scopeKind);
|
||||
@@ -120,7 +121,8 @@ static already_AddRefed<JS::Stencil> CompileModuleScriptToStencilImpl(
|
||||
frontend::CompilationInput compilationInput(options);
|
||||
|
||||
NoScopeBindingCache scopeCache;
|
||||
js::LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
js::LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena);
|
||||
RefPtr<JS::Stencil> stencil = ParseModuleToStencil(
|
||||
nullptr, fc, tempLifoAlloc, compilationInput, &scopeCache, srcBuf);
|
||||
// CompilationInput initialized with ParseModuleToStencil only
|
||||
|
||||
@@ -2615,7 +2615,7 @@ void CompilationStencil::assertBorrowingFromExtensibleCompilationStencil(
|
||||
|
||||
CompilationStencil::CompilationStencil(
|
||||
UniquePtr<ExtensibleCompilationStencil>&& extensibleStencil)
|
||||
: alloc(LifoAllocChunkSize) {
|
||||
: alloc(LifoAllocChunkSize, js::BackgroundMallocArena) {
|
||||
ownedBorrowStencil = std::move(extensibleStencil);
|
||||
|
||||
storageType = StorageType::OwnedExtensible;
|
||||
@@ -3010,21 +3010,21 @@ bool CompilationStencil::deserializeStencils(
|
||||
}
|
||||
|
||||
ExtensibleCompilationStencil::ExtensibleCompilationStencil(ScriptSource* source)
|
||||
: alloc(CompilationStencil::LifoAllocChunkSize),
|
||||
: alloc(CompilationStencil::LifoAllocChunkSize, js::BackgroundMallocArena),
|
||||
source(source),
|
||||
parserAtoms(alloc) {}
|
||||
|
||||
ExtensibleCompilationStencil::ExtensibleCompilationStencil(
|
||||
CompilationInput& input)
|
||||
: canLazilyParse(CanLazilyParse(input.options)),
|
||||
alloc(CompilationStencil::LifoAllocChunkSize),
|
||||
alloc(CompilationStencil::LifoAllocChunkSize, js::BackgroundMallocArena),
|
||||
source(input.source),
|
||||
parserAtoms(alloc) {}
|
||||
|
||||
ExtensibleCompilationStencil::ExtensibleCompilationStencil(
|
||||
const JS::ReadOnlyCompileOptions& options, RefPtr<ScriptSource> source)
|
||||
: canLazilyParse(CanLazilyParse(options)),
|
||||
alloc(CompilationStencil::LifoAllocChunkSize),
|
||||
alloc(CompilationStencil::LifoAllocChunkSize, js::BackgroundMallocArena),
|
||||
source(std::move(source)),
|
||||
parserAtoms(alloc) {}
|
||||
|
||||
|
||||
@@ -450,11 +450,14 @@ GCRuntime::GCRuntime(JSRuntime* rt)
|
||||
hadShutdownGC(false),
|
||||
#endif
|
||||
requestSliceAfterBackgroundTask(false),
|
||||
lifoBlocksToFree((size_t)JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
|
||||
lifoBlocksToFree((size_t)JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena),
|
||||
lifoBlocksToFreeAfterFullMinorGC(
|
||||
(size_t)JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
|
||||
(size_t)JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena),
|
||||
lifoBlocksToFreeAfterNextMinorGC(
|
||||
(size_t)JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
|
||||
(size_t)JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena),
|
||||
sweepGroupIndex(0),
|
||||
sweepGroups(nullptr),
|
||||
currentSweepGroup(nullptr),
|
||||
|
||||
@@ -33,7 +33,7 @@ void StoreBuffer::checkAccess() const {
|
||||
bool StoreBuffer::WholeCellBuffer::init() {
|
||||
MOZ_ASSERT(!head_);
|
||||
if (!storage_) {
|
||||
storage_ = MakeUnique<LifoAlloc>(LifoAllocBlockSize);
|
||||
storage_ = MakeUnique<LifoAlloc>(LifoAllocBlockSize, js::MallocArena);
|
||||
// This prevents LifoAlloc::Enum from crashing with a release
|
||||
// assertion if we ever allocate one entry larger than
|
||||
// LifoAllocBlockSize.
|
||||
@@ -47,7 +47,7 @@ bool StoreBuffer::WholeCellBuffer::init() {
|
||||
|
||||
bool StoreBuffer::GenericBuffer::init() {
|
||||
if (!storage_) {
|
||||
storage_ = MakeUnique<LifoAlloc>(LifoAllocBlockSize);
|
||||
storage_ = MakeUnique<LifoAlloc>(LifoAllocBlockSize, js::MallocArena);
|
||||
}
|
||||
clear();
|
||||
return bool(storage_);
|
||||
|
||||
@@ -462,7 +462,8 @@ void BackgroundFreeTask::run(AutoLockHelperThreadState& lock) {
|
||||
|
||||
void GCRuntime::freeFromBackgroundThread(AutoLockHelperThreadState& lock) {
|
||||
do {
|
||||
LifoAlloc lifoBlocks(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifoBlocks(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena);
|
||||
lifoBlocks.transferFrom(&lifoBlocksToFree.ref());
|
||||
|
||||
Nursery::BufferSet buffers;
|
||||
|
||||
@@ -572,7 +572,8 @@ class VirtualRegister {
|
||||
|
||||
// A sequence of code positions, for tellings BacktrackingAllocator::splitAt
|
||||
// where to split.
|
||||
using SplitPositionVector = js::Vector<CodePosition, 4, SystemAllocPolicy>;
|
||||
using SplitPositionVector =
|
||||
js::Vector<CodePosition, 4, BackgroundSystemAllocPolicy>;
|
||||
|
||||
class BacktrackingAllocator : protected RegisterAllocator {
|
||||
friend class JSONSpewer;
|
||||
@@ -599,7 +600,8 @@ class BacktrackingAllocator : protected RegisterAllocator {
|
||||
size_t priority_;
|
||||
};
|
||||
|
||||
PriorityQueue<QueueItem, QueueItem, 0, SystemAllocPolicy> allocationQueue;
|
||||
PriorityQueue<QueueItem, QueueItem, 0, BackgroundSystemAllocPolicy>
|
||||
allocationQueue;
|
||||
|
||||
// This is a set of LiveRange. They must be non-overlapping. Attempts
|
||||
// to add an overlapping range will cause AvlTree::insert to MOZ_CRASH().
|
||||
@@ -659,9 +661,9 @@ class BacktrackingAllocator : protected RegisterAllocator {
|
||||
// All allocated slots of each width.
|
||||
SpillSlotList normalSlots, doubleSlots, quadSlots;
|
||||
|
||||
Vector<LiveBundle*, 4, SystemAllocPolicy> spilledBundles;
|
||||
Vector<LiveBundle*, 4, BackgroundSystemAllocPolicy> spilledBundles;
|
||||
|
||||
using LiveBundleVector = Vector<LiveBundle*, 4, SystemAllocPolicy>;
|
||||
using LiveBundleVector = Vector<LiveBundle*, 4, BackgroundSystemAllocPolicy>;
|
||||
|
||||
// Misc accessors
|
||||
bool compilingWasm() { return mir->outerInfo().compilingWasm(); }
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace jit {
|
||||
// stub data. Each JitZone has a single ICStubSpace.
|
||||
class ICStubSpace {
|
||||
static constexpr size_t DefaultChunkSize = 4096;
|
||||
LifoAlloc allocator_{DefaultChunkSize};
|
||||
LifoAlloc allocator_{DefaultChunkSize, js::BackgroundMallocArena};
|
||||
|
||||
public:
|
||||
inline void* alloc(size_t size) { return allocator_.alloc(size); }
|
||||
|
||||
@@ -1664,8 +1664,8 @@ static AbortReason IonCompile(JSContext* cx, HandleScript script,
|
||||
jsbytecode* osrPc) {
|
||||
cx->check(script);
|
||||
|
||||
auto alloc =
|
||||
cx->make_unique<LifoAlloc>(TempAllocator::PreferredLifoChunkSize);
|
||||
auto alloc = cx->make_unique<LifoAlloc>(TempAllocator::PreferredLifoChunkSize,
|
||||
js::MallocArena);
|
||||
if (!alloc) {
|
||||
return AbortReason::Error;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ class alignas(uintptr_t) ICScript final : public TrailingArray<ICScript> {
|
||||
|
||||
// List of allocation sites referred to by ICs in this script.
|
||||
static constexpr size_t AllocSiteChunkSize = 256;
|
||||
LifoAlloc allocSitesSpace_{AllocSiteChunkSize};
|
||||
LifoAlloc allocSitesSpace_{AllocSiteChunkSize, js::BackgroundMallocArena};
|
||||
Vector<gc::AllocSite*, 0, SystemAllocPolicy> allocSites_;
|
||||
|
||||
// Number of times this copy of the script has been called or has had
|
||||
|
||||
@@ -449,7 +449,8 @@ class JitcodeGlobalTable {
|
||||
EntryTree tree_;
|
||||
|
||||
public:
|
||||
JitcodeGlobalTable() : alloc_(LIFO_CHUNK_SIZE), tree_(&alloc_) {}
|
||||
JitcodeGlobalTable()
|
||||
: alloc_(LIFO_CHUNK_SIZE, js::BackgroundMallocArena), tree_(&alloc_) {}
|
||||
|
||||
bool empty() const {
|
||||
MOZ_ASSERT(entries_.empty() == tree_.empty());
|
||||
|
||||
@@ -32,7 +32,7 @@ class IonIC;
|
||||
class OutOfLineTruncateSlow;
|
||||
|
||||
class CodeGeneratorShared : public LElementVisitor {
|
||||
js::Vector<OutOfLineCode*, 0, SystemAllocPolicy> outOfLineCode_;
|
||||
js::Vector<OutOfLineCode*, 0, BackgroundSystemAllocPolicy> outOfLineCode_;
|
||||
|
||||
MacroAssembler& ensureMasm(MacroAssembler* masm, TempAllocator& alloc,
|
||||
CompileRealm* realm);
|
||||
@@ -61,24 +61,26 @@ class CodeGeneratorShared : public LElementVisitor {
|
||||
// Amount of bytes allocated for incoming args. Used for Wasm return calls.
|
||||
uint32_t inboundStackArgBytes_;
|
||||
|
||||
js::Vector<CodegenSafepointIndex, 0, SystemAllocPolicy> safepointIndices_;
|
||||
js::Vector<OsiIndex, 0, SystemAllocPolicy> osiIndices_;
|
||||
js::Vector<CodegenSafepointIndex, 0, BackgroundSystemAllocPolicy>
|
||||
safepointIndices_;
|
||||
js::Vector<OsiIndex, 0, BackgroundSystemAllocPolicy> osiIndices_;
|
||||
|
||||
// Allocated data space needed at runtime.
|
||||
js::Vector<uint8_t, 0, SystemAllocPolicy> runtimeData_;
|
||||
js::Vector<uint8_t, 0, BackgroundSystemAllocPolicy> runtimeData_;
|
||||
|
||||
// Vector mapping each IC index to its offset in runtimeData_.
|
||||
js::Vector<uint32_t, 0, SystemAllocPolicy> icList_;
|
||||
js::Vector<uint32_t, 0, BackgroundSystemAllocPolicy> icList_;
|
||||
|
||||
// IC data we need at compile-time. Discarded after creating the IonScript.
|
||||
struct CompileTimeICInfo {
|
||||
CodeOffset icOffsetForJump;
|
||||
CodeOffset icOffsetForPush;
|
||||
};
|
||||
js::Vector<CompileTimeICInfo, 0, SystemAllocPolicy> icInfo_;
|
||||
js::Vector<CompileTimeICInfo, 0, BackgroundSystemAllocPolicy> icInfo_;
|
||||
|
||||
protected:
|
||||
js::Vector<NativeToBytecode, 0, SystemAllocPolicy> nativeToBytecodeList_;
|
||||
js::Vector<NativeToBytecode, 0, BackgroundSystemAllocPolicy>
|
||||
nativeToBytecodeList_;
|
||||
UniquePtr<uint8_t> nativeToBytecodeMap_;
|
||||
uint32_t nativeToBytecodeMapSize_;
|
||||
uint32_t nativeToBytecodeTableOffset_;
|
||||
|
||||
@@ -165,7 +165,7 @@ class AssemblerBuffer {
|
||||
maxSize(MaxCodeBytesPerBuffer),
|
||||
finger(nullptr),
|
||||
finger_offset(0),
|
||||
lifoAlloc_(8192) {}
|
||||
lifoAlloc_(8192, js::BackgroundMallocArena) {}
|
||||
|
||||
public:
|
||||
bool isAligned(size_t alignment) const {
|
||||
|
||||
@@ -110,7 +110,7 @@ BEGIN_TEST(testAssemblerBuffer_BranchDeadlineSet) {
|
||||
using DLSet = js::jit::BranchDeadlineSet<3>;
|
||||
using js::jit::BufferOffset;
|
||||
|
||||
js::LifoAlloc alloc(1024);
|
||||
js::LifoAlloc alloc(1024, js::MallocArena);
|
||||
DLSet dls(alloc);
|
||||
|
||||
CHECK(dls.empty());
|
||||
@@ -519,7 +519,7 @@ END_TEST(testAssemblerBuffer_AssemblerBufferWithConstantPools_ShortBranch)
|
||||
BEGIN_TEST(testAssemblerBuffer_ARM64) {
|
||||
using namespace js::jit;
|
||||
|
||||
js::LifoAlloc lifo(4096);
|
||||
js::LifoAlloc lifo(4096, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
|
||||
@@ -213,7 +213,7 @@ BEGIN_TEST(testAvlTree_main) {
|
||||
static const int UNIV_MAX = 5999;
|
||||
static const int UNIV_SIZE = UNIV_MAX - UNIV_MIN + 1;
|
||||
|
||||
LifoAlloc alloc(4096);
|
||||
LifoAlloc alloc(4096, js::MallocArena);
|
||||
AvlTreeTestIF<CmpInt, CmpInt> tree(&alloc);
|
||||
std::set<int> should_be_in_tree;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ struct MinimalAlloc {
|
||||
|
||||
// We are not testing the fallible allocator in these test cases, thus make
|
||||
// the lifo alloc chunk extremely large for our test cases.
|
||||
MinimalAlloc() : lifo(128 * 1024), alloc(&lifo) {
|
||||
MinimalAlloc() : lifo(128 * 1024, js::MallocArena), alloc(&lifo) {
|
||||
if (!alloc.ensureBallast()) {
|
||||
MOZ_CRASH("[OOM] Not enough RAM for the test.");
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ static js::jit::JitCode* linkAndAllocate(JSContext* cx,
|
||||
BEGIN_TEST(testJitMoveEmitterCycles_simple) {
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
@@ -115,7 +115,7 @@ END_TEST(testJitMoveEmitterCycles_simple)
|
||||
BEGIN_TEST(testJitMoveEmitterCycles_autogen) {
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
@@ -241,7 +241,7 @@ END_TEST(testJitMoveEmitterCycles_autogen)
|
||||
BEGIN_TEST(testJitMoveEmitterCycles_autogen2) {
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
@@ -384,7 +384,7 @@ END_TEST(testJitMoveEmitterCycles_autogen2)
|
||||
BEGIN_TEST(testJitMoveEmitterCycles_autogen3) {
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
@@ -526,7 +526,7 @@ END_TEST(testJitMoveEmitterCycles_autogen3)
|
||||
BEGIN_TEST(testJitMoveEmitterCycles_bug1299147_1) {
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
@@ -577,7 +577,7 @@ END_TEST(testJitMoveEmitterCycles_bug1299147_1)
|
||||
BEGIN_TEST(testJitMoveEmitterCycles_bug1299147) {
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
|
||||
@@ -22,7 +22,7 @@ BEGIN_TEST(testParserAtom_empty) {
|
||||
using js::frontend::TaggedParserAtomIndex;
|
||||
|
||||
js::AutoReportFrontendContext fc(cx);
|
||||
js::LifoAlloc alloc(512);
|
||||
js::LifoAlloc alloc(512, js::MallocArena);
|
||||
ParserAtomsTable atomTable(alloc);
|
||||
|
||||
const char ascii[] = {};
|
||||
@@ -49,7 +49,7 @@ BEGIN_TEST(testParserAtom_tiny1_ASCII) {
|
||||
using js::frontend::WellKnownParserAtoms;
|
||||
|
||||
js::AutoReportFrontendContext fc(cx);
|
||||
js::LifoAlloc alloc(512);
|
||||
js::LifoAlloc alloc(512, js::MallocArena);
|
||||
ParserAtomsTable atomTable(alloc);
|
||||
|
||||
char16_t a = 'a';
|
||||
@@ -77,7 +77,7 @@ BEGIN_TEST(testParserAtom_tiny1_nonASCII) {
|
||||
using js::frontend::WellKnownParserAtoms;
|
||||
|
||||
js::AutoReportFrontendContext fc(cx);
|
||||
js::LifoAlloc alloc(512);
|
||||
js::LifoAlloc alloc(512, js::MallocArena);
|
||||
ParserAtomsTable atomTable(alloc);
|
||||
|
||||
{
|
||||
@@ -191,7 +191,7 @@ BEGIN_TEST(testParserAtom_tiny1_invalidUTF8) {
|
||||
using js::frontend::WellKnownParserAtoms;
|
||||
|
||||
js::AutoReportFrontendContext fc(cx);
|
||||
js::LifoAlloc alloc(512);
|
||||
js::LifoAlloc alloc(512, js::MallocArena);
|
||||
ParserAtomsTable atomTable(alloc);
|
||||
|
||||
{
|
||||
@@ -326,7 +326,7 @@ BEGIN_TEST(testParserAtom_tiny2) {
|
||||
using js::frontend::WellKnownParserAtoms;
|
||||
|
||||
js::AutoReportFrontendContext fc(cx);
|
||||
js::LifoAlloc alloc(512);
|
||||
js::LifoAlloc alloc(512, js::MallocArena);
|
||||
ParserAtomsTable atomTable(alloc);
|
||||
|
||||
const char ascii[] = {'a', '0'};
|
||||
@@ -360,7 +360,7 @@ BEGIN_TEST(testParserAtom_int) {
|
||||
using js::frontend::WellKnownParserAtoms;
|
||||
|
||||
js::AutoReportFrontendContext fc(cx);
|
||||
js::LifoAlloc alloc(512);
|
||||
js::LifoAlloc alloc(512, js::MallocArena);
|
||||
ParserAtomsTable atomTable(alloc);
|
||||
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace js::jit;
|
||||
// Check if wasmMarkSlowCall produces the byte sequence that can
|
||||
// wasmCheckSlowCallsite detect.
|
||||
BEGIN_TEST(testWasmCheckSlowCallMarkerHit) {
|
||||
js::LifoAlloc lifo(4096);
|
||||
js::LifoAlloc lifo(4096, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
@@ -58,7 +58,7 @@ END_TEST(testWasmCheckSlowCallMarkerHit)
|
||||
|
||||
// Check if wasmCheckSlowCallsite does not detect non-marked slow calls.
|
||||
BEGIN_TEST(testWasmCheckSlowCallMarkerMiss) {
|
||||
js::LifoAlloc lifo(4096);
|
||||
js::LifoAlloc lifo(4096, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jc(cx);
|
||||
StackMacroAssembler masm(cx, alloc);
|
||||
|
||||
@@ -94,6 +94,7 @@ void InitLargeAllocLimit() {
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_DATA arena_id_t js::MallocArena;
|
||||
JS_PUBLIC_DATA arena_id_t js::BackgroundMallocArena;
|
||||
JS_PUBLIC_DATA arena_id_t js::ArrayBufferContentsArena;
|
||||
JS_PUBLIC_DATA arena_id_t js::StringBufferArena;
|
||||
|
||||
@@ -101,6 +102,7 @@ void js::InitMallocAllocator() {
|
||||
arena_params_t mallocArenaParams;
|
||||
mallocArenaParams.mMaxDirtyIncreaseOverride = 5;
|
||||
MallocArena = moz_create_arena_with_params(&mallocArenaParams);
|
||||
BackgroundMallocArena = moz_create_arena_with_params(&mallocArenaParams);
|
||||
|
||||
arena_params_t params;
|
||||
params.mMaxDirtyIncreaseOverride = 5;
|
||||
|
||||
@@ -383,7 +383,7 @@ void LCovSource::writeScript(JSScript* script, const char* scriptName) {
|
||||
}
|
||||
|
||||
LCovRealm::LCovRealm(JS::Realm* realm)
|
||||
: alloc_(4096), outTN_(&alloc_), sources_(alloc_) {
|
||||
: alloc_(4096, js::MallocArena), outTN_(&alloc_), sources_(alloc_) {
|
||||
// Record realm name. If we wait until finalization, the embedding may not be
|
||||
// able to provide us the name anymore.
|
||||
writeRealmName(realm);
|
||||
|
||||
@@ -215,7 +215,8 @@ bool DelazificationContext::delazify() {
|
||||
// to use it, as it could be purged by a GC in the mean time.
|
||||
StencilScopeBindingCache scopeCache(merger_);
|
||||
|
||||
LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::BackgroundMallocArena);
|
||||
|
||||
while (!strategy_->done()) {
|
||||
if (isInterrupted_) {
|
||||
|
||||
@@ -1006,7 +1006,8 @@ JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options)
|
||||
isEvaluatingModule(this, 0),
|
||||
frontendCollectionPool_(this),
|
||||
suppressProfilerSampling(false),
|
||||
tempLifoAlloc_(this, (size_t)TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
|
||||
tempLifoAlloc_(this, (size_t)TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE,
|
||||
js::MallocArena),
|
||||
debuggerMutations(this, 0),
|
||||
status(this, JS::ExceptionStatus::None),
|
||||
unwrappedException_(this),
|
||||
|
||||
@@ -807,7 +807,8 @@ class InterpreterStack {
|
||||
}
|
||||
|
||||
public:
|
||||
InterpreterStack() : allocator_(DEFAULT_CHUNK_SIZE), frameCount_(0) {}
|
||||
InterpreterStack()
|
||||
: allocator_(DEFAULT_CHUNK_SIZE, js::MallocArena), frameCount_(0) {}
|
||||
|
||||
~InterpreterStack() { MOZ_ASSERT(frameCount_ == 0); }
|
||||
|
||||
|
||||
@@ -1405,7 +1405,7 @@ class MOZ_STACK_CLASS ModuleValidatorShared {
|
||||
moduleFunctionNode_(moduleFunctionNode),
|
||||
moduleFunctionName_(FunctionName(moduleFunctionNode)),
|
||||
standardLibraryMathNames_(fc),
|
||||
validationLifo_(VALIDATION_LIFO_DEFAULT_CHUNK_SIZE),
|
||||
validationLifo_(VALIDATION_LIFO_DEFAULT_CHUNK_SIZE, js::MallocArena),
|
||||
funcDefs_(fc),
|
||||
tables_(fc),
|
||||
globalMap_(fc),
|
||||
|
||||
@@ -1956,7 +1956,7 @@ bool wasm::EnsureBuiltinThunksInitialized(
|
||||
return false;
|
||||
}
|
||||
|
||||
LifoAlloc lifo(BUILTIN_THUNK_LIFO_SIZE);
|
||||
LifoAlloc lifo(BUILTIN_THUNK_LIFO_SIZE, js::MallocArena);
|
||||
TempAllocator tempAlloc(&lifo);
|
||||
WasmMacroAssembler masm(tempAlloc);
|
||||
AutoCreatedBy acb(masm, "wasm::EnsureBuiltinThunksInitialized");
|
||||
|
||||
@@ -558,7 +558,7 @@ bool Code::createManyLazyEntryStubs(const WriteGuard& guard,
|
||||
size_t* stubBlockIndex) const {
|
||||
MOZ_ASSERT(funcExportIndices.length());
|
||||
|
||||
LifoAlloc lifo(LAZY_STUB_LIFO_DEFAULT_CHUNK_SIZE);
|
||||
LifoAlloc lifo(LAZY_STUB_LIFO_DEFAULT_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jitContext;
|
||||
WasmMacroAssembler masm(alloc);
|
||||
|
||||
@@ -87,7 +87,7 @@ ModuleGenerator::ModuleGenerator(const CodeMetadata& codeMeta,
|
||||
featureUsage_(FeatureUsage::None),
|
||||
codeBlock_(nullptr),
|
||||
linkData_(nullptr),
|
||||
lifo_(GENERATOR_LIFO_DEFAULT_CHUNK_SIZE),
|
||||
lifo_(GENERATOR_LIFO_DEFAULT_CHUNK_SIZE, js::MallocArena),
|
||||
masm_(nullptr),
|
||||
debugStubCodeOffset_(0),
|
||||
requestTierUpStubCodeOffset_(0),
|
||||
|
||||
@@ -164,7 +164,7 @@ struct CompileTask : public HelperThreadTask {
|
||||
compilerEnv(compilerEnv),
|
||||
compileState(compileState),
|
||||
state(state),
|
||||
lifo(defaultChunkSize) {}
|
||||
lifo(defaultChunkSize, js::MallocArena) {}
|
||||
|
||||
virtual ~CompileTask() = default;
|
||||
|
||||
|
||||
@@ -9928,7 +9928,8 @@ bool wasm::IonDumpFunction(const CompilerEnvironment& compilerEnv,
|
||||
const FuncCompileInput& func,
|
||||
IonDumpContents contents, GenericPrinter& out,
|
||||
UniqueChars* error) {
|
||||
LifoAlloc lifo(TempAllocator::PreferredLifoChunkSize);
|
||||
LifoAlloc lifo(TempAllocator::PreferredLifoChunkSize,
|
||||
js::BackgroundMallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jitContext;
|
||||
Decoder d(func.begin, func.end, func.lineOrBytecode, error);
|
||||
|
||||
@@ -2930,7 +2930,7 @@ static bool GenerateRequestTierUpStub(MacroAssembler& masm,
|
||||
bool wasm::GenerateEntryStubs(const CodeMetadata& codeMeta,
|
||||
const FuncExportVector& exports,
|
||||
CompiledCode* code) {
|
||||
LifoAlloc lifo(STUBS_LIFO_DEFAULT_CHUNK_SIZE);
|
||||
LifoAlloc lifo(STUBS_LIFO_DEFAULT_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jcx;
|
||||
WasmMacroAssembler masm(alloc);
|
||||
@@ -3034,7 +3034,7 @@ bool wasm::GenerateProvisionalLazyJitEntryStub(MacroAssembler& masm,
|
||||
bool wasm::GenerateStubs(const CodeMetadata& codeMeta,
|
||||
const FuncImportVector& imports,
|
||||
const FuncExportVector& exports, CompiledCode* code) {
|
||||
LifoAlloc lifo(STUBS_LIFO_DEFAULT_CHUNK_SIZE);
|
||||
LifoAlloc lifo(STUBS_LIFO_DEFAULT_CHUNK_SIZE, js::MallocArena);
|
||||
TempAllocator alloc(&lifo);
|
||||
JitContext jcx;
|
||||
WasmMacroAssembler masm(alloc);
|
||||
|
||||
Reference in New Issue
Block a user