Follow-up to bug 990787 - Fix GC hazards introduced by part 1 and part 4, caught by static analysis. Pushing to a CLOSED TREE. r=sfink.

This commit is contained in:
Jason Orendorff 2014-04-08 15:43:39 -05:00
parent 06912887b1
commit fa1d1db711
2 changed files with 9 additions and 6 deletions

View File

@ -1083,12 +1083,7 @@ ThreadSafeContext::recoverFromOutOfMemory()
// If this is not a JSContext, there's nothing to do. // If this is not a JSContext, there's nothing to do.
if (JSContext *maybecx = maybeJSContext()) { if (JSContext *maybecx = maybeJSContext()) {
if (maybecx->isExceptionPending()) { if (maybecx->isExceptionPending()) {
#ifdef DEBUG MOZ_ASSERT(maybecx->isThrowingOutOfMemory());
RootedValue v(maybecx);
bool ok = maybecx->getPendingException(&v);
MOZ_ASSERT(ok);
MOZ_ASSERT(v == StringValue(maybecx->names().outOfMemory));
#endif
maybecx->clearPendingException(); maybecx->clearPendingException();
} else { } else {
MOZ_ASSERT(maybecx->runtime()->hadOutOfMemory); MOZ_ASSERT(maybecx->runtime()->hadOutOfMemory);
@ -1150,6 +1145,12 @@ JSContext::getPendingException(MutableHandleValue rval)
return true; return true;
} }
bool
JSContext::isThrowingOutOfMemory()
{
return throwing && unwrappedException_ == StringValue(names().outOfMemory);
}
void void
JSContext::enterGenerator(JSGenerator *gen) JSContext::enterGenerator(JSGenerator *gen)
{ {

View File

@ -560,6 +560,8 @@ struct JSContext : public js::ExclusiveContext,
MOZ_WARN_UNUSED_RESULT MOZ_WARN_UNUSED_RESULT
bool getPendingException(JS::MutableHandleValue rval); bool getPendingException(JS::MutableHandleValue rval);
bool isThrowingOutOfMemory();
void setPendingException(js::Value v); void setPendingException(js::Value v);
void clearPendingException() { void clearPendingException() {