Bug 1346010: Properly render the name of func imports when there's at least one non-func import; r?yury
MozReview-Commit-ID: JqMfC1KrgTY
--- 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;