Reland "[wasm] Improve test coverage of s128 exception handling."
This is a reland of 837556be7f
Original change's description:
> [wasm] Improve test coverage of s128 exception handling.
>
> This adds test coverage for the encoding and decoding of s128 values as
> part of an exception package. The encoding within an exception package
> is not specified (and not observable), but the full bit-pattern needs to
> survive an encoding/decoding round trip.
>
> R=clemensb@chromium.org
> TEST=mjsunit/wasm/exceptions-simd
> BUG=v8:8091
>
> Change-Id: I4cf6c1f00c64757512f66d068640a7e772eb0127
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1905769
> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#64932}
Bug: v8:8091,v8:9973
Change-Id: I7daf17a0cbc6904e7130ec4e50b12a829b1b1d34
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1916203
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64951}
This commit is contained in:
parent
a9ea67d4bb
commit
785eabadd2
@ -1392,6 +1392,15 @@ RUNTIME_FUNCTION(Runtime_IsLiftoffFunction) {
|
||||
return isolate->heap()->ToBoolean(code && code->is_liftoff());
|
||||
}
|
||||
|
||||
// TODO(9973): Replace this runtime function with a true feature testing
|
||||
// function in "wasm-module-builder.js" that can be used by "mjsunit" to
|
||||
// determine whether Simd128 is supported on the running architecture.
|
||||
RUNTIME_FUNCTION(Runtime_WasmSupportsSimd128) {
|
||||
SealHandleScope shs(isolate);
|
||||
DCHECK_EQ(0, args.length());
|
||||
return isolate->heap()->ToBoolean(CpuFeatures::SupportsWasmSimd128());
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_CompleteInobjectSlackTracking) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
|
@ -533,6 +533,7 @@ namespace internal {
|
||||
F(WasmGetNumberOfInstances, 1, 1) \
|
||||
F(WasmNumInterpretedCalls, 1, 1) \
|
||||
F(WasmNumCodeSpaces, 1, 1) \
|
||||
F(WasmSupportsSimd128, 0, 1) \
|
||||
F(WasmTierUpFunction, 2, 1) \
|
||||
F(WasmTraceMemory, 1, 1) \
|
||||
I(DeoptimizeNow, 0, 1)
|
||||
|
@ -8,6 +8,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
load("test/mjsunit/wasm/exceptions-utils.js");
|
||||
|
||||
(function TestThrowS128Default() {
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
var kSig_v_s = makeSig([kWasmS128], []);
|
||||
var except = builder.addException(kSig_v_s);
|
||||
@ -25,6 +26,8 @@ load("test/mjsunit/wasm/exceptions-utils.js");
|
||||
})();
|
||||
|
||||
(function TestThrowCatchS128Default() {
|
||||
if (!%WasmSupportsSimd128()) return;
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
var kSig_v_s = makeSig([kWasmS128], []);
|
||||
var except = builder.addException(kSig_v_s);
|
||||
@ -38,13 +41,46 @@ load("test/mjsunit/wasm/exceptions-utils.js");
|
||||
kExprBrOnExn, 0, except,
|
||||
kExprRethrow,
|
||||
kExprEnd,
|
||||
// TODO(mstarzinger): Actually return some compressed form of the s128
|
||||
// value here to make sure it is extracted properly from the exception.
|
||||
kExprDrop,
|
||||
kExprI32Const, 1,
|
||||
kExprLocalGet, 0,
|
||||
kSimdPrefix, kExprI32x4Eq,
|
||||
kSimdPrefix, kExprS1x4AllTrue,
|
||||
])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate();
|
||||
|
||||
assertEquals(1, instance.exports.throw_catch_simd());
|
||||
})();
|
||||
|
||||
(function TestThrowCatchS128WithValue() {
|
||||
if (!%WasmSupportsSimd128()) return;
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
var kSig_v_s = makeSig([kWasmS128], []);
|
||||
var except = builder.addException(kSig_v_s);
|
||||
const in_idx = 0x10; // Input index in memory.
|
||||
const out_idx = 0x20; // Output index in memory.
|
||||
builder.addImportedMemory("env", "memory");
|
||||
builder.addFunction("throw_catch_simd", kSig_v_v)
|
||||
.addBody([
|
||||
kExprI32Const, out_idx,
|
||||
kExprTry, kWasmS128,
|
||||
kExprI32Const, in_idx,
|
||||
kSimdPrefix, kExprS128LoadMem, 0, 0,
|
||||
kExprThrow, 0,
|
||||
kExprCatch,
|
||||
kExprBrOnExn, 0, except,
|
||||
kExprRethrow,
|
||||
kExprEnd,
|
||||
kSimdPrefix, kExprS128StoreMem, 0, 0,
|
||||
])
|
||||
.exportFunc();
|
||||
var memory = new WebAssembly.Memory({initial: 1});
|
||||
var instance = builder.instantiate({env: {memory:memory}});
|
||||
|
||||
var ref = [0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
|
||||
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0];
|
||||
var array = new Uint8Array(memory.buffer);
|
||||
array.set(ref, in_idx); // Store reference value in memory.
|
||||
instance.exports.throw_catch_simd();
|
||||
assertArrayEquals(ref, array.slice(out_idx, out_idx + 0x10));
|
||||
})();
|
||||
|
@ -468,6 +468,8 @@ let kExprI64AtomicCompareExchange32U = 0x4e;
|
||||
let kExprS128LoadMem = 0x00;
|
||||
let kExprS128StoreMem = 0x01;
|
||||
let kExprI32x4Splat = 0x0c;
|
||||
let kExprI32x4Eq = 0x2c;
|
||||
let kExprS1x4AllTrue = 0x75;
|
||||
let kExprF32x4Min = 0x9e;
|
||||
|
||||
// Compilation hint constants.
|
||||
|
Loading…
Reference in New Issue
Block a user