Bug 868684 - OdinMonkey: sequential compilation allocates LIR in the tempLifoAlloc (r=sstangl)
authorLuke Wagner <luke@mozilla.com>
Mon, 06 May 2013 16:05:19 -0700
changeset 142012 983dd922cef2240e957fc741141b4ae20ec43c5d
parent 142011 ffa5c9610cba0fc62809cdba695c9a1d00045a12
child 142013 f0b7c3e3b6227984ca552110d17b32e8102e643c
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs868684
milestone23.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 868684 - OdinMonkey: sequential compilation allocates LIR in the tempLifoAlloc (r=sstangl)
js/src/ion/AsmJS.cpp
js/src/ion/Ion.cpp
js/src/ion/Ion.h
js/src/ion/shared/Assembler-shared.h
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -1054,17 +1054,16 @@ class ModuleCompiler
 
   private:
     typedef HashMap<PropertyName*, AsmJSMathBuiltin> MathNameMap;
     typedef HashMap<PropertyName*, Global> GlobalMap;
     typedef Vector<Func> FuncVector;
     typedef Vector<AsmJSGlobalAccess> GlobalAccessVector;
 
     JSContext *                    cx_;
-    IonContext                     ictx_;
     MacroAssembler                 masm_;
 
     ScopedJSDeletePtr<AsmJSModule> module_;
 
     PropertyName *                 moduleFunctionName_;
 
     GlobalMap                      globals_;
     FuncVector                     functions_;
@@ -1086,17 +1085,16 @@ class ModuleCompiler
         if (!atom)
             return false;
         return standardLibraryMathNames_.putNew(atom->asPropertyName(), builtin);
     }
 
   public:
     ModuleCompiler(JSContext *cx, TokenStream &ts)
       : cx_(cx),
-        ictx_(cx->runtime),
         masm_(cx),
         moduleFunctionName_(NULL),
         globals_(cx),
         functions_(cx),
         funcPtrTables_(cx),
         exits_(cx),
         standardLibraryMathNames_(cx),
         globalAccesses_(cx),
@@ -4516,16 +4514,18 @@ CheckFunctionBodiesSequential(ModuleComp
         LifoAllocScope scope(&lifo);
 
         MIRGenerator *mirGen = CheckFunctionBody(m, func, lifo);
         if (!mirGen)
             return false;
 
         IonSpewNewFunction(&mirGen->graph(), NullPtr());
 
+        IonContext icx(m.cx()->compartment, &mirGen->temp());
+
         if (!OptimizeMIR(mirGen))
             return m.fail("Internal compiler failure (probably out of memory)", func.fn());
 
         LIRGraph *lir = GenerateLIR(mirGen);
         if (!lir)
             return m.fail("Internal compiler failure (probably out of memory)", func.fn());
 
         if (!GenerateAsmJSCode(m, func, *mirGen, *lir))
--- a/js/src/ion/Ion.cpp
+++ b/js/src/ion/Ion.cpp
@@ -98,16 +98,22 @@ ion::SetIonContext(IonContext *ctx)
 
 IonContext *
 ion::GetIonContext()
 {
     JS_ASSERT(CurrentIonContext());
     return CurrentIonContext();
 }
 
+IonContext *
+ion::MaybeGetIonContext()
+{
+    return CurrentIonContext();
+}
+
 IonContext::IonContext(JSContext *cx, TempAllocator *temp)
   : runtime(cx->runtime),
     cx(cx),
     compartment(cx->compartment),
     temp(temp),
     prev_(CurrentIonContext()),
     assemblerCount_(0)
 {
--- a/js/src/ion/Ion.h
+++ b/js/src/ion/Ion.h
@@ -267,16 +267,17 @@ class IonContext
 
 extern IonOptions js_IonOptions;
 
 // Initialize Ion statically for all JSRuntimes.
 bool InitializeIon();
 
 // Get and set the current Ion context.
 IonContext *GetIonContext();
+IonContext *MaybeGetIonContext();
 
 bool SetIonContext(IonContext *ctx);
 
 bool CanIonCompileScript(JSContext *cx, HandleScript script, bool osr);
 
 MethodStatus CanEnterAtBranch(JSContext *cx, JSScript *script,
                               AbstractFramePtr fp, jsbytecode *pc, bool isConstructing);
 MethodStatus CanEnter(JSContext *cx, JSScript *script, AbstractFramePtr fp, bool isConstructing);
--- a/js/src/ion/shared/Assembler-shared.h
+++ b/js/src/ion/shared/Assembler-shared.h
@@ -256,17 +256,17 @@ class Label : public LabelBase
     Label(const Label &label) : LabelBase(label)
     { }
     ~Label()
     {
 #ifdef DEBUG
         // Note: the condition is a hack to silence this assert when OOM testing,
         // see bug 756614.
         if (!js_IonOptions.parallelCompilation)
-            JS_ASSERT_IF(!GetIonContext()->runtime->hadOutOfMemory, !used());
+            JS_ASSERT_IF(MaybeGetIonContext() && !GetIonContext()->runtime->hadOutOfMemory, !used());
 #endif
     }
 };
 
 // Wrapper around Label, on the heap, to avoid a bogus assert with OOM.
 struct HeapLabel
   : public TempObject,
     public Label