Don't botch assert after OOM while linking ICs, bug 727344. r=dvander
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 10 Apr 2012 12:07:26 -0700
changeset 94650 a44bebea2bc8abe1dbfdc70465f5d2579793570c
parent 94649 b78eb58c290083be2fff0a94abc1d1793bc5f2db
child 94651 db71aaa60195df39d781cd375ae898b3a8ed42a0
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs727344
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Don't botch assert after OOM while linking ICs, bug 727344. r=dvander
js/src/methodjit/BaseCompiler.h
js/src/methodjit/MonoIC.cpp
js/src/methodjit/PolyIC.cpp
--- a/js/src/methodjit/BaseCompiler.h
+++ b/js/src/methodjit/BaseCompiler.h
@@ -133,19 +133,17 @@ class LinkerHelper : public JSC::LinkBuf
 #endif
     { }
 
     ~LinkerHelper() {
         JS_ASSERT(verifiedRange);
     }
 
     bool verifyRange(const JSC::JITCode &other) {
-#ifdef DEBUG
-        verifiedRange = true;
-#endif
+        markVerified();
 #ifdef JS_CPU_X64
         return VerifyRange(m_code, m_size, other.start(), other.size());
 #else
         return true;
 #endif
     }
 
     bool verifyRange(JITChunk *chunk) {
@@ -157,16 +155,17 @@ class LinkerHelper : public JSC::LinkBuf
         // The pool is incref'd after this call, so it's necessary to release()
         // on any failure.
         JSScript *script = cx->fp()->script();
         JSC::ExecutableAllocator *allocator = script->compartment()->jaegerCompartment()->execAlloc();
         allocator->setDestroyCallback(Probes::discardExecutableRegion);
         JSC::ExecutablePool *pool;
         m_code = executableAllocAndCopy(masm, allocator, &pool);
         if (!m_code) {
+            markVerified();
             js_ReportOutOfMemory(cx);
             return NULL;
         }
         m_size = masm.size();   // must come after call to executableAllocAndCopy()!
         return pool;
     }
 
     JSC::CodeLocationLabel finalize(VMFrame &f) {
@@ -181,16 +180,23 @@ class LinkerHelper : public JSC::LinkBuf
         if (!jump.isSet())
             return;
         link(jump.get(), label);
     }
 
     size_t size() const {
         return m_size;
     }
+
+  protected:
+    void markVerified() {
+#ifdef DEBUG
+        verifiedRange = true;
+#endif
+    }
 };
 
 class NativeStubLinker : public LinkerHelper
 {
   public:
 #ifdef JS_CPU_X64
     typedef JSC::MacroAssembler::DataLabelPtr FinalJump;
 #else
--- a/js/src/methodjit/MonoIC.cpp
+++ b/js/src/methodjit/MonoIC.cpp
@@ -217,16 +217,17 @@ class EqualityICLinker : public LinkerHe
     { }
 
     bool init(JSContext *cx) {
         JSC::ExecutablePool *pool = LinkerHelper::init(cx);
         if (!pool)
             return false;
         JS_ASSERT(!f.regs.inlined());
         if (!f.chunk()->execPools.append(pool)) {
+            markVerified();
             pool->release();
             js_ReportOutOfMemory(cx);
             return false;
         }
         return true;
     }
 };
 
@@ -433,16 +434,17 @@ NativeStubLinker::init(JSContext *cx)
     if (!pool)
         return false;
 
     NativeCallStub stub;
     stub.pc = pc;
     stub.pool = pool;
     stub.jump = locationOf(done);
     if (!chunk->nativeCallStubs.append(stub)) {
+        markVerified();
         pool->release();
         return false;
     }
 
     return true;
 }
 
 /*
--- a/js/src/methodjit/PolyIC.cpp
+++ b/js/src/methodjit/PolyIC.cpp
@@ -81,16 +81,17 @@ class PICLinker : public LinkerHelper
       : LinkerHelper(masm, JSC::METHOD_CODE), ic(ic)
     { }
 
     bool init(JSContext *cx) {
         JSC::ExecutablePool *pool = LinkerHelper::init(cx);
         if (!pool)
             return false;
         if (!ic.addPool(cx, pool)) {
+            markVerified();
             pool->release();
             js_ReportOutOfMemory(cx);
             return false;
         }
         return true;
     }
 };