Commit cccbd5f1 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

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

This relands commit 7c32fa05.

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: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66090}
parent bdac09e4
...@@ -357,6 +357,11 @@ class LiftoffCompiler { ...@@ -357,6 +357,11 @@ class LiftoffCompiler {
bool CheckSupportedType(FullDecoder* decoder, bool CheckSupportedType(FullDecoder* decoder,
Vector<const ValueType> supported_types, Vector<const ValueType> supported_types,
ValueType type, const char* context) { 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. // Check supported types.
for (ValueType supported : supported_types) { for (ValueType supported : supported_types) {
if (type == supported) return true; if (type == supported) return true;
...@@ -2198,6 +2203,9 @@ class LiftoffCompiler { ...@@ -2198,6 +2203,9 @@ class LiftoffCompiler {
void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args, void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
Value* result) { Value* result) {
if (!CpuFeatures::SupportsWasmSimd128()) {
return unsupported(decoder, kSimd, "simd");
}
switch (opcode) { switch (opcode) {
case wasm::kExprF32x4Splat: case wasm::kExprF32x4Splat:
EmitUnOp<kWasmF32, kWasmS128>( EmitUnOp<kWasmF32, kWasmS128>(
......
...@@ -32,7 +32,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Local) { ...@@ -32,7 +32,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Local) {
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_GET_LOCAL(temp1)), WASM_ONE); BUILD(r, WASM_SET_LOCAL(temp1, WASM_GET_LOCAL(temp1)), WASM_ONE);
CHECK_EQ(1, r.Call()); CHECK_EQ(1, r.Call());
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
} }
WASM_SIMD_LIFTOFF_TEST(S128Global) { WASM_SIMD_LIFTOFF_TEST(S128Global) {
...@@ -47,7 +46,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Global) { ...@@ -47,7 +46,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Global) {
WriteLittleEndianValue<int32_t>(&g0[i], expected); WriteLittleEndianValue<int32_t>(&g0[i], expected);
} }
r.Call(); r.Call();
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int32_t actual = ReadLittleEndianValue<int32_t>(&g1[i]); int32_t actual = ReadLittleEndianValue<int32_t>(&g1[i]);
CHECK_EQ(actual, expected); CHECK_EQ(actual, expected);
...@@ -70,7 +68,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Param) { ...@@ -70,7 +68,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Param) {
WASM_CALL_FUNCTION(simd_func.function_index(), WASM_GET_LOCAL(temp1))); WASM_CALL_FUNCTION(simd_func.function_index(), WASM_GET_LOCAL(temp1)));
CHECK_EQ(1, r.Call()); CHECK_EQ(1, r.Call());
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
} }
WASM_SIMD_LIFTOFF_TEST(S128Return) { WASM_SIMD_LIFTOFF_TEST(S128Return) {
...@@ -85,7 +82,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Return) { ...@@ -85,7 +82,6 @@ WASM_SIMD_LIFTOFF_TEST(S128Return) {
WASM_ONE); WASM_ONE);
CHECK_EQ(1, r.Call()); CHECK_EQ(1, r.Call());
r.CheckUsedExecutionTier(ExecutionTier::kLiftoff);
} }
#undef WASM_SIMD_LIFTOFF_TEST #undef WASM_SIMD_LIFTOFF_TEST
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
// Flags: --no-stress-opt --trace-wasm-memory --liftoff --no-future // Flags: --no-stress-opt --trace-wasm-memory --liftoff --no-future
// Flags: --no-wasm-tier-up --experimental-wasm-simd // 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 // Force enable sse3 and sse4-1, since that will determine which execution tier
// the turbofan tier and not liftoff // we use, and thus the expected output message will differ.
load("test/message/wasm-trace-memory.js"); load("test/message/wasm-trace-memory.js");
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --experimental-wasm-simd // Flags: --experimental-wasm-simd
// Flags: --nowasm-tier-up
// TODO(v8/10169)
load('test/mjsunit/wasm/wasm-module-builder.js'); load('test/mjsunit/wasm/wasm-module-builder.js');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment