Skip to content

Commit 46f2a0e

Browse files
takikawawebkit-commit-queue
authored andcommitted
[Wasm] Unify memory import handling in module loader and JS cases
https://bugs.webkit.org/show_bug.cgi?id=234116 Patch by Asumu Takikawa <asumu@igalia.com> on 2022-01-11 Reviewed by Yusuke Suzuki. JSTests: Add an instantiation test case that tests that instantiating the same binary module twice will not crash. * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async test): (assert.asyncTest): LayoutTests/imported/w3c: Adjust Wasm WPT test expectations now that getter ordering tests should pass. * web-platform-tests/wasm/jsapi/constructor/instantiate.any-expected.txt: * web-platform-tests/wasm/jsapi/constructor/instantiate.any.worker-expected.txt: * web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt: * web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt: * web-platform-tests/wasm/webapi/instantiateStreaming.any-expected.txt: * web-platform-tests/wasm/webapi/instantiateStreaming.any.worker-expected.txt: Source/JavaScriptCore: Moves the memory import handling code to the Wasm module record and use the strategy used by the module loader to handle memory in all cases. * wasm/WasmModule.cpp: (JSC::Wasm::Module::copyInitialCalleeGroupToAllMemoryModes): * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::finalizeCreation): (JSC::JSWebAssemblyInstance::tryCreate): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::initializeImportsAndExports): Canonical link: https://commits.webkit.org/245938@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9f91d1b commit 46f2a0e

13 files changed

Lines changed: 110 additions & 133 deletions

‎JSTests/ChangeLog‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2022-01-11 Asumu Takikawa <asumu@igalia.com>
2+
3+
[Wasm] Unify memory import handling in module loader and JS cases
4+
https://bugs.webkit.org/show_bug.cgi?id=234116
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
Add an instantiation test case that tests that instantiating the same
9+
binary module twice will not crash.
10+
11+
* wasm/js-api/web-assembly-instantiate.js:
12+
(assert.asyncTest.async test):
13+
(assert.asyncTest):
14+
115
2022-01-10 Yusuke Suzuki <ysuzuki@apple.com>
216

317
Unreviewed, add a bit more Intl.Locale hourCycle tests to investigate flakiness

‎JSTests/wasm/js-api/web-assembly-instantiate.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,30 @@ assert.eq(WebAssembly.instantiate.length, 1);
190190

191191
assert.asyncTest(test());
192192
}
193+
194+
{
195+
const builder = (new Builder())
196+
.Type().End()
197+
.Import().Memory("imp", "memory", {initial:100}).End()
198+
.Function().End()
199+
.Export()
200+
.Function("foo")
201+
.End()
202+
.Code()
203+
.Function("foo", { params: [], ret: "i32" })
204+
.I32Const(1)
205+
.End()
206+
.End();
207+
208+
const bin = builder.WebAssembly().get();
209+
210+
async function test() {
211+
let module = new WebAssembly.Module(bin);
212+
let instance1 = await WebAssembly.instantiate(module, { imp: { memory: new WebAssembly.Memory({ initial: 100 }) } });
213+
assert.truthy(instance1 instanceof WebAssembly.Instance);
214+
let instance2 = await WebAssembly.instantiate(module, { imp: { memory: new WebAssembly.Memory({ initial: 100 }) } });
215+
assert.truthy(instance2 instanceof WebAssembly.Instance);
216+
}
217+
218+
assert.asyncTest(test());
219+
}

‎LayoutTests/imported/w3c/ChangeLog‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2022-01-11 Asumu Takikawa <asumu@igalia.com>
2+
3+
[Wasm] Unify memory import handling in module loader and JS cases
4+
https://bugs.webkit.org/show_bug.cgi?id=234116
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
Adjust Wasm WPT test expectations now that getter ordering tests
9+
should pass.
10+
11+
* web-platform-tests/wasm/jsapi/constructor/instantiate.any-expected.txt:
12+
* web-platform-tests/wasm/jsapi/constructor/instantiate.any.worker-expected.txt:
13+
* web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt:
14+
* web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt:
15+
* web-platform-tests/wasm/webapi/instantiateStreaming.any-expected.txt:
16+
* web-platform-tests/wasm/webapi/instantiateStreaming.any.worker-expected.txt:
17+
118
2022-01-11 Antoine Quint <graouts@webkit.org>
219

320
css/css-transitions/KeyframeEffect-setKeyframes.tentative.html is a failure (part 2)

‎LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate.any-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ PASS Empty module with undefined imports argument: BufferSource argument
99
PASS Empty module with undefined imports argument: Module argument
1010
PASS Empty module with empty imports argument: BufferSource argument
1111
PASS Empty module with empty imports argument: Module argument
12-
FAIL getter order for imports object: BufferSource argument assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
13-
FAIL getter order for imports object: Module argument assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
12+
PASS getter order for imports object: BufferSource argument
13+
PASS getter order for imports object: Module argument
1414
PASS imports: BufferSource argument
1515
PASS imports: Module argument
1616
PASS imports with empty module names: BufferSource argument

‎LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate.any.worker-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ PASS Empty module with undefined imports argument: BufferSource argument
99
PASS Empty module with undefined imports argument: Module argument
1010
PASS Empty module with empty imports argument: BufferSource argument
1111
PASS Empty module with empty imports argument: Module argument
12-
FAIL getter order for imports object: BufferSource argument assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
13-
FAIL getter order for imports object: Module argument assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
12+
PASS getter order for imports object: BufferSource argument
13+
PASS getter order for imports object: Module argument
1414
PASS imports: BufferSource argument
1515
PASS imports: Module argument
1616
PASS imports with empty module names: BufferSource argument

‎LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PASS Calling
77
PASS Empty module without imports argument
88
PASS Empty module with undefined imports argument
99
PASS Empty module with empty imports argument
10-
FAIL getter order for imports object assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
10+
PASS getter order for imports object
1111
PASS imports
1212
PASS imports with empty module names
1313
PASS imports with empty names

‎LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PASS Calling
77
PASS Empty module without imports argument
88
PASS Empty module with undefined imports argument
99
PASS Empty module with empty imports argument
10-
FAIL getter order for imports object assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
10+
PASS getter order for imports object
1111
PASS imports
1212
PASS imports with empty module names
1313
PASS imports with empty names

‎LayoutTests/imported/w3c/web-platform-tests/wasm/webapi/instantiateStreaming.any-expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PASS Empty module without imports argument
33
PASS Empty module with undefined imports argument
44
PASS Empty module with empty imports argument
5-
FAIL getter order for imports object assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
5+
PASS getter order for imports object
66
PASS imports
77
PASS imports with empty module names
88
PASS imports with empty names

‎LayoutTests/imported/w3c/web-platform-tests/wasm/webapi/instantiateStreaming.any.worker-expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PASS Empty module without imports argument
33
PASS Empty module with undefined imports argument
44
PASS Empty module with empty imports argument
5-
FAIL getter order for imports object assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"])
5+
PASS getter order for imports object
66
PASS imports
77
PASS imports with empty module names
88
PASS imports with empty names

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2022-01-11 Asumu Takikawa <asumu@igalia.com>
2+
3+
[Wasm] Unify memory import handling in module loader and JS cases
4+
https://bugs.webkit.org/show_bug.cgi?id=234116
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
Moves the memory import handling code to the Wasm module record and
9+
use the strategy used by the module loader to handle memory in all
10+
cases.
11+
12+
* wasm/WasmModule.cpp:
13+
(JSC::Wasm::Module::copyInitialCalleeGroupToAllMemoryModes):
14+
* wasm/js/JSWebAssemblyInstance.cpp:
15+
(JSC::JSWebAssemblyInstance::finalizeCreation):
16+
(JSC::JSWebAssemblyInstance::tryCreate):
17+
* wasm/js/WebAssemblyModuleRecord.cpp:
18+
(JSC::WebAssemblyModuleRecord::initializeImportsAndExports):
19+
120
2022-01-11 Yusuke Suzuki <ysuzuki@apple.com>
221

322
[JSC] Fix kind of error thrown by wasm module creation

0 commit comments

Comments
 (0)