Bug 1248860 - Odin: move CompileArgs to ModuleGeneratorData (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Wed, 17 Feb 2016 09:30:48 -0600
changeset 331618 185f8e002c0e7f4f2828ce0e23001d74392d0013
parent 331617 e9a8fbf9af4de82175576729996a6f01c9a06330
child 331619 c4d7e7b3172fc806afe55879c19f1e31894cd546
push id11020
push userjolesen@mozilla.com
push dateWed, 17 Feb 2016 18:16:38 +0000
reviewersbbouvier
bugs1248860
milestone47.0a1
Bug 1248860 - Odin: move CompileArgs to ModuleGeneratorData (r=bbouvier) MozReview-Commit-ID: L2d6zJSJw2y
js/src/asmjs/AsmJS.cpp
js/src/asmjs/Wasm.cpp
js/src/asmjs/WasmGenerator.cpp
js/src/asmjs/WasmGenerator.h
js/src/asmjs/WasmIonCompile.cpp
js/src/asmjs/WasmIonCompile.h
js/src/asmjs/WasmText.cpp
--- a/js/src/asmjs/AsmJS.cpp
+++ b/js/src/asmjs/AsmJS.cpp
@@ -1778,17 +1778,17 @@ class MOZ_STACK_CLASS ModuleValidator
 #define ADDSTDLIBSIMDOPNAME(op) || !addStandardLibrarySimdOpName(#op, SimdOperation::Fn_##op)
         if (!standardLibrarySimdOpNames_.init()
             FORALL_SIMD_ASMJS_OP(ADDSTDLIBSIMDOPNAME))
         {
             return false;
         }
 #undef ADDSTDLIBSIMDOPNAME
 
-        UniqueModuleGeneratorData genData = MakeUnique<ModuleGeneratorData>(ModuleKind::AsmJS);
+        UniqueModuleGeneratorData genData = MakeUnique<ModuleGeneratorData>(cx_, ModuleKind::AsmJS);
         if (!genData ||
             !genData->sigs.resize(MaxSigs) ||
             !genData->funcSigs.resize(MaxFuncs) ||
             !genData->imports.resize(MaxImports) ||
             !genData->sigToTable.resize(MaxSigs))
         {
             return false;
         }
--- a/js/src/asmjs/Wasm.cpp
+++ b/js/src/asmjs/Wasm.cpp
@@ -1160,17 +1160,17 @@ DecodeModule(JSContext* cx, UniqueChars 
 
     uint32_t u32;
     if (!d.readFixedU32(&u32) || u32 != MagicNumber)
         return Fail(cx, d, "failed to match magic number");
 
     if (!d.readFixedU32(&u32) || u32 != EncodingVersion)
         return Fail(cx, d, "failed to match binary version");
 
-    UniqueModuleGeneratorData init = MakeUnique<ModuleGeneratorData>();
+    UniqueModuleGeneratorData init = js::MakeUnique<ModuleGeneratorData>(cx);
     if (!init)
         return false;
 
     if (!DecodeSignatureSection(cx, d, init.get()))
         return false;
 
     if (!DecodeImportSection(cx, d, init.get(), importNames))
         return false;
--- a/js/src/asmjs/WasmGenerator.cpp
+++ b/js/src/asmjs/WasmGenerator.cpp
@@ -115,17 +115,17 @@ ModuleGenerator::init(UniqueModuleGenera
     if (!funcIndexToExport_.init())
         return false;
 
     module_ = MakeUnique<ModuleData>();
     if (!module_)
         return false;
 
     module_->globalBytes = InitialGlobalDataBytes;
-    module_->compileArgs = CompileArgs(cx_);
+    module_->compileArgs = shared->args;
     module_->kind = shared->kind;
     module_->heapUsage = HeapUsage::None;
     module_->filename = Move(filename);
 
     exportMap_ = MakeUnique<ExportMap>();
     if (!exportMap_)
         return false;
 
@@ -759,17 +759,17 @@ ModuleGenerator::startFuncDefs()
     } else {
         numTasks = 1;
     }
 
     if (!tasks_.initCapacity(numTasks))
         return false;
     JSRuntime* rt = cx_->compartment()->runtimeFromAnyThread();
     for (size_t i = 0; i < numTasks; i++)
-        tasks_.infallibleEmplaceBack(rt, args(), *threadView_, COMPILATION_LIFO_DEFAULT_CHUNK_SIZE);
+        tasks_.infallibleEmplaceBack(rt, *threadView_, COMPILATION_LIFO_DEFAULT_CHUNK_SIZE);
 
     if (!freeTasks_.reserve(numTasks))
         return false;
     for (size_t i = 0; i < numTasks; i++)
         freeTasks_.infallibleAppend(&tasks_[i]);
 
     MOZ_ASSERT(startedFuncDefs());
     return true;
--- a/js/src/asmjs/WasmGenerator.h
+++ b/js/src/asmjs/WasmGenerator.h
@@ -91,31 +91,32 @@ struct AsmJSGlobalVariable
       : type(type), globalDataOffset(offset), isConst(isConst)
     {}
 };
 
 typedef Vector<AsmJSGlobalVariable, 0, SystemAllocPolicy> AsmJSGlobalVariableVector;
 
 struct ModuleGeneratorData
 {
+    CompileArgs                     args;
     ModuleKind                      kind;
     uint32_t                        numTableElems;
 
     DeclaredSigVector               sigs;
     TableModuleGeneratorDataVector  sigToTable;
     DeclaredSigPtrVector            funcSigs;
     ImportModuleGeneratorDataVector imports;
     AsmJSGlobalVariableVector       globals;
 
     uint32_t funcSigIndex(uint32_t funcIndex) const {
         return funcSigs[funcIndex] - sigs.begin();
     }
 
-    explicit ModuleGeneratorData(ModuleKind kind = ModuleKind::Wasm)
-      : kind(kind), numTableElems(0)
+    explicit ModuleGeneratorData(ExclusiveContext* cx, ModuleKind kind = ModuleKind::Wasm)
+      : args(cx), kind(kind), numTableElems(0)
     {}
 };
 
 typedef UniquePtr<ModuleGeneratorData> UniqueModuleGeneratorData;
 
 // The ModuleGeneratorThreadView class presents a restricted, read-only view of
 // the shared state needed by helper threads. There is only one
 // ModuleGeneratorThreadView object owned by ModuleGenerator and referenced by
@@ -124,16 +125,19 @@ typedef UniquePtr<ModuleGeneratorData> U
 class ModuleGeneratorThreadView
 {
     const ModuleGeneratorData& shared_;
 
   public:
     explicit ModuleGeneratorThreadView(const ModuleGeneratorData& shared)
       : shared_(shared)
     {}
+    CompileArgs args() const {
+        return shared_.args;
+    }
     bool isAsmJS() const {
         return shared_.kind == ModuleKind::AsmJS;
     }
     uint32_t numTableElems() const {
         MOZ_ASSERT(!isAsmJS());
         return shared_.numTableElems;
     }
     const DeclaredSig& sig(uint32_t sigIndex) const {
--- a/js/src/asmjs/WasmIonCompile.cpp
+++ b/js/src/asmjs/WasmIonCompile.cpp
@@ -3016,17 +3016,17 @@ wasm::IonCompileFunction(IonCompileTask*
 
     JitContext jitContext(CompileRuntime::get(task->runtime()), &results.alloc());
 
     const JitCompileOptions options;
     MIRGraph graph(&results.alloc());
     CompileInfo compileInfo(func.numLocals());
     MIRGenerator mir(nullptr, options, &results.alloc(), &graph, &compileInfo,
                      IonOptimizations.get(OptimizationLevel::AsmJS),
-                     task->args().useSignalHandlersForOOB);
+                     task->mg().args().useSignalHandlersForOOB);
 
     // Build MIR graph
     {
         FunctionCompiler f(task->mg(), func, mir, results);
         if (!f.init())
             return false;
 
         MDefinition* last = nullptr;
--- a/js/src/asmjs/WasmIonCompile.h
+++ b/js/src/asmjs/WasmIonCompile.h
@@ -62,43 +62,34 @@ class FuncCompileResults
 // IonCompileTask is filled with the wasm code to be compiled on the main
 // validation thread, sent off to an Ion compilation helper thread which creates
 // the FuncCompileResults, and finally sent back to the validation thread. To
 // save time allocating and freeing memory, IonCompileTasks are reset() and
 // reused.
 class IonCompileTask
 {
     JSRuntime* const runtime_;
-    const CompileArgs args_;
     ModuleGeneratorThreadView& mg_;
     LifoAlloc lifo_;
     UniqueFuncBytecode func_;
     mozilla::Maybe<FuncCompileResults> results_;
 
     IonCompileTask(const IonCompileTask&) = delete;
     IonCompileTask& operator=(const IonCompileTask&) = delete;
 
   public:
-    IonCompileTask(JSRuntime* rt, CompileArgs args, ModuleGeneratorThreadView& mg,
-                   size_t defaultChunkSize)
-      : runtime_(rt),
-        args_(args),
-        mg_(mg),
-        lifo_(defaultChunkSize),
-        func_(nullptr)
+    IonCompileTask(JSRuntime* rt, ModuleGeneratorThreadView& mg, size_t defaultChunkSize)
+      : runtime_(rt), mg_(mg), lifo_(defaultChunkSize), func_(nullptr)
     {}
     JSRuntime* runtime() const {
         return runtime_;
     }
     LifoAlloc& lifo() {
         return lifo_;
     }
-    CompileArgs args() const {
-        return args_;
-    }
     ModuleGeneratorThreadView& mg() const {
         return mg_;
     }
     void init(UniqueFuncBytecode func) {
         MOZ_ASSERT(!func_);
         func_ = mozilla::Move(func);
         results_.emplace(lifo_);
     }
--- a/js/src/asmjs/WasmText.cpp
+++ b/js/src/asmjs/WasmText.cpp
@@ -29,16 +29,17 @@
 
 #include "asmjs/WasmBinary.h"
 #include "ds/LifoAlloc.h"
 #include "js/CharacterEncoding.h"
 #include "js/HashTable.h"
 
 using namespace js;
 using namespace js::wasm;
+
 using mozilla::BitwiseCast;
 using mozilla::CountLeadingZeroes32;
 using mozilla::CheckedInt;
 using mozilla::FloatingPoint;
 using mozilla::Maybe;
 using mozilla::PositiveInfinity;
 using mozilla::SpecificNaN;