From 6a2d183fee258be78d0a568cee42718250c6c272 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Fri, 2 Jan 2009 15:50:56 -0800 Subject: [PATCH] Stop generating LIR when running out of memory in the regexp compiler (471924, r=danderson). --- js/src/jsregexp.cpp | 2 ++ js/src/nanojit/LIR.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/src/jsregexp.cpp b/js/src/jsregexp.cpp index f77585bdb4e..f84831a0d2a 100644 --- a/js/src/jsregexp.cpp +++ b/js/src/jsregexp.cpp @@ -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; } diff --git a/js/src/nanojit/LIR.cpp b/js/src/nanojit/LIR.cpp index 5e5e54571ab..83745e04891 100755 --- a/js/src/nanojit/LIR.cpp +++ b/js/src/nanojit/LIR.cpp @@ -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()