10000 Merge pull request #16339 from Liamolucko/wasm-i64 · webpack/webpack@f7f36ad · GitHub
[go: up one dir, main page]

Skip to content

Commit f7f36ad

Browse files
authored
Merge pull request #16339 from Liamolucko/wasm-i64
Add `i64` to the set of JS-compatible wasm types in `syncWebAssembly` mode
2 parents 2403a36 + cb9248c commit f7f36ad

File tree

9 files changed

+38
-4
lines changed

9 files changed

+38
-4
lines changed

lib/wasm-sync/WebAssemblyParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe
1717
/** @typedef {import("../Parser").ParserState} ParserState */
1818
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
1919

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

2222
/**
2323
* @param {t.Signature} signature the func signature
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
it("should allow to run a WebAssembly module with non-js-compatible imports", function() {
22
return import("./wasm.wasm").then(function(wasm) {
3-
const result = wasm.testI64();
3+
const result = wasm.testV128();
44
expect(result).toEqual(42);
55
});
66
});
-20 Bytes
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
1+
const supports = require("webassembly-feature");
22

33
module.exports = function(config) {
4-
return supportsWebAssembly();
4+
return supports["simd"]();
55
};
-29 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
it("should allow converting i64s to JS bigints", async () => {
2+
const { getI64 } = await import("./wasm.wat");
3+
expect(getI64()).toEqual(42n);
4+
});
5+
6+
it("should allow converting JS bigints to i64s", async () => {
7+
const { takeI64 } = await import("./wasm.wat");
8+
takeI64(42n);
9+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const supports = require("webassembly-feature");
2+
3+
module.exports = function(config) {
4+
return supports["JS-BigInt-integration"]();
5+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(module
2+
(func (export "getI64") (result i64)
3+
i64.const 42)
4+
(func (export "takeI64") (param i64)))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @type {import("../../../../").Configuration} */
2+
module.exports = {
3+
entry: "./index",
4+
module: {
5+
rules: [
6+
{
7+
test: /\.wat$/,
8+
loader: "wast-loader",
9+
type: "webassembly/sync"
10+
}
11+
]
12+
},
13+
experiments: {
14+
syncWebAssembly: true
15+
}
16+
};

0 commit comments

Comments
 (0)
0