Bug 1346010: Properly render the name of func imports when there's at least one non-func import; r=yury a=jcristau
authorBenjamin Bouvier <benj@benj.me>
Fri, 10 Mar 2017 12:21:39 +0100
changeset 395134 2816763298de292c2c00a8c921d1b81f26d4b7ea
parent 395133 4b4accef4785dc1a46c80f940dad7af3ebbcd9b3
child 395135 2cf57400546eda653c5857b69b1b7f2aa1ff3174
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyury, jcristau
bugs1346010
milestone54.0a2
Bug 1346010: Properly render the name of func imports when there's at least one non-func import; r=yury a=jcristau MozReview-Commit-ID: JqMfC1KrgTY
js/src/jit-test/tests/wasm/full-cycle.js
js/src/wasm/WasmBinaryToAST.cpp
--- a/js/src/jit-test/tests/wasm/full-cycle.js
+++ b/js/src/jit-test/tests/wasm/full-cycle.js
@@ -14,16 +14,23 @@ wasmFullPass(`(module
         i32.const 0
         call 3
         i32.const 42
         i32.add
     )
     (func) (func) (func)
 (export "run" 0))`, 43);
 
+wasmFullPass(`
+(module
+  (import "env" "a" (global $a i32))
+  (import "env" "b" (func $b (param i32) (result i32)))
+  (func (export "run") (param $0 i32) (result i32) get_local 0 call $b)
+)`, 43, { env: { a: 1337, b: x => x+1 } }, 42);
+
 // Global section.
 wasmFullPass(`(module
  (import $imported "globals" "x" (global i32))
  (global $mut_local (mut i32) (i32.const 0))
  (global $imm_local i32 (i32.const 37))
  (global $imm_local_2 i32 (get_global 0))
  (func $get (result i32)
   i32.const 13
--- a/js/src/wasm/WasmBinaryToAST.cpp
+++ b/js/src/wasm/WasmBinaryToAST.cpp
@@ -297,18 +297,17 @@ AstDecodeCall(AstDecodeContext& c)
     if (!c.iter().readCall(&funcIndex, &unusedArgs))
         return false;
 
     if (c.iter().currentBlockHasPolymorphicBase())
         return true;
 
     AstRef funcRef;
     if (funcIndex < c.module().numFuncImports()) {
-        AstImport* import = c.module().imports()[funcIndex];
-        funcRef = AstRef(import->name());
+        funcRef = AstRef(c.module().funcImportNames()[funcIndex]);
     } else {
         if (!GenerateRef(c, AstName(u"func"), funcIndex, &funcRef))
             return false;
     }
 
     const SigWithId* sig = c.env().funcSigs[funcIndex];
 
     AstExprVector args(c.lifo);
@@ -1540,16 +1539,17 @@ AstCreateImports(AstDecodeContext& c)
     }
 
     for (size_t importIndex = 0; importIndex < c.env().imports.length(); importIndex++) {
         const Import& import = c.env().imports[importIndex];
 
         AstName moduleName;
         if (!ToAstName(c, import.module.get(), &moduleName))
             return false;
+
         AstName fieldName;
         if (!ToAstName(c, import.field.get(), &fieldName))
             return false;
 
         AstImport* ast = nullptr;
         switch (import.kind) {
           case DefinitionKind::Function: {
             AstName importName;