Skip to content

Commit

Permalink
fix small bug in wasm runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed May 28, 2018
1 parent 1f2584e commit 909a2ac
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/wasm/WasmMainTemplatePlugin.js
Expand Up @@ -96,7 +96,7 @@ function generateImportObject(module) {
).join(", ");
const variables = Array.from(
waitForInstances.keys(),
(name, i) => `${name} = array[${i}];`
(name, i) => `${name} = array[${i}]`
).join(", ");
return Template.asString([
`${JSON.stringify(module.id)}: function() {`,
Expand Down
6 changes: 6 additions & 0 deletions test/cases/wasm/imports-many-direct/index.js
@@ -0,0 +1,6 @@
it("should allow to run a WebAssembly module with many direct wasm dependencies", function() {
return import("./wasm.wat").then(function(wasm) {
const result = wasm.testI64();
expect(result).toEqual(42);
});
});
7 changes: 7 additions & 0 deletions test/cases/wasm/imports-many-direct/other1.wat
@@ -0,0 +1,7 @@
(module
(type $t0 (func (param i64) (result i64)))
(func $getI64 (type $t0) (param $p0 i64) (result i64)
get_local $p0
i64.const 20
i64.add)
(export "getI64" (func $getI64)))
7 changes: 7 additions & 0 deletions test/cases/wasm/imports-many-direct/other2.wat
@@ -0,0 +1,7 @@
(module
(type $t0 (func (param i64) (result i64)))
(func $getI64 (type $t0) (param $p0 i64) (result i64)
get_local $p0
i64.const 22
i64.add)
(export "getI64" (func $getI64)))
5 changes: 5 additions & 0 deletions test/cases/wasm/imports-many-direct/test.filter.js
@@ -0,0 +1,5 @@
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");

module.exports = function(config) {
return supportsWebAssembly();
};
13 changes: 13 additions & 0 deletions test/cases/wasm/imports-many-direct/wasm.wat
@@ -0,0 +1,13 @@
(module
(type $t0 (func (param i64) (result i64)))
(type $t1 (func (result i32)))
(import "./other1.wat" "getI64" (func $getI641 (type $t0)))
(import "./other2.wat" "getI64" (func $getI642 (type $t0)))
(func $testI64 (type $t1) (result i32)
i64.const 1152921504606846976
call $getI641
call $getI642
i64.const 1152921504606846976
i64.sub
i32.wrap/i64)
(export "testI64" (func $testI64)))

0 comments on commit 909a2ac

Please sign in to comment.