Merge pull request #16339 from Liamolucko/wasm-i64

Add `i64` to the set of JS-compatible wasm types in `syncWebAssembly` mode
This commit is contained in:
Tobias Koppers 2022-11-09 13:07:40 +01:00 committed by GitHub
commit f7f36ad412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 4 deletions

View File

@ -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

View File

@ -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);
});
});

View File

@ -1,5 +1,5 @@
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
const supports = require("webassembly-feature");
module.exports = function(config) {
return supportsWebAssembly();
return supports["simd"]();
};

View File

@ -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);
})

View File

@ -0,0 +1,5 @@
const supports = require("webassembly-feature");
module.exports = function(config) {
return supports["JS-BigInt-integration"]();
};

View File

@ -0,0 +1,4 @@
(module
(func (export "getI64") (result i64)
i64.const 42)
(func (export "takeI64") (param i64)))

View File

@ -0,0 +1,16 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: "./index",
module: {
rules: [
{
test: /\.wat$/,
loader: "wast-loader",
type: "webassembly/sync"
}
]
},
experiments: {
syncWebAssembly: true
}
};