Bug 1029653 - Fix subtle bug in computing the main thread stack limit in PJS. (r=lth)

This commit is contained in:
Shu-yu Guo 2014-06-25 17:30:55 -07:00
parent e00f170c66
commit 2085fa4ebe
2 changed files with 17 additions and 17 deletions

View File

@ -131,13 +131,8 @@ jit::CheckOverRecursedPar(ForkJoinContext *cx)
JS_ASSERT(ForkJoinContext::current() == cx);
int stackDummy_;
// When an interrupt is requested, the main thread stack limit is
// overwritten with a sentinel value that brings us here.
// Therefore, we must check whether this is really a stack overrun
// and, if not, check whether an interrupt was requested.
//
// When not on the main thread, we don't overwrite the stack
// limit, but we do still call into this routine if the interrupt
// In PJS, unlike sequential execution, we don't overwrite the stack limit
// on interrupt, but we do still call into this routine if the interrupt
// flag is set, so we still need to double check.
#if defined(JS_ARM_SIMULATOR) || defined(JS_MIPS_SIMULATOR)
@ -147,13 +142,7 @@ jit::CheckOverRecursedPar(ForkJoinContext *cx)
}
#endif
uintptr_t realStackLimit;
if (cx->isMainThread())
realStackLimit = GetNativeStackLimit(cx);
else
realStackLimit = cx->perThreadData->jitStackLimit;
if (!JS_CHECK_STACK_SIZE(realStackLimit, &stackDummy_)) {
if (!JS_CHECK_STACK_SIZE(cx->perThreadData->jitStackLimit, &stackDummy_)) {
cx->bailoutRecord->joinCause(ParallelBailoutOverRecursed);
return false;
}

View File

@ -1611,9 +1611,20 @@ ForkJoinShared::executeFromMainThread(ThreadPoolWorker *worker)
}
TlsPerThreadData.set(&thisThread);
// Don't use setIonStackLimit() because that acquires the ionStackLimitLock, and the
// lock has not been initialized in these cases.
thisThread.jitStackLimit = oldData->jitStackLimit;
// Subtlety warning: the reason the stack limit is set via
// GetNativeStackLimit instead of oldData->jitStackLimit is because the
// main thread's jitStackLimit could be -1 due to runtime->interrupt being
// set.
//
// In turn, the reason that it is okay for runtime->interrupt to be
// set and for us to still continue PJS execution is because PJS, being
// unable to use the signal-based interrupt handling like sequential JIT
// code, keeps a separate flag, interruptPar, to filter out interrupts
// which should not interrupt JIT code.
//
// Thus, use GetNativeStackLimit instead of just propagating the
// main thread's.
thisThread.jitStackLimit = GetNativeStackLimit(cx_);
executePortion(&thisThread, worker);
TlsPerThreadData.set(oldData);