Bug 1343594 - Baldr: remove dead functionlocs (r=yury)
authorLuke Wagner <luke@mozilla.com>
Thu, 02 Mar 2017 16:49:08 -0600
changeset 374773 d2ad3e67b80b59188baa34f981dc2d267490efe0
parent 374772 85613fa0c5fec9e51f428debcb1d05aaa33f73da
child 374774 c5c15cca280a57fdd7553bc2f3b053dd877a403e
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyury
bugs1343594
milestone54.0a1
Bug 1343594 - Baldr: remove dead functionlocs (r=yury) MozReview-Commit-ID: 2gkcP5rkQjM
js/src/wasm/WasmBinaryToExperimentalText.cpp
js/src/wasm/WasmBinaryToText.cpp
js/src/wasm/WasmCode.cpp
js/src/wasm/WasmCode.h
--- a/js/src/wasm/WasmBinaryToExperimentalText.cpp
+++ b/js/src/wasm/WasmBinaryToExperimentalText.cpp
@@ -1702,19 +1702,16 @@ PrintExportSection(WasmPrintContext& c, 
 }
 
 static bool
 PrintFunctionBody(WasmPrintContext& c, AstFunc& func, const AstModule::SigVector& sigs)
 {
     const AstSig* sig = sigs[func.sig().index()];
     c.indent++;
 
-    size_t startExprIndex = c.maybeSourceMap ? c.maybeSourceMap->exprlocs().length() : 0;
-    uint32_t startLineno = c.buffer.lineno();
-
     uint32_t argsNum = sig->args().length();
     uint32_t localsNum = func.vars().length();
     if (localsNum > 0) {
         if (!PrintIndent(c))
             return false;
         if (!c.buffer.append("var "))
             return false;
         for (uint32_t i = 0; i < localsNum; i++) {
@@ -1741,23 +1738,18 @@ PrintFunctionBody(WasmPrintContext& c, A
     uint32_t exprsNum = func.body().length();
     for (uint32_t i = 0; i < exprsNum; i++) {
       if (!PrintBlockLevelExpr(c, *func.body()[i], i + 1 == exprsNum))
           return false;
     }
 
     c.indent--;
 
-    size_t endExprIndex = c.maybeSourceMap ? c.maybeSourceMap->exprlocs().length() : 0;
-    uint32_t endLineno = c.buffer.lineno();
-
     if (c.maybeSourceMap) {
-        if (!c.maybeSourceMap->exprlocs().emplaceBack(endLineno, c.buffer.column(), func.endOffset()))
-            return false;
-        if (!c.maybeSourceMap->functionlocs().emplaceBack(startExprIndex, endExprIndex, startLineno, endLineno))
+        if (!c.maybeSourceMap->exprlocs().emplaceBack(c.buffer.lineno(), c.buffer.column(), func.endOffset()))
             return false;
     }
     return true;
 }
 
 static bool
 PrintCodeSection(WasmPrintContext& c, const AstModule::FuncVector& funcs, const AstModule::SigVector& sigs)
 {
--- a/js/src/wasm/WasmBinaryToText.cpp
+++ b/js/src/wasm/WasmBinaryToText.cpp
@@ -1526,19 +1526,16 @@ RenderExportSection(WasmRenderContext& c
     return true;
 }
 
 static bool
 RenderFunctionBody(WasmRenderContext& c, AstFunc& func, const AstModule::SigVector& sigs)
 {
     const AstSig* sig = sigs[func.sig().index()];
 
-    size_t startExprIndex = c.maybeSourceMap ? c.maybeSourceMap->exprlocs().length() : 0;
-    uint32_t startLineno = c.buffer.lineno();
-
     uint32_t argsNum = sig->args().length();
     uint32_t localsNum = func.vars().length();
     if (localsNum > 0) {
         if (!RenderIndent(c))
             return false;
         for (uint32_t i = 0; i < localsNum; i++) {
             if (!c.buffer.append("(local "))
                 return false;
@@ -1561,27 +1558,19 @@ RenderFunctionBody(WasmRenderContext& c,
 
 
     uint32_t exprsNum = func.body().length();
     for (uint32_t i = 0; i < exprsNum; i++) {
         if (!RenderExpr(c, *func.body()[i]))
             return false;
     }
 
-    size_t endExprIndex = c.maybeSourceMap ? c.maybeSourceMap->exprlocs().length() : 0;
-    uint32_t endLineno = c.buffer.lineno();
-
     if (c.maybeSourceMap) {
-        if (!c.maybeSourceMap->exprlocs().emplaceBack(endLineno, c.buffer.column(), func.endOffset()))
+        if (!c.maybeSourceMap->exprlocs().emplaceBack(c.buffer.lineno(), c.buffer.column(), func.endOffset()))
             return false;
-        if (!c.maybeSourceMap->functionlocs().emplaceBack(startExprIndex, endExprIndex,
-                                                          startLineno, endLineno))
-        {
-            return false;
-        }
     }
 
     return true;
 }
 
 static bool
 RenderCodeSection(WasmRenderContext& c, const AstModule::FuncVector& funcs,
                   const AstModule::SigVector& sigs)
--- a/js/src/wasm/WasmCode.cpp
+++ b/js/src/wasm/WasmCode.cpp
@@ -758,29 +758,22 @@ Code::createText(JSContext* cx)
             return nullptr;
         }
         maybeSourceMap_ = Move(sourceMap);
 
         if (!BinaryToText(cx, bytes.begin(), bytes.length(), buffer, maybeSourceMap_.get()))
             return nullptr;
 
 #if DEBUG
-        // Checking source map invariant: expression and function locations must be sorted
-        // by line number.
+        // Check that expression locations are sorted by line number.
         uint32_t lastLineno = 0;
         for (const ExprLoc& loc : maybeSourceMap_->exprlocs()) {
             MOZ_ASSERT(lastLineno <= loc.lineno);
             lastLineno = loc.lineno;
         }
-        lastLineno = 0;
-        for (const FunctionLoc& loc : maybeSourceMap_->functionlocs()) {
-            MOZ_ASSERT(lastLineno <= loc.startLineno);
-            MOZ_ASSERT(loc.startLineno <= loc.endLineno);
-            lastLineno = loc.endLineno + 1;
-        }
 #endif
     } else {
         if (!buffer.append(enabledMessage))
             return nullptr;
     }
     return buffer.finishString();
 }
 
--- a/js/src/wasm/WasmCode.h
+++ b/js/src/wasm/WasmCode.h
@@ -524,66 +524,39 @@ struct ExprLoc
     uint32_t offset;
     ExprLoc() : lineno(0), column(0), offset(0) {}
     ExprLoc(uint32_t lineno_, uint32_t column_, uint32_t offset_)
       : lineno(lineno_), column(column_), offset(offset_)
     {}
 };
 
 typedef Vector<ExprLoc, 0, SystemAllocPolicy> ExprLocVector;
-
-// The generated source WebAssembly function lines and expressions ranges.
-
-struct FunctionLoc
-{
-    size_t startExprsIndex;
-    size_t endExprsIndex;
-    uint32_t startLineno;
-    uint32_t endLineno;
-    FunctionLoc(size_t startExprsIndex_, size_t endExprsIndex_, uint32_t startLineno_, uint32_t endLineno_)
-      : startExprsIndex(startExprsIndex_),
-        endExprsIndex(endExprsIndex_),
-        startLineno(startLineno_),
-        endLineno(endLineno_)
-    {}
-};
-
-typedef Vector<FunctionLoc, 0, SystemAllocPolicy> FunctionLocVector;
-
 typedef Vector<uint32_t, 0, SystemAllocPolicy> ExprLocIndexVector;
 
 // The generated source map for WebAssembly binary file. This map is generated during
 // building the text buffer (see BinaryToExperimentalText).
 
 class GeneratedSourceMap
 {
     ExprLocVector exprlocs_;
-    FunctionLocVector functionlocs_;
     UniquePtr<ExprLocIndexVector> sortedByOffsetExprLocIndices_;
     uint32_t totalLines_;
 
   public:
-    explicit GeneratedSourceMap()
-     : exprlocs_(),
-       functionlocs_(),
-       totalLines_(0)
-    {}
+    explicit GeneratedSourceMap() : totalLines_(0) {}
     ExprLocVector& exprlocs() { return exprlocs_; }
-    FunctionLocVector& functionlocs() { return functionlocs_; }
 
     uint32_t totalLines() { return totalLines_; }
     void setTotalLines(uint32_t val) { totalLines_ = val; }
 
     bool searchLineByOffset(JSContext* cx, uint32_t offset, size_t* exprlocIndex);
 };
 
 typedef UniquePtr<GeneratedSourceMap> UniqueGeneratedSourceMap;
-
 typedef HashMap<uint32_t, uint32_t, DefaultHasher<uint32_t>, SystemAllocPolicy> StepModeCounters;
-
 typedef HashMap<uint32_t, WasmBreakpointSite*, DefaultHasher<uint32_t>, SystemAllocPolicy> WasmBreakpointSiteMap;
 
 // Code objects own executable code and the metadata that describes it. At the
 // moment, Code objects are owned uniquely by instances since CodeSegments are
 // not shareable. However, once this restriction is removed, a single Code
 // object will be shared between a module and all its instances.
 
 class Code