Bug 780549 - AutoEnterCompilation: Handle init error cases. r=bhackett
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Thu, 27 Dec 2012 07:12:09 -0800
changeset 117101 58d263c1c3dcb864c47ecbb2bc94f32aa5e0571a
parent 117100 f3e277d2e0c167546b8a68edcfd39f5d239c9f55
child 117102 7ef62857f69f359fd52553154890438d5953df6e
push id20312
push usernpierron@mozilla.com
push dateThu, 27 Dec 2012 15:15:39 +0000
treeherdermozilla-inbound@58d263c1c3dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs780549
milestone20.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
Bug 780549 - AutoEnterCompilation: Handle init error cases. r=bhackett
js/src/jsinferinlines.h
--- a/js/src/jsinferinlines.h
+++ b/js/src/jsinferinlines.h
@@ -436,35 +436,42 @@ struct AutoEnterCompilation
         if (!types.constrainedOutputs) {
             types.constrainedOutputs = cx->new_< Vector<CompilerOutput> >(cx);
             if (!types.constrainedOutputs) {
                 types.setPendingNukeTypes(cx);
                 return false;
             }
         }
 
-        info.outputIndex = cx->compartment->types.constrainedOutputs->length();
+        info.outputIndex = types.constrainedOutputs->length();
         // I hope we GC before we reach 64k of compilation attempts.
         if (info.outputIndex >= RecompileInfo::NoCompilerRunning)
             return false;
 
-        if (!cx->compartment->types.constrainedOutputs->append(co))
+        if (!types.constrainedOutputs->append(co)) {
+            info.outputIndex = RecompileInfo::NoCompilerRunning;
             return false;
+        }
         return true;
     }
 
     void initExisting(RecompileInfo oldInfo)
     {
         // Initialize the active compilation index from that produced during a
         // previous compilation, for finishing an off thread compilation.
         info = oldInfo;
     }
 
     ~AutoEnterCompilation()
     {
+        // Handle failure cases of init.
+        if (info.outputIndex >= RecompileInfo::NoCompilerRunning)
+            return;
+
+        JS_ASSERT(info.outputIndex < cx->compartment->types.constrainedOutputs->length());
         CompilerOutput *co = info.compilerOutput(cx);
         co->pendingRecompilation = false;
         if (!co->isValid())
             co->invalidate();
 
         info.outputIndex = RecompileInfo::NoCompilerRunning;
     }
 };