Bug 1270108 - IonMonkey: Only keep a certain amount of IonBuilder waiting to get linked alive, r=jandem

This commit is contained in:
Hannes Verschore 2016-05-14 11:52:01 +02:00
parent 9c6551efdd
commit 8f9524759e
4 changed files with 38 additions and 4 deletions

View File

@ -465,7 +465,7 @@ jit::FinishOffThreadBuilder(JSContext* cx, IonBuilder* builder)
// If the builder is still in one of the helper thread list, then remove it.
if (builder->isInList())
builder->removeFrom(HelperThreadState().ionLazyLinkList());
HelperThreadState().ionLazyLinkListRemove(builder);
// Clear the recompiling flag of the old ionScript, since we continue to
// use the old ionScript if recompiling fails.
@ -548,7 +548,7 @@ jit::LazyLink(JSContext* cx, HandleScript calleeScript)
calleeScript->baselineScript()->removePendingIonBuilder(calleeScript);
// Remove from pending.
builder->removeFrom(HelperThreadState().ionLazyLinkList());
HelperThreadState().ionLazyLinkListRemove(builder);
}
{
@ -2019,7 +2019,15 @@ AttachFinishedCompilations(JSContext* cx)
JSScript* script = builder->script();
MOZ_ASSERT(script->hasBaselineScript());
script->baselineScript()->setPendingIonBuilder(cx, script, builder);
HelperThreadState().ionLazyLinkList().insertFront(builder);
HelperThreadState().ionLazyLinkListAdd(builder);
// Don't keep more than 100 lazy link builders.
// Throw away the oldest items.
while (HelperThreadState().ionLazyLinkListSize() > 100) {
jit::IonBuilder* builder = HelperThreadState().ionLazyLinkList().getLast();
jit::FinishOffThreadBuilder(nullptr, builder);
}
continue;
}
}

View File

@ -28,7 +28,7 @@ function foo(code)
toString = c1;
}
let z;
for (z = 1; z <= 1632; ++z) {
for (z = 1; z <= 16322; ++z) {
this.__defineGetter__('functional', function x(){ yield; } );
foo("this.__defineSetter__('', function(){});");
foo("for each (y in this);");

View File

@ -628,6 +628,7 @@ GlobalHelperThreadState::GlobalHelperThreadState()
: cpuCount(0),
threadCount(0),
threads(nullptr),
ionLazyLinkListSize_(0),
wasmCompilationInProgress(false),
numWasmFailedJobs(0),
helperLock(nullptr),
@ -657,6 +658,7 @@ GlobalHelperThreadState::finish()
PR_DestroyLock(helperLock);
ionLazyLinkList_.clear();
ionLazyLinkListSize_ = 0;
}
void
@ -731,6 +733,24 @@ GlobalHelperThreadState::notifyOne(CondVar which)
PR_NotifyCondVar(whichWakeup(which));
}
void
GlobalHelperThreadState::ionLazyLinkListRemove(jit::IonBuilder* builder)
{
MOZ_ASSERT(ionLazyLinkListSize_ > 0);
builder->removeFrom(HelperThreadState().ionLazyLinkList());
ionLazyLinkListSize_--;
MOZ_ASSERT(HelperThreadState().ionLazyLinkList().isEmpty() == (ionLazyLinkListSize_ == 0));
}
void
GlobalHelperThreadState::ionLazyLinkListAdd(jit::IonBuilder* builder)
{
HelperThreadState().ionLazyLinkList().insertFront(builder);
ionLazyLinkListSize_++;
}
bool
GlobalHelperThreadState::hasActiveThreads()
{

View File

@ -72,6 +72,7 @@ class GlobalHelperThreadState
// List of IonBuilders using lazy linking pending to get linked.
IonBuilderList ionLazyLinkList_;
size_t ionLazyLinkListSize_;
// wasm worklist and finished jobs.
wasm::IonCompileTaskVector wasmWorklist_, wasmFinishedList_;
@ -156,6 +157,11 @@ class GlobalHelperThreadState
"Should only be mutated by the main thread.");
return ionLazyLinkList_;
}
size_t ionLazyLinkListSize() {
return ionLazyLinkListSize_;
}
void ionLazyLinkListRemove(jit::IonBuilder* builder);
void ionLazyLinkListAdd(jit::IonBuilder* builder);
wasm::IonCompileTaskVector& wasmWorklist() {
MOZ_ASSERT(isLocked());