Bug 1085740 - Reduce heap churn caused by TempAllocator. r=jandem.

This commit is contained in:
Nicholas Nethercote 2014-10-21 15:26:28 -07:00
parent e55b1c1c87
commit f7aebf9715
5 changed files with 18 additions and 13 deletions

View File

@ -8481,7 +8481,7 @@ static bool
FinishModule(ModuleCompiler &m,
ScopedJSDeletePtr<AsmJSModule> *module)
{
LifoAlloc lifo(LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
LifoAlloc lifo(TempAllocator::PreferredLifoChunkSize);
TempAllocator alloc(&lifo);
IonContext ionContext(m.cx(), &alloc);

View File

@ -55,7 +55,6 @@ BaselineScript::BaselineScript(uint32_t prologueOffset, uint32_t epilogueOffset,
flags_(0)
{ }
static const size_t BASELINE_LIFO_ALLOC_PRIMARY_CHUNK_SIZE = 4096;
static const unsigned BASELINE_MAX_ARGS_LENGTH = 20000;
static bool
@ -212,10 +211,10 @@ jit::BaselineCompile(JSContext *cx, JSScript *script)
MOZ_ASSERT(!script->hasBaselineScript());
MOZ_ASSERT(script->canBaselineCompile());
MOZ_ASSERT(IsBaselineEnabled(cx));
LifoAlloc alloc(BASELINE_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
script->ensureNonLazyCanonicalFunction(cx);
LifoAlloc alloc(TempAllocator::PreferredLifoChunkSize);
TempAllocator *temp = alloc.new_<TempAllocator>(&alloc);
if (!temp)
return Method_Error;

View File

@ -1938,8 +1938,6 @@ AttachFinishedCompilations(JSContext *cx)
}
}
static const size_t BUILDER_LIFO_ALLOC_PRIMARY_CHUNK_SIZE = 1 << 12;
static inline bool
OffThreadCompilationAvailable(JSContext *cx)
{
@ -2004,7 +2002,7 @@ IonCompile(JSContext *cx, JSScript *script,
TrackPropertiesForSingletonScopes(cx, script, baselineFrame);
LifoAlloc *alloc = cx->new_<LifoAlloc>(BUILDER_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
LifoAlloc *alloc = cx->new_<LifoAlloc>(TempAllocator::PreferredLifoChunkSize);
if (!alloc)
return AbortReason_Alloc;
@ -3377,3 +3375,8 @@ jit::JitSupportsSimd()
{
return js::jit::MacroAssembler::SupportsSimd();
}
// If you change these, please also change the comment in TempAllocator.
/* static */ const size_t TempAllocator::BallastSize = 16 * 1024;
/* static */ const size_t TempAllocator::PreferredLifoChunkSize = 32 * 1024;

View File

@ -24,6 +24,13 @@ class TempAllocator
LifoAllocScope lifoScope_;
public:
// Most infallible Ion allocations are small, so we use a ballast of 16
// KiB. And with a ballast of 16 KiB, a chunk size of 32 KiB works well,
// because TempAllocators with a peak allocation size of less than 16 KiB
// (which is most of them) only have to allocate a single chunk.
static const size_t BallastSize; // 16 KiB
static const size_t PreferredLifoChunkSize; // 32 KiB
explicit TempAllocator(LifoAlloc *lifoAlloc)
: lifoScope_(lifoAlloc)
{ }
@ -58,9 +65,7 @@ class TempAllocator
}
bool ensureBallast() {
// Most infallible Ion allocations are small, so we use a ballast of
// ~16K for now.
return lifoScope_.alloc().ensureUnusedApproximate(16 * 1024);
return lifoScope_.alloc().ensureUnusedApproximate(BallastSize);
}
};

View File

@ -2869,8 +2869,7 @@ jit::AnalyzeNewScriptDefiniteProperties(JSContext *cx, JSFunction *fun,
Vector<PropertyName *> accessedProperties(cx);
LifoAlloc alloc(types::TypeZone::TYPE_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
LifoAlloc alloc(TempAllocator::PreferredLifoChunkSize);
TempAllocator temp(&alloc);
IonContext ictx(cx, &temp);
@ -3109,8 +3108,7 @@ jit::AnalyzeArgumentsUsage(JSContext *cx, JSScript *scriptArg)
if (!script->ensureHasTypes(cx))
return false;
LifoAlloc alloc(types::TypeZone::TYPE_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
LifoAlloc alloc(TempAllocator::PreferredLifoChunkSize);
TempAllocator temp(&alloc);
IonContext ictx(cx, &temp);