Bug 1237508 - Odin: remove function index from Export (r?bbouvier) draft
authorLuke Wagner <luke@mozilla.com>
Wed, 06 Jan 2016 23:23:31 -0600
changeset 319571 164f5f36138a1a4e6666527579b5827bb7c91c4a
parent 319570 200aa49f81d22a35861a04d4171b3792cca3b9ce
child 319572 1a0ba2f985ebde4e009ff46f7e23d5bf036cab07
push id9054
push userlwagner@mozilla.com
push dateThu, 07 Jan 2016 05:25:31 +0000
reviewersbbouvier
bugs1237508
milestone46.0a1
Bug 1237508 - Odin: remove function index from Export (r?bbouvier)
js/src/asmjs/WasmGenerator.cpp
js/src/asmjs/WasmGenerator.h
js/src/asmjs/WasmModule.h
--- a/js/src/asmjs/WasmGenerator.cpp
+++ b/js/src/asmjs/WasmGenerator.cpp
@@ -44,16 +44,17 @@ ModuleGenerator::ModuleGenerator(Exclusi
     masm_(MacroAssembler::AsmJSToken(), alloc_),
     sigs_(cx),
     parallel_(false),
     outstanding_(0),
     tasks_(cx),
     freeTasks_(cx),
     funcBytes_(0),
     funcEntryOffsets_(cx),
+    exportFuncIndices_(cx),
     activeFunc_(nullptr),
     finishedFuncs_(false)
 {
     MOZ_ASSERT(IsCompilingAsmJS());
 }
 
 ModuleGenerator::~ModuleGenerator()
 {
@@ -309,23 +310,24 @@ ModuleGenerator::defineImport(uint32_t i
     import.initJitExitOffset(jitExit.begin);
     return codeRanges_.emplaceBack(CodeRange::ImportInterpExit, interpExit) &&
            codeRanges_.emplaceBack(CodeRange::ImportJitExit, jitExit);
 }
 
 bool
 ModuleGenerator::declareExport(MallocSig&& sig, uint32_t funcIndex)
 {
-    return exports_.emplaceBack(Move(sig), funcIndex);
+    return exports_.emplaceBack(Move(sig)) &&
+           exportFuncIndices_.append(funcIndex);
 }
 
 uint32_t
 ModuleGenerator::exportFuncIndex(uint32_t index) const
 {
-    return exports_[index].funcIndex();
+    return exportFuncIndices_[index];
 }
 
 const MallocSig&
 ModuleGenerator::exportSig(uint32_t index) const
 {
     return exports_[index].sig();
 }
 
--- a/js/src/asmjs/WasmGenerator.h
+++ b/js/src/asmjs/WasmGenerator.h
@@ -49,16 +49,17 @@ typedef Vector<SlowFunction> SlowFunctio
 // A ModuleGenerator encapsulates the creation of a wasm module. During the
 // lifetime of a ModuleGenerator, a sequence of FunctionGenerators are created
 // and destroyed to compile the individual function bodies. After generating all
 // functions, ModuleGenerator::finish() must be called to complete the
 // compilation and extract the resulting wasm module.
 class MOZ_STACK_CLASS ModuleGenerator
 {
     typedef Vector<uint32_t> FuncOffsetVector;
+    typedef Vector<uint32_t> FuncIndexVector;
 
     struct SigHashPolicy
     {
         typedef const MallocSig& Lookup;
         static HashNumber hash(Lookup l) { return l.hash(); }
         static bool match(const LifoSig* lhs, Lookup rhs) { return *lhs == rhs; }
     };
     typedef HashSet<const LifoSig*, SigHashPolicy> SigSet;
@@ -88,16 +89,17 @@ class MOZ_STACK_CLASS ModuleGenerator
     bool                          parallel_;
     uint32_t                      outstanding_;
     Vector<IonCompileTask>        tasks_;
     Vector<IonCompileTask*>       freeTasks_;
 
     // Function compilation
     uint32_t                      funcBytes_;
     FuncOffsetVector              funcEntryOffsets_;
+    FuncIndexVector               exportFuncIndices_;
     DebugOnly<FunctionGenerator*> activeFunc_;
     DebugOnly<bool>               finishedFuncs_;
 
     bool allocateGlobalBytes(uint32_t bytes, uint32_t align, uint32_t* globalDataOffset);
     bool finishOutstandingTask();
     bool finishTask(IonCompileTask* task);
 
   public:
--- a/js/src/asmjs/WasmModule.h
+++ b/js/src/asmjs/WasmModule.h
@@ -98,41 +98,36 @@ typedef UniquePtr<StaticLinkData, JS::De
 
 // An Export describes an export from a wasm module. Currently only functions
 // can be exported.
 
 class Export
 {
     MallocSig sig_;
     struct CacheablePod {
-        uint32_t funcIndex_;
         uint32_t stubOffset_;
     } pod;
 
   public:
     Export() = default;
-    Export(MallocSig&& sig, uint32_t funcIndex)
+    explicit Export(MallocSig&& sig)
       : sig_(Move(sig))
     {
-        pod.funcIndex_ = funcIndex;
         pod.stubOffset_ = UINT32_MAX;
     }
     Export(Export&& rhs)
       : sig_(Move(rhs.sig_)),
         pod(rhs.pod)
     {}
 
     void initStubOffset(uint32_t stubOffset) {
         MOZ_ASSERT(pod.stubOffset_ == UINT32_MAX);
         pod.stubOffset_ = stubOffset;
     }
 
-    uint32_t funcIndex() const {
-        return pod.funcIndex_;
-    }
     uint32_t stubOffset() const {
         return pod.stubOffset_;
     }
     const MallocSig& sig() const {
         return sig_;
     }
 
     WASM_DECLARE_SERIALIZABLE(Export)