Stop generating LIR when running out of memory in the regexp compiler (471924, r=danderson).

This commit is contained in:
Andreas Gal 2009-01-02 15:50:56 -08:00
parent a59109830e
commit 6a2d183fee
2 changed files with 6 additions and 3 deletions

View File

@ -2207,6 +2207,8 @@ class RegExpNativeCompiler {
pos = compileFlatSingleChar(node->u.flat.chr, pos, fails);
} else {
for (size_t i = 0; i < node->u.flat.length; ++i) {
if (fragment->lirbuf->outOMem())
return JS_FALSE;
pos = compileFlatSingleChar(((jschar*) node->kid)[i], pos, fails);
if (!pos) break;
}

View File

@ -108,19 +108,20 @@ namespace nanojit
_unused = 0;
_stats.lir = 0;
_noMem = 0;
_nextPage = 0;
for (int i = 0; i < NumSavedRegs; ++i)
savedRegs[i] = NULL;
explicitSavedRegs = false;
// pre-allocate the next page we will be using
_nextPage = pageAlloc();
NanoAssert(_nextPage || _noMem);
}
void LirBuffer::rewind()
{
clear();
// pre-allocate the current and the next page we will be using
Page* start = pageAlloc();
_unused = start ? &start->lir[0] : NULL;
_nextPage = pageAlloc();
NanoAssert((_unused && _nextPage) || _noMem);
}
int32_t LirBuffer::insCount()