-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WASM] V128 should be throwable to match Chrome and the spec
https://bugs.webkit.org/show_bug.cgi?id=275383 rdar://106030051 Reviewed by Yusuke Suzuki. Adds support for v128 parameters in tags to BBQ and OMG tiers and the WASM/JS interface. * JSTests/wasm/stress/exception-containing-v128.js: Added. (async test): * JSTests/wasm/stress/import-exception-tag-with-v128.js: Added. (async test): * Source/JavaScriptCore/wasm/WasmBBQJIT.cpp: (JSC::Wasm::BBQJITImpl::BBQJIT::addThrow): * Source/JavaScriptCore/wasm/WasmBBQJIT32_64.cpp: (JSC::Wasm::BBQJITImpl::BBQJIT::emitCatchImpl): * Source/JavaScriptCore/wasm/WasmBBQJIT64.cpp: (JSC::Wasm::BBQJITImpl::BBQJIT::emitCatchImpl): * Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp: (JSC::Wasm::OMGIRGenerator::addCatchToUnreachable): (JSC::Wasm::OMGIRGenerator::addThrow): * Source/JavaScriptCore/wasm/WasmOMGIRGenerator32_64.cpp: (JSC::Wasm::OMGIRGenerator::addCatchToUnreachable): (JSC::Wasm::OMGIRGenerator::addThrow): * Source/JavaScriptCore/wasm/WasmOperations.cpp: (JSC::Wasm::JSC_DEFINE_NOEXCEPT_JIT_OPERATION): * Source/JavaScriptCore/wasm/WasmSlowPaths.cpp: (JSC::LLInt::WASM_SLOW_PATH_DECL): * Source/JavaScriptCore/wasm/WasmTag.h: * Source/JavaScriptCore/wasm/js/WebAssemblyTagConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/279989@main
- Loading branch information
Showing
17 changed files
with
252 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
//@ skip unless $isSIMDPlatform | ||
import { instantiate } from "../wabt-wrapper.js"; | ||
import * as assert from "../assert.js"; | ||
|
||
let wat = ` | ||
(module | ||
(tag $vtag (export "vtag") (param v128)) | ||
(func (export "testCatchOwnV128") (result i32) | ||
try (result i32) | ||
v128.const i32x4 0 0 42 0 | ||
throw $vtag | ||
catch $vtag | ||
i32x4.extract_lane 2 | ||
end | ||
) | ||
(func $innerFunc | ||
v128.const i32x4 0 42 0 0 | ||
throw $vtag | ||
) | ||
(func (export "testCatchCalleeV128") (result i32) | ||
try (result i32) | ||
call $innerFunc | ||
i32.const 0 | ||
catch $vtag | ||
i32x4.extract_lane 1 | ||
end | ||
) | ||
(tag $interleaved (param v128 i32 v128 f32 v128 i64 v128 f64 v128 f32 i64 v128 f64 i32 v128)) | ||
(func $throwsInterleaved | ||
v128.const i32x4 1 2 3 4 | ||
i32.const 43 | ||
v128.const i32x4 1 2 3 4 | ||
f32.const 43 | ||
v128.const i32x4 1 2 3 4 | ||
i64.const 43 | ||
v128.const i32x4 1 2 3 4 | ||
f64.const 43 | ||
v128.const i32x4 1 2 3 4 | ||
f32.const 43 | ||
i64.const 43 | ||
v128.const i32x4 1 2 3 4 | ||
f64.const 43 | ||
i32.const 43 | ||
v128.const i32x4 1 2 3 4 | ||
throw $interleaved | ||
) | ||
(func (export "testLotsOfInterleavedTypes") (result i32) (local v128 v128 v128 v128 v128 v128 v128) | ||
try (result i32) | ||
call $throwsInterleaved | ||
i32.const 0 | ||
catch $interleaved | ||
local.set 0 | ||
drop | ||
drop | ||
local.set 1 | ||
drop | ||
drop | ||
local.set 2 | ||
drop | ||
local.set 3 | ||
drop | ||
local.set 4 | ||
drop | ||
local.set 5 | ||
drop | ||
local.set 6 | ||
local.get 0 | ||
local.get 1 | ||
local.get 2 | ||
local.get 3 | ||
local.get 4 | ||
local.get 5 | ||
local.get 6 | ||
i32x4.add | ||
i32x4.add | ||
i32x4.add | ||
i32x4.add | ||
i32x4.add | ||
i32x4.add | ||
local.tee 0 | ||
i32x4.extract_lane 1 | ||
local.get 0 | ||
i32x4.extract_lane 3 | ||
i32.add | ||
end | ||
) | ||
(func (export "testThrowV128ToJS") | ||
v128.const i32x4 0 0 0 0 | ||
throw $vtag | ||
) | ||
) | ||
`; | ||
|
||
async function test() { | ||
const instance = await instantiate(wat, {}, { exceptions: true, simd: true }); | ||
assert.eq(instance.exports.testCatchOwnV128(), 42); | ||
assert.eq(instance.exports.testCatchCalleeV128(), 42); | ||
assert.eq(instance.exports.testLotsOfInterleavedTypes(), 42); | ||
assert.throws(() => instance.exports.testThrowV128ToJS(), WebAssembly.Exception); | ||
} | ||
|
||
await assert.asyncTest(test()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//@ skip unless $isSIMDPlatform | ||
import { instantiate } from "../wabt-wrapper.js"; | ||
import * as assert from "../assert.js"; | ||
|
||
let wat = ` | ||
(module | ||
(import "tags" "vtag" (tag $vtag (param v128))) | ||
(import "tags" "vvtag" (tag $vvtag (param v128 v128))) | ||
(import "tags" "vitag" (tag $vitag (param v128 i32))) | ||
(func (export "testThrowV128") (result i32) | ||
try (result i32) | ||
v128.const i32x4 0 0 42 0 | ||
throw $vtag | ||
catch $vtag | ||
i32x4.extract_lane 2 | ||
end | ||
) | ||
(func (export "testThrowV128Pair") (result i32) | ||
try (result i32) | ||
v128.const i32x4 0 21 42 0 | ||
v128.const i32x4 0 21 42 0 | ||
throw $vvtag | ||
catch $vvtag | ||
i32x4.add | ||
i32x4.extract_lane 1 | ||
end | ||
) | ||
(func (export "testThrowV128AndI32") (result i32) | ||
try (result i32) | ||
v128.const i32x4 1 2 3 4 | ||
i32.const 42 | ||
throw $vitag | ||
catch $vitag | ||
br 0 | ||
end | ||
) | ||
) | ||
`; | ||
|
||
async function test() { | ||
const vtag = new WebAssembly.Tag({ parameters: ["v128"] }); | ||
const vvtag = new WebAssembly.Tag({ parameters: ["v128", "v128"] }); | ||
const vitag = new WebAssembly.Tag({ parameters: ["v128", "i32"] }); | ||
const instance = await instantiate(wat, { tags: { | ||
vtag: vtag, | ||
vvtag: vvtag, | ||
vitag: vitag | ||
} }, { exceptions: true, simd: true }); | ||
assert.eq(instance.exports.testThrowV128(), 42); | ||
assert.eq(instance.exports.testThrowV128Pair(), 42); | ||
assert.eq(instance.exports.testThrowV128AndI32(), 42); | ||
} | ||
|
||
await assert.asyncTest(test()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.