Reland "[wasm-simd][liftoff] Check CpuFeatures for SIMD support"

This relands commit 7c32fa05df.

Some test cases need to be updated, since we will bail out to TurboFan
where previously Liftoff was happy to run, when SIMD is not supported.

Original change's description:
> [wasm-simd][liftoff] Check CpuFeatures for SIMD support
>
> If Wasm simd128 is not supported on this particular hardware, we bail
> out to TurboFan.
>
> Bug: v8:9909
> Change-Id: Ie46e154426783ba099b7c0facc906670cda1bdd0
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2029427
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Commit-Queue: Zhi An Ng <zhin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#66055}

Bug: v8:9909
Bug: v8:10169
Change-Id: I850e1fe6bfbd12fb2eec052aa8367624c09f7a08
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030354
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66090}
This commit is contained in:
Ng Zhi An 2020-02-03 10:36:39 -08:00 committed by Commit Bot
parent bdac09e493
commit cccbd5f123
4 changed files with 11 additions and 8 deletions

View File

@ -357,6 +357,11 @@ class LiftoffCompiler {
bool CheckSupportedType(FullDecoder* decoder,
Vector<const ValueType> supported_types,
ValueType type, const char* context) {
// Special case for kWasm128 which requires specific hardware support.
if (type == kWasmS128 && (!CpuFeatures::SupportsWasmSimd128())) {
unsupported(decoder, kSimd, "simd");
return false;
}
// Check supported types.
for (ValueType supported : supported_types) {
if (type == supported) return true;
@ -2198,6 +2203,9 @@ class LiftoffCompiler {
void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
Value* result) {
if (!CpuFeatures::SupportsWasmSimd128()) {
return unsupported(decoder, kSimd, "simd");
}
switch (opcode) {
case wasm::kExprF32x4Splat:
EmitUnOp<kWasmF32, kWasmS128>(

View File

@ -32,7 +32,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Local) {
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_GET_LOCAL(temp1)), WASM_ONE);
CHECK_EQ(1, r.Call());
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
}
WASM_SIMD_LIFTOFF_TEST(S128Global) {
@ -47,7 +46,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Global) {
WriteLittleEndianValue<int32_t>(&g0[i], expected);
}
r.Call();
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
for (int i = 0; i < 4; i++) {
int32_t actual = ReadLittleEndianValue<int32_t>(&g1[i]);
CHECK_EQ(actual, expected);
@ -70,7 +68,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Param) {
WASM_CALL_FUNCTION(simd_func.function_index(), WASM_GET_LOCAL(temp1)));
CHECK_EQ(1, r.Call());
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
}
WASM_SIMD_LIFTOFF_TEST(S128Return) {
@ -85,7 +82,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Return) {
WASM_ONE);
CHECK_EQ(1, r.Call());
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
}
#undef WASM_SIMD_LIFTOFF_TEST

View File

@ -4,7 +4,8 @@
// Flags: --no-stress-opt --trace-wasm-memory --liftoff --no-future
// Flags: --no-wasm-tier-up --experimental-wasm-simd
// Flags: --enable-sse3 --enable-sse4-1
// liftoff does not support simd128, so the s128 load and store traces are in
// the turbofan tier and not liftoff
// Force enable sse3 and sse4-1, since that will determine which execution tier
// we use, and thus the expected output message will differ.
load("test/message/wasm-trace-memory.js");

View File

@ -3,8 +3,6 @@
// found in the LICENSE file.
// Flags: --experimental-wasm-simd
// Flags: --nowasm-tier-up
// TODO(v8/10169)
load('test/mjsunit/wasm/wasm-module-builder.js');