Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i64 to the set of JS-compatible wasm types in syncWebAssembly mode #16339

Merged
merged 2 commits into from Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}
};