Bug 1385842 - Clean-up InWorklist flags in case of OOM. r=tcampbell

This commit is contained in:
Nicolas B. Pierron 2017-09-20 09:57:18 +00:00
Родитель 79bca6297c
Коммит dbb5850a90
1 изменённых файлов: 21 добавлений и 9 удалений

Просмотреть файл

@ -6,6 +6,8 @@
#include "jit/LIR.h"
#include "mozilla/ScopeExit.h"
#include <ctype.h>
#include "jsprf.h"
@ -235,10 +237,18 @@ LRecoverInfo::appendDefinition(MDefinition* def)
{
MOZ_ASSERT(def->isRecoveredOnBailout());
def->setInWorklist();
auto clearWorklistFlagOnFailure = mozilla::MakeScopeExit([&] {
def->setNotInWorklist();
});
if (!appendOperands(def))
return false;
return instructions_.append(def);
if (!instructions_.append(def))
return false;
clearWorklistFlagOnFailure.release();
return true;
}
bool
@ -262,6 +272,16 @@ LRecoverInfo::appendResumePoint(MResumePoint* rp)
bool
LRecoverInfo::init(MResumePoint* rp)
{
// Before exiting this function, remove temporary flags from all definitions
// added in the vector.
auto clearWorklistFlags = mozilla::MakeScopeExit([&] {
for (MNode** it = begin(); it != end(); it++) {
if (!(*it)->isDefinition())
continue;
(*it)->toDefinition()->setNotInWorklist();
}
});
// Sort operations in the order in which we need to restore the stack. This
// implies that outer frames, as well as operations needed to recover the
// current frame, are located before the current frame. The inner-most
@ -269,14 +289,6 @@ LRecoverInfo::init(MResumePoint* rp)
if (!appendResumePoint(rp))
return false;
// Remove temporary flags from all definitions.
for (MNode** it = begin(); it != end(); it++) {
if (!(*it)->isDefinition())
continue;
(*it)->toDefinition()->setNotInWorklist();
}
MOZ_ASSERT(mir() == rp);
return true;
}