Skip to content

Commit

Permalink
Merge pull request #16339 from Liamolucko/wasm-i64
Browse files Browse the repository at this point in the history
Add `i64` to the set of JS-compatible wasm types in `syncWebAssembly` mode
  • Loading branch information
sokra committed Nov 9, 2022
2 parents 2403a36 + cb9248c commit f7f36ad
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/wasm-sync/WebAssemblyParser.js
Expand Up @@ -17,7 +17,7 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe
/** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */

const JS_COMPAT_TYPES = new Set(["i32", "f32", "f64"]);
const JS_COMPAT_TYPES = new Set(["i32", "i64", "f32", "f64"]);

/**
* @param {t.Signature} signature the func signature
Expand Down
2 changes: 1 addition & 1 deletion test/cases/wasm/imports-complex-types/index.js
@@ -1,6 +1,6 @@
it("should allow to run a WebAssembly module with non-js-compatible imports", function() {
return import("./wasm.wasm").then(function(wasm) {
const result = wasm.testI64();
const result = wasm.testV128();
expect(result).toEqual(42);
});
});
Binary file modified test/cases/wasm/imports-complex-types/other.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions test/cases/wasm/imports-complex-types/test.filter.js
@@ -1,5 +1,5 @@
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
const supports = require("webassembly-feature");

module.exports = function(config) {
return supportsWebAssembly();
return supports["simd"]();
};
Binary file modified test/cases/wasm/imports-complex-types/wasm.wasm
Binary file not shown.
9 changes: 9 additions & 0 deletions test/configCases/wasm/bigints/index.js
@@ -0,0 +1,9 @@
it("should allow converting i64s to JS bigints", async () => {
const { getI64 } = await import("./wasm.wat");
expect(getI64()).toEqual(42n);
});

it("should allow converting JS bigints to i64s", async () => {
const { takeI64 } = await import("./wasm.wat");
takeI64(42n);
})
5 changes: 5 additions & 0 deletions test/configCases/wasm/bigints/test.filter.js
@@ -0,0 +1,5 @@
const supports = require("webassembly-feature");

module.exports = function(config) {
return supports["JS-BigInt-integration"]();
};
4 changes: 4 additions & 0 deletions test/configCases/wasm/bigints/wasm.wat
@@ -0,0 +1,4 @@
(module
(func (export "getI64") (result i64)
i64.const 42)
(func (export "takeI64") (param i64)))
16 changes: 16 additions & 0 deletions test/configCases/wasm/bigints/webpack.config.js
@@ -0,0 +1,16 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: "./index",
module: {
rules: [
{
test: /\.wat$/,
loader: "wast-loader",
type: "webassembly/sync"
}
]
},
experiments: {
syncWebAssembly: true
}
};

0 comments on commit f7f36ad

Please sign in to comment.