Skip to content

Commit

Permalink
Bug 1404306 - Set ION_COMPILING_SCRIPT in AutoLockHelperThreadState s…
Browse files Browse the repository at this point in the history
…cope to avoid a shell-only race. r=jonco
  • Loading branch information
jandem committed Oct 11, 2017
1 parent 98c5d33 commit 8824c01
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion js/src/jit/Ion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,8 @@ IonCompile(JSContext* cx, JSScript* script,
if (!CreateMIRRootList(*builder))
return AbortReason::Alloc;

if (!StartOffThreadIonCompile(cx, builder)) {
AutoLockHelperThreadState lock;
if (!StartOffThreadIonCompile(cx, builder, lock)) {
JitSpew(JitSpew_IonAbort, "Unable to start off-thread ion compilation.");
builder->graphSpewer().endFunction();
return AbortReason::Alloc;
Expand Down
2 changes: 1 addition & 1 deletion js/src/jsscriptinlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ JSScript::setBaselineScript(JSRuntime* maybeRuntime, js::jit::BaselineScript* ba
{
if (hasBaselineScript())
js::jit::BaselineScript::writeBarrierPre(zone(), baseline);
MOZ_ASSERT(!hasIonScript());
MOZ_ASSERT(!ion || ion == ION_DISABLED_SCRIPT);
baseline = baselineScript;
resetWarmUpResetCounter();
updateBaselineOrIonRaw(maybeRuntime);
Expand Down
5 changes: 2 additions & 3 deletions js/src/vm/HelperThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ js::CancelOffThreadWasmTier2Generator()
}

bool
js::StartOffThreadIonCompile(JSContext* cx, jit::IonBuilder* builder)
js::StartOffThreadIonCompile(JSContext* cx, jit::IonBuilder* builder,
const AutoLockHelperThreadState& lock)
{
AutoLockHelperThreadState lock;

if (!HelperThreadState().ionWorklist(lock).append(builder))
return false;

Expand Down
9 changes: 2 additions & 7 deletions js/src/vm/HelperThreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ StartOffThreadPromiseHelperTask(JSContext* cx, UniquePtr<PromiseHelperTask> task
* generated and read everything needed from the VM state.
*/
bool
StartOffThreadIonCompile(JSContext* cx, jit::IonBuilder* builder);
StartOffThreadIonCompile(JSContext* cx, jit::IonBuilder* builder,
const AutoLockHelperThreadState& lock);

/*
* Schedule deletion of Ion compilation data.
Expand Down Expand Up @@ -539,12 +540,6 @@ CancelOffThreadIonCompilesUsingNurseryPointers(JSRuntime* runtime)
CancelOffThreadIonCompile(CompilationSelector(CompilationsUsingNursery{runtime}), true);
}

inline void
CancelOffThreadIonCompile()
{
CancelOffThreadIonCompile(CompilationSelector(AllCompilations()), false);
}

#ifdef DEBUG
bool
HasOffThreadIonCompile(JSCompartment* comp);
Expand Down

0 comments on commit 8824c01

Please sign in to comment.