Commit 45618a9a authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Make prototype flags experimental

Most prototype implementations are not fully supported in the
interpreter. This is the case at least for exception handling, simd, and
atomics. Any function can be redirected to the interpreter though,
either by passing --wasm-interpret-all, or by dynamically redirecting to
the interpreter for debugging.
Making the flags experimental keeps the fuzzer from playing around with
these flags.

Drive-by: Refactor tests which explicitly set the prototype flag to use
a new scope for that.

R=ahaas@chromium.org
BUG=chromium:727584

Change-Id: I67da79f579f1ac93c67189afef40c6524bdd4430
Reviewed-on: https://chromium-review.googlesource.com/519402
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45639}
parent b21bc232
......@@ -576,13 +576,13 @@ DEFINE_STRING(dump_wasm_module_path, NULL, "directory to dump wasm modules to")
DEFINE_INT(typed_array_max_size_in_heap, 64,
"threshold for in-heap typed array")
DEFINE_BOOL(wasm_simd_prototype, false,
DEFINE_BOOL(experimental_wasm_simd, false,
"enable prototype simd opcodes for wasm")
DEFINE_BOOL(wasm_eh_prototype, false,
DEFINE_BOOL(experimental_wasm_eh, false,
"enable prototype exception handling opcodes for wasm")
DEFINE_BOOL(wasm_mv_prototype, false,
DEFINE_BOOL(experimental_wasm_mv, false,
"enable prototype multi-value support for wasm")
DEFINE_BOOL(wasm_atomics_prototype, false,
DEFINE_BOOL(experimental_wasm_atomics, false,
"enable prototype atomic opcodes for wasm")
DEFINE_BOOL(wasm_opt, true, "enable wasm optimization")
......
......@@ -1222,7 +1222,8 @@ Object* Isolate::UnwindAndFindHandler() {
trap_handler::ClearThreadInWasm();
}
if (!FLAG_wasm_eh_prototype || !is_catchable_by_wasm(exception)) break;
if (!FLAG_experimental_wasm_eh || !is_catchable_by_wasm(exception))
break;
int stack_slots = 0; // Will contain stack slot count of frame.
WasmCompiledFrame* wasm_frame = static_cast<WasmCompiledFrame*>(frame);
int offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots);
......
......@@ -100,7 +100,7 @@ struct BlockTypeOperand {
types = pc + 1;
} else {
// Handle multi-value blocks.
if (!CHECKED_COND(FLAG_wasm_mv_prototype)) {
if (!CHECKED_COND(FLAG_experimental_wasm_mv)) {
decoder->error(pc + 1, "invalid block arity > 1");
return;
}
......
......@@ -39,8 +39,8 @@ namespace wasm {
if (module_ != nullptr && module_->is_asm_js()) { \
error("Opcode not supported for asmjs modules"); \
} \
if (!FLAG_##flag) { \
error("Invalid opcode (enable with --" #flag ")"); \
if (!FLAG_experimental_wasm_##flag) { \
error("Invalid opcode (enable with --experimental-wasm-" #flag ")"); \
break; \
}
......@@ -599,7 +599,8 @@ class WasmDecoder : public Decoder {
case kExprUnreachable:
return {0, 0};
default:
V8_Fatal(__FILE__, __LINE__, "unimplemented opcode: %x", opcode);
V8_Fatal(__FILE__, __LINE__, "unimplemented opcode: %x (%s)", opcode,
WasmOpcodes::OpcodeName(opcode));
return {0, 0};
}
#undef DECLARE_OPCODE_CASE
......@@ -843,7 +844,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprThrow: {
CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
CHECK_PROTOTYPE_OPCODE(eh);
Value value = Pop(0, kWasmI32);
BUILD(Throw, value.node);
// TODO(titzer): Throw should end control, but currently we build a
......@@ -853,7 +854,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprTry: {
CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
CHECK_PROTOTYPE_OPCODE(eh);
BlockTypeOperand<true> operand(this, pc_);
SsaEnv* outer_env = ssa_env_;
SsaEnv* try_env = Steal(outer_env);
......@@ -865,7 +866,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprCatch: {
CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
CHECK_PROTOTYPE_OPCODE(eh);
LocalIndexOperand<true> operand(this, pc_);
len = 1 + operand.length;
......@@ -1262,7 +1263,7 @@ class WasmFullDecoder : public WasmDecoder {
len = DecodeLoadMem(kWasmF64, MachineType::Float64());
break;
case kExprS128LoadMem:
CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
CHECK_PROTOTYPE_OPCODE(simd);
len = DecodeLoadMem(kWasmS128, MachineType::Simd128());
break;
case kExprI32StoreMem8:
......@@ -1293,7 +1294,7 @@ class WasmFullDecoder : public WasmDecoder {
len = DecodeStoreMem(kWasmF64, MachineType::Float64());
break;
case kExprS128StoreMem:
CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
CHECK_PROTOTYPE_OPCODE(simd);
len = DecodeStoreMem(kWasmS128, MachineType::Simd128());
break;
case kExprGrowMemory: {
......@@ -1341,7 +1342,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kSimdPrefix: {
CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
CHECK_PROTOTYPE_OPCODE(simd);
len++;
byte simd_index = read_u8<true>(pc_ + 1, "simd index");
opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
......@@ -1355,10 +1356,7 @@ class WasmFullDecoder : public WasmDecoder {
error("Atomics are allowed only in AsmJs modules");
break;
}
if (!FLAG_wasm_atomics_prototype) {
error("Invalid opcode (enable with --wasm_atomics_prototype)");
break;
}
CHECK_PROTOTYPE_OPCODE(atomics);
len = 2;
byte atomic_opcode = read_u8<true>(pc_ + 1, "atomic index");
opcode = static_cast<WasmOpcode>(opcode << 8 | atomic_opcode);
......
......@@ -1163,7 +1163,7 @@ class ModuleDecoder : public Decoder {
case kLocalF64:
return kWasmF64;
default:
if (origin_ != kAsmJsOrigin && FLAG_wasm_simd_prototype) {
if (origin_ != kAsmJsOrigin && FLAG_experimental_wasm_simd) {
switch (t) {
case kLocalS128:
return kWasmS128;
......@@ -1196,7 +1196,7 @@ class ModuleDecoder : public Decoder {
}
// parse return types
const size_t max_return_count = FLAG_wasm_mv_prototype
const size_t max_return_count = FLAG_experimental_wasm_mv
? kV8MaxWasmFunctionMultiReturns
: kV8MaxWasmFunctionReturns;
uint32_t return_count = consume_count("return count", max_return_count);
......
......@@ -11,8 +11,9 @@ v8_executable("cctest") {
"$target_gen_dir/resources.cc",
### gcmole(all) ###
"../common/wasm/test-signatures.h",
"../common/wasm/wasm-macro-gen.h",
"../../test/common/wasm/flag-utils.h",
"../../test/common/wasm/test-signatures.h",
"../../test/common/wasm/wasm-macro-gen.h",
"ast-types-fuzz.h",
"cctest.cc",
"cctest.h",
......
......@@ -336,6 +336,7 @@
'../..',
],
'sources': [
'../common/wasm/flag-utils.h',
'../common/wasm/test-signatures.h',
'../common/wasm/wasm-macro-gen.h',
'../common/wasm/wasm-module-runner.cc',
......
......@@ -38,6 +38,14 @@ typedef int8_t (*Int8ShiftOp)(int8_t, int);
#define SIMD_LOWERING_TARGET 0
#endif
#define WASM_SIMD_TEST(name) \
void RunWasm_##name##_Impl(); \
TEST(RunWasm_##name) { \
EXPERIMENTAL_FLAG_SCOPE(simd); \
RunWasm_##name##_Impl(); \
} \
void RunWasm_##name##_Impl()
// Generic expected value functions.
template <typename T>
T Negate(T a) {
......@@ -423,9 +431,7 @@ bool SkipFPExpectedValue(float x) { return std::isnan(x) || SkipFPValue(x); }
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(F32x4Splat) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(F32x4Splat) {
WasmRunner<int32_t, float> r(kExecuteCompiled);
byte lane_val = 0;
byte simd = r.AllocateLocal(kWasmS128);
......@@ -439,8 +445,7 @@ WASM_EXEC_COMPILED_TEST(F32x4Splat) {
}
}
WASM_EXEC_COMPILED_TEST(F32x4ReplaceLane) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(F32x4ReplaceLane) {
WasmRunner<int32_t, float, float> r(kExecuteCompiled);
byte old_val = 0;
byte new_val = 1;
......@@ -467,8 +472,7 @@ WASM_EXEC_COMPILED_TEST(F32x4ReplaceLane) {
}
// Tests both signed and unsigned conversion.
WASM_EXEC_COMPILED_TEST(F32x4ConvertI32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(F32x4ConvertI32x4) {
WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled);
byte a = 0;
byte expected_signed = 1;
......@@ -497,7 +501,6 @@ WASM_EXEC_COMPILED_TEST(F32x4ConvertI32x4) {
V8_TARGET_ARCH_MIPS64
void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op,
float error = 0.0f) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, float, float, float> r(kExecuteCompiled);
byte a = 0;
byte low = 1;
......@@ -517,19 +520,19 @@ void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op,
}
}
WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); }
WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); }
WASM_SIMD_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); }
WASM_SIMD_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); }
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
// V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
static const float kApproxError = 0.01f;
WASM_EXEC_COMPILED_TEST(F32x4RecipApprox) {
WASM_SIMD_TEST(F32x4RecipApprox) {
RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError);
}
WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) {
WASM_SIMD_TEST(F32x4RecipSqrtApprox) {
RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError);
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
......@@ -537,7 +540,6 @@ WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) {
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, float, float, float> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -561,22 +563,17 @@ void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); }
WASM_EXEC_COMPILED_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); }
WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); }
WASM_EXEC_COMPILED_TEST(F32x4_Min) {
RunF32x4BinOpTest(kExprF32x4Min, Minimum);
}
WASM_EXEC_COMPILED_TEST(F32x4_Max) {
RunF32x4BinOpTest(kExprF32x4Max, Maximum);
}
WASM_SIMD_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); }
WASM_SIMD_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); }
WASM_SIMD_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); }
WASM_SIMD_TEST(F32x4_Min) { RunF32x4BinOpTest(kExprF32x4Min, Minimum); }
WASM_SIMD_TEST(F32x4_Max) { RunF32x4BinOpTest(kExprF32x4Max, Maximum); }
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
// V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -602,31 +599,21 @@ void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(F32x4Eq) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); }
WASM_SIMD_TEST(F32x4Eq) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); }
WASM_EXEC_COMPILED_TEST(F32x4Ne) {
RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual);
}
WASM_SIMD_TEST(F32x4Ne) { RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); }
WASM_EXEC_COMPILED_TEST(F32x4Gt) {
RunF32x4CompareOpTest(kExprF32x4Gt, Greater);
}
WASM_SIMD_TEST(F32x4Gt) { RunF32x4CompareOpTest(kExprF32x4Gt, Greater); }
WASM_EXEC_COMPILED_TEST(F32x4Ge) {
RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual);
}
WASM_SIMD_TEST(F32x4Ge) { RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual); }
WASM_EXEC_COMPILED_TEST(F32x4Lt) { RunF32x4CompareOpTest(kExprF32x4Lt, Less); }
WASM_SIMD_TEST(F32x4Lt) { RunF32x4CompareOpTest(kExprF32x4Lt, Less); }
WASM_EXEC_COMPILED_TEST(F32x4Le) {
RunF32x4CompareOpTest(kExprF32x4Le, LessEqual);
}
WASM_SIMD_TEST(F32x4Le) { RunF32x4CompareOpTest(kExprF32x4Le, LessEqual); }
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
// V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I32x4Splat) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I32x4Splat) {
// Store SIMD value in a local variable, use extract lane to check lane values
// This test is not a test for ExtractLane as Splat does not create
// interesting SIMD values.
......@@ -647,8 +634,7 @@ WASM_EXEC_COMPILED_TEST(I32x4Splat) {
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
}
WASM_EXEC_COMPILED_TEST(I32x4ReplaceLane) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I32x4ReplaceLane) {
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte old_val = 0;
byte new_val = 1;
......@@ -676,9 +662,7 @@ WASM_EXEC_COMPILED_TEST(I32x4ReplaceLane) {
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I16x8Splat) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I16x8Splat) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
byte lane_val = 0;
byte simd = r.AllocateLocal(kWasmS128);
......@@ -689,8 +673,7 @@ WASM_EXEC_COMPILED_TEST(I16x8Splat) {
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
}
WASM_EXEC_COMPILED_TEST(I16x8ReplaceLane) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I16x8ReplaceLane) {
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte old_val = 0;
byte new_val = 1;
......@@ -743,9 +726,7 @@ WASM_EXEC_COMPILED_TEST(I16x8ReplaceLane) {
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64 || SIMD_LOWERING_TARGET
WASM_EXEC_COMPILED_TEST(I8x16Splat) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I8x16Splat) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
byte lane_val = 0;
byte simd = r.AllocateLocal(kWasmS128);
......@@ -756,8 +737,7 @@ WASM_EXEC_COMPILED_TEST(I8x16Splat) {
FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
}
WASM_EXEC_COMPILED_TEST(I8x16ReplaceLane) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I8x16ReplaceLane) {
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte old_val = 0;
byte new_val = 1;
......@@ -906,8 +886,7 @@ int32_t ConvertToInt(double val, bool unsigned_integer) {
}
// Tests both signed and unsigned conversion.
WASM_EXEC_COMPILED_TEST(I32x4ConvertF32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I32x4ConvertF32x4) {
WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected_signed = 1;
......@@ -935,8 +914,7 @@ WASM_EXEC_COMPILED_TEST(I32x4ConvertF32x4) {
#if V8_TARGET_ARCH_ARM
// Tests both signed and unsigned conversion from I16x8 (unpacking).
WASM_EXEC_COMPILED_TEST(I32x4ConvertI16x8) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I32x4ConvertI16x8) {
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte unpacked_signed = 1;
......@@ -963,7 +941,6 @@ WASM_EXEC_COMPILED_TEST(I32x4ConvertI16x8) {
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
......@@ -975,16 +952,15 @@ void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) {
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
}
WASM_EXEC_COMPILED_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); }
WASM_SIMD_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); }
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
// V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
WASM_EXEC_COMPILED_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); }
WASM_SIMD_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); }
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -1002,38 +978,33 @@ void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); }
WASM_SIMD_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); }
WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); }
WASM_SIMD_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); }
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); }
WASM_SIMD_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); }
WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
WASM_SIMD_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
WASM_SIMD_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
WASM_SIMD_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
WASM_EXEC_COMPILED_TEST(I32x4Min) {
RunI32x4BinOpTest(kExprI32x4MinS, Minimum);
}
WASM_SIMD_TEST(I32x4Min) { RunI32x4BinOpTest(kExprI32x4MinS, Minimum); }
WASM_EXEC_COMPILED_TEST(I32x4MaxS) {
RunI32x4BinOpTest(kExprI32x4MaxS, Maximum);
}
WASM_SIMD_TEST(I32x4MaxS) { RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); }
WASM_EXEC_COMPILED_TEST(I32x4MinU) {
WASM_SIMD_TEST(I32x4MinU) {
RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum);
}
WASM_EXEC_COMPILED_TEST(I32x4MaxU) {
WASM_SIMD_TEST(I32x4MaxU) {
RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum);
}
void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -1053,45 +1024,33 @@ void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); }
WASM_SIMD_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); }
WASM_EXEC_COMPILED_TEST(I32x4Ne) {
RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual);
}
WASM_SIMD_TEST(I32x4Ne) { RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); }
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
// V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I32x4LtS) {
RunI32x4CompareOpTest(kExprI32x4LtS, Less);
}
WASM_SIMD_TEST(I32x4LtS) { RunI32x4CompareOpTest(kExprI32x4LtS, Less); }
WASM_EXEC_COMPILED_TEST(I32x4LeS) {
RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual);
}
WASM_SIMD_TEST(I32x4LeS) { RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); }
WASM_EXEC_COMPILED_TEST(I32x4GtS) {
RunI32x4CompareOpTest(kExprI32x4GtS, Greater);
}
WASM_SIMD_TEST(I32x4GtS) { RunI32x4CompareOpTest(kExprI32x4GtS, Greater); }
WASM_EXEC_COMPILED_TEST(I32x4GeS) {
RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual);
}
WASM_SIMD_TEST(I32x4GeS) { RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual); }
WASM_EXEC_COMPILED_TEST(I32x4LtU) {
RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess);
}
WASM_SIMD_TEST(I32x4LtU) { RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); }
WASM_EXEC_COMPILED_TEST(I32x4LeU) {
WASM_SIMD_TEST(I32x4LeU) {
RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual);
}
WASM_EXEC_COMPILED_TEST(I32x4GtU) {
WASM_SIMD_TEST(I32x4GtU) {
RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater);
}
WASM_EXEC_COMPILED_TEST(I32x4GeU) {
WASM_SIMD_TEST(I32x4GeU) {
RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual);
}
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
......@@ -1101,7 +1060,6 @@ WASM_EXEC_COMPILED_TEST(I32x4GeU) {
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
int shift) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
......@@ -1114,15 +1072,15 @@ void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
}
WASM_EXEC_COMPILED_TEST(I32x4Shl) {
WASM_SIMD_TEST(I32x4Shl) {
RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1);
}
WASM_EXEC_COMPILED_TEST(I32x4ShrS) {
WASM_SIMD_TEST(I32x4ShrS) {
RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1);
}
WASM_EXEC_COMPILED_TEST(I32x4ShrU) {
WASM_SIMD_TEST(I32x4ShrU) {
RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1);
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
......@@ -1130,8 +1088,7 @@ WASM_EXEC_COMPILED_TEST(I32x4ShrU) {
#if V8_TARGET_ARCH_ARM
// Tests both signed and unsigned conversion from I8x16 (unpacking).
WASM_EXEC_COMPILED_TEST(I16x8ConvertI8x16) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I16x8ConvertI8x16) {
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte unpacked_signed = 1;
......@@ -1158,7 +1115,6 @@ WASM_EXEC_COMPILED_TEST(I16x8ConvertI8x16) {
#if SIMD_LOWERING_TARGET || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
......@@ -1170,14 +1126,13 @@ void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
}
WASM_EXEC_COMPILED_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); }
WASM_SIMD_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); }
#endif // SIMD_LOWERING_TARGET || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS ||
// V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM
// Tests both signed and unsigned conversion from I32x4 (packing).
WASM_EXEC_COMPILED_TEST(I16x8ConvertI32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I16x8ConvertI32x4) {
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte packed_signed = 1;
......@@ -1208,7 +1163,6 @@ WASM_EXEC_COMPILED_TEST(I16x8ConvertI32x4) {
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -1226,15 +1180,15 @@ void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); }
WASM_SIMD_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); }
WASM_EXEC_COMPILED_TEST(I16x8AddSaturateS) {
WASM_SIMD_TEST(I16x8AddSaturateS) {
RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate);
}
WASM_EXEC_COMPILED_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); }
WASM_SIMD_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); }
WASM_EXEC_COMPILED_TEST(I16x8SubSaturateS) {
WASM_SIMD_TEST(I16x8SubSaturateS) {
RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate);
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
......@@ -1242,34 +1196,29 @@ WASM_EXEC_COMPILED_TEST(I16x8SubSaturateS) {
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); }
WASM_SIMD_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); }
WASM_EXEC_COMPILED_TEST(I16x8MinS) {
RunI16x8BinOpTest(kExprI16x8MinS, Minimum);
}
WASM_SIMD_TEST(I16x8MinS) { RunI16x8BinOpTest(kExprI16x8MinS, Minimum); }
WASM_EXEC_COMPILED_TEST(I16x8MaxS) {
RunI16x8BinOpTest(kExprI16x8MaxS, Maximum);
}
WASM_SIMD_TEST(I16x8MaxS) { RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); }
WASM_EXEC_COMPILED_TEST(I16x8AddSaturateU) {
WASM_SIMD_TEST(I16x8AddSaturateU) {
RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate);
}
WASM_EXEC_COMPILED_TEST(I16x8SubSaturateU) {
WASM_SIMD_TEST(I16x8SubSaturateU) {
RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate);
}
WASM_EXEC_COMPILED_TEST(I16x8MinU) {
WASM_SIMD_TEST(I16x8MinU) {
RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum);
}
WASM_EXEC_COMPILED_TEST(I16x8MaxU) {
WASM_SIMD_TEST(I16x8MaxU) {
RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum);
}
void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -1289,45 +1238,33 @@ void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(I16x8Eq) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); }
WASM_SIMD_TEST(I16x8Eq) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); }
WASM_EXEC_COMPILED_TEST(I16x8Ne) {
RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual);
}
WASM_SIMD_TEST(I16x8Ne) { RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); }
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
// V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I16x8LtS) {
RunI16x8CompareOpTest(kExprI16x8LtS, Less);
}
WASM_SIMD_TEST(I16x8LtS) { RunI16x8CompareOpTest(kExprI16x8LtS, Less); }
WASM_EXEC_COMPILED_TEST(I16x8LeS) {
RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual);
}
WASM_SIMD_TEST(I16x8LeS) { RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); }
WASM_EXEC_COMPILED_TEST(I16x8GtS) {
RunI16x8CompareOpTest(kExprI16x8GtS, Greater);
}
WASM_SIMD_TEST(I16x8GtS) { RunI16x8CompareOpTest(kExprI16x8GtS, Greater); }
WASM_EXEC_COMPILED_TEST(I16x8GeS) {
RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual);
}
WASM_SIMD_TEST(I16x8GeS) { RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual); }
WASM_EXEC_COMPILED_TEST(I16x8GtU) {
WASM_SIMD_TEST(I16x8GtU) {
RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater);
}
WASM_EXEC_COMPILED_TEST(I16x8GeU) {
WASM_SIMD_TEST(I16x8GeU) {
RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual);
}
WASM_EXEC_COMPILED_TEST(I16x8LtU) {
RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess);
}
WASM_SIMD_TEST(I16x8LtU) { RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); }
WASM_EXEC_COMPILED_TEST(I16x8LeU) {
WASM_SIMD_TEST(I16x8LeU) {
RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual);
}
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
......@@ -1337,7 +1274,6 @@ WASM_EXEC_COMPILED_TEST(I16x8LeU) {
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op,
int shift) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
......@@ -1350,15 +1286,15 @@ void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op,
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
}
WASM_EXEC_COMPILED_TEST(I16x8Shl) {
WASM_SIMD_TEST(I16x8Shl) {
RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1);
}
WASM_EXEC_COMPILED_TEST(I16x8ShrS) {
WASM_SIMD_TEST(I16x8ShrS) {
RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1);
}
WASM_EXEC_COMPILED_TEST(I16x8ShrU) {
WASM_SIMD_TEST(I16x8ShrU) {
RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1);
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
......@@ -1367,7 +1303,6 @@ WASM_EXEC_COMPILED_TEST(I16x8ShrU) {
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || \
SIMD_LOWERING_TARGET
void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
......@@ -1379,14 +1314,13 @@ void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) {
FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
}
WASM_EXEC_COMPILED_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); }
WASM_SIMD_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); }
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ||
// SIMD_LOWERING_TARGET
#if V8_TARGET_ARCH_ARM
// Tests both signed and unsigned conversion from I16x8 (packing).
WASM_EXEC_COMPILED_TEST(I8x16ConvertI16x8) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(I8x16ConvertI16x8) {
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte packed_signed = 1;
......@@ -1417,7 +1351,6 @@ WASM_EXEC_COMPILED_TEST(I8x16ConvertI16x8) {
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -1435,44 +1368,39 @@ void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); }
WASM_SIMD_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); }
WASM_EXEC_COMPILED_TEST(I8x16AddSaturateS) {
WASM_SIMD_TEST(I8x16AddSaturateS) {
RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate);
}
WASM_EXEC_COMPILED_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); }
WASM_SIMD_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); }
WASM_EXEC_COMPILED_TEST(I8x16SubSaturateS) {
WASM_SIMD_TEST(I8x16SubSaturateS) {
RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate);
}
WASM_EXEC_COMPILED_TEST(I8x16MinS) {
RunI8x16BinOpTest(kExprI8x16MinS, Minimum);
}
WASM_SIMD_TEST(I8x16MinS) { RunI8x16BinOpTest(kExprI8x16MinS, Minimum); }
WASM_EXEC_COMPILED_TEST(I8x16MaxS) {
RunI8x16BinOpTest(kExprI8x16MaxS, Maximum);
}
WASM_SIMD_TEST(I8x16MaxS) { RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); }
WASM_EXEC_COMPILED_TEST(I8x16AddSaturateU) {
WASM_SIMD_TEST(I8x16AddSaturateU) {
RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate);
}
WASM_EXEC_COMPILED_TEST(I8x16SubSaturateU) {
WASM_SIMD_TEST(I8x16SubSaturateU) {
RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate);
}
WASM_EXEC_COMPILED_TEST(I8x16MinU) {
WASM_SIMD_TEST(I8x16MinU) {
RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum);
}
WASM_EXEC_COMPILED_TEST(I8x16MaxU) {
WASM_SIMD_TEST(I8x16MaxU) {
RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum);
}
void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte b = 1;
......@@ -1492,52 +1420,40 @@ void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) {
}
}
WASM_EXEC_COMPILED_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); }
WASM_SIMD_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); }
WASM_EXEC_COMPILED_TEST(I8x16Ne) {
RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual);
}
WASM_SIMD_TEST(I8x16Ne) { RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); }
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
// V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); }
WASM_SIMD_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); }
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS ||
// V8_TARGET_ARCH_MIPS64
// TODO(gdeepti): Remove special case for ARM64 after v8:6421 is fixed
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET && !V8_TARGET_ARCH_ARM64 || \
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I8x16GtS) {
RunI8x16CompareOpTest(kExprI8x16GtS, Greater);
}
WASM_SIMD_TEST(I8x16GtS) { RunI8x16CompareOpTest(kExprI8x16GtS, Greater); }
WASM_EXEC_COMPILED_TEST(I8x16GeS) {
RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual);
}
WASM_SIMD_TEST(I8x16GeS) { RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); }
WASM_EXEC_COMPILED_TEST(I8x16LtS) {
RunI8x16CompareOpTest(kExprI8x16LtS, Less);
}
WASM_SIMD_TEST(I8x16LtS) { RunI8x16CompareOpTest(kExprI8x16LtS, Less); }
WASM_EXEC_COMPILED_TEST(I8x16LeS) {
RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual);
}
WASM_SIMD_TEST(I8x16LeS) { RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual); }
WASM_EXEC_COMPILED_TEST(I8x16GtU) {
WASM_SIMD_TEST(I8x16GtU) {
RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater);
}
WASM_EXEC_COMPILED_TEST(I8x16GeU) {
WASM_SIMD_TEST(I8x16GeU) {
RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual);
}
WASM_EXEC_COMPILED_TEST(I8x16LtU) {
RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess);
}
WASM_SIMD_TEST(I8x16LtU) { RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess); }
WASM_EXEC_COMPILED_TEST(I8x16LeU) {
WASM_SIMD_TEST(I8x16LeU) {
RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual);
}
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET && !V8_TARGET_ARCH_ARM64
......@@ -1545,7 +1461,6 @@ WASM_EXEC_COMPILED_TEST(I8x16LeU) {
void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op,
int shift) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
......@@ -1560,11 +1475,11 @@ void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op,
#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || \
SIMD_LOWERING_TARGET
WASM_EXEC_COMPILED_TEST(I8x16Shl) {
WASM_SIMD_TEST(I8x16Shl) {
RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1);
}
WASM_EXEC_COMPILED_TEST(I8x16ShrS) {
WASM_SIMD_TEST(I8x16ShrS) {
RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1);
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ||
......@@ -1572,7 +1487,7 @@ WASM_EXEC_COMPILED_TEST(I8x16ShrS) {
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
V8_TARGET_ARCH_MIPS64
WASM_EXEC_COMPILED_TEST(I8x16ShrU) {
WASM_SIMD_TEST(I8x16ShrU) {
RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1);
}
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
......@@ -1583,8 +1498,7 @@ WASM_EXEC_COMPILED_TEST(I8x16ShrU) {
// Test Select by making a mask where the first two lanes are true and the rest
// false, and comparing for non-equality with zero to materialize a bool vector.
#define WASM_SIMD_SELECT_TEST(format) \
WASM_EXEC_COMPILED_TEST(S##format##Select) { \
FLAG_wasm_simd_prototype = true; \
WASM_SIMD_TEST(S##format##Select) { \
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \
byte val1 = 0; \
byte val2 = 1; \
......@@ -1592,8 +1506,9 @@ WASM_EXEC_COMPILED_TEST(I8x16ShrU) {
byte src2 = r.AllocateLocal(kWasmS128); \
byte zero = r.AllocateLocal(kWasmS128); \
byte mask = r.AllocateLocal(kWasmS128); \
BUILD(r, WASM_SET_LOCAL( \
src1, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \
BUILD(r, \
WASM_SET_LOCAL(src1, \
WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \
WASM_SET_LOCAL(src2, \
WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val2))), \
WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(WASM_ZERO)), \
......@@ -1603,8 +1518,9 @@ WASM_EXEC_COMPILED_TEST(I8x16ShrU) {
2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), \
WASM_SET_LOCAL( \
mask, \
WASM_SIMD_SELECT(format, WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_GET_LOCAL(mask), \
WASM_SIMD_SELECT( \
format, \
WASM_SIMD_BINOP(kExprI##format##Ne, WASM_GET_LOCAL(mask), \
WASM_GET_LOCAL(zero)), \
WASM_GET_LOCAL(src1), WASM_GET_LOCAL(src2))), \
WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \
......@@ -1633,7 +1549,6 @@ template <typename T>
void RunBinaryLaneOpTest(
WasmOpcode simd_op,
const std::array<T, kSimd128Size / sizeof(T)>& expected) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
// Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7].
T* src0 = r.module().AddGlobal<T>(kWasmS128);
......@@ -1683,113 +1598,113 @@ void RunBinaryLaneOpTest(
}
}
WASM_EXEC_COMPILED_TEST(I32x4AddHoriz) {
WASM_SIMD_TEST(I32x4AddHoriz) {
RunBinaryLaneOpTest<int32_t>(kExprI32x4AddHoriz, {{1, 5, 9, 13}});
}
WASM_EXEC_COMPILED_TEST(I16x8AddHoriz) {
WASM_SIMD_TEST(I16x8AddHoriz) {
RunBinaryLaneOpTest<int16_t>(kExprI16x8AddHoriz,
{{1, 5, 9, 13, 17, 21, 25, 29}});
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64
#if V8_TARGET_ARCH_ARM
WASM_EXEC_COMPILED_TEST(F32x4AddHoriz) {
WASM_SIMD_TEST(F32x4AddHoriz) {
RunBinaryLaneOpTest<float>(kExprF32x4AddHoriz, {{1.0f, 5.0f, 9.0f, 13.0f}});
}
// Test some regular shuffles that may have special handling on some targets.
// Test a normal and unary versions (where second operand isn't used).
WASM_EXEC_COMPILED_TEST(S32x4ZipLeft) {
WASM_SIMD_TEST(S32x4ZipLeft) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 1, 5}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 1, 1}});
}
WASM_EXEC_COMPILED_TEST(S32x4ZipRight) {
WASM_SIMD_TEST(S32x4ZipRight) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{2, 6, 3, 7}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{2, 2, 3, 3}});
}
WASM_EXEC_COMPILED_TEST(S32x4UnzipLeft) {
WASM_SIMD_TEST(S32x4UnzipLeft) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 2, 4, 6}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 2, 0, 2}});
}
WASM_EXEC_COMPILED_TEST(S32x4UnzipRight) {
WASM_SIMD_TEST(S32x4UnzipRight) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 3, 5, 7}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 3, 1, 3}});
}
WASM_EXEC_COMPILED_TEST(S32x4TransposeLeft) {
WASM_SIMD_TEST(S32x4TransposeLeft) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 2, 6}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 2, 2}});
}
WASM_EXEC_COMPILED_TEST(S32x4TransposeRight) {
WASM_SIMD_TEST(S32x4TransposeRight) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 5, 3, 7}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 1, 3, 3}});
}
// Reverses are only unary.
WASM_EXEC_COMPILED_TEST(S32x2Reverse) {
WASM_SIMD_TEST(S32x2Reverse) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 0, 3, 2}});
}
// Test irregular shuffle.
WASM_EXEC_COMPILED_TEST(S32x4Irregular) {
WASM_SIMD_TEST(S32x4Irregular) {
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 4, 5}});
RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 0, 1}});
}
WASM_EXEC_COMPILED_TEST(S16x8ZipLeft) {
WASM_SIMD_TEST(S16x8ZipLeft) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 1, 9, 2, 10, 3, 11}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3}});
}
WASM_EXEC_COMPILED_TEST(S16x8ZipRight) {
WASM_SIMD_TEST(S16x8ZipRight) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle,
{{4, 12, 5, 13, 6, 14, 7, 15}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{4, 4, 5, 5, 6, 6, 7, 7}});
}
WASM_EXEC_COMPILED_TEST(S16x8UnzipLeft) {
WASM_SIMD_TEST(S16x8UnzipLeft) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle,
{{0, 2, 4, 6, 8, 10, 12, 14}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 2, 4, 6, 0, 2, 4, 6}});
}
WASM_EXEC_COMPILED_TEST(S16x8UnzipRight) {
WASM_SIMD_TEST(S16x8UnzipRight) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle,
{{1, 3, 5, 7, 9, 11, 13, 15}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 3, 5, 7, 1, 3, 5, 7}});
}
WASM_EXEC_COMPILED_TEST(S16x8TransposeLeft) {
WASM_SIMD_TEST(S16x8TransposeLeft) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle,
{{0, 8, 2, 10, 4, 12, 6, 14}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 2, 2, 4, 4, 6, 6}});
}
WASM_EXEC_COMPILED_TEST(S16x8TransposeRight) {
WASM_SIMD_TEST(S16x8TransposeRight) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle,
{{1, 9, 3, 11, 5, 13, 7, 15}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 1, 3, 3, 5, 5, 7, 7}});
}
WASM_EXEC_COMPILED_TEST(S16x4Reverse) {
WASM_SIMD_TEST(S16x4Reverse) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4}});
}
WASM_EXEC_COMPILED_TEST(S16x2Reverse) {
WASM_SIMD_TEST(S16x2Reverse) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6}});
}
WASM_EXEC_COMPILED_TEST(S16x8Irregular) {
WASM_SIMD_TEST(S16x8Irregular) {
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 8, 0, 2, 10, 3, 11}});
RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3}});
}
WASM_EXEC_COMPILED_TEST(S8x16ZipLeft) {
WASM_SIMD_TEST(S8x16ZipLeft) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}});
......@@ -1797,7 +1712,7 @@ WASM_EXEC_COMPILED_TEST(S8x16ZipLeft) {
kExprS8x16Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}});
}
WASM_EXEC_COMPILED_TEST(S8x16ZipRight) {
WASM_SIMD_TEST(S8x16ZipRight) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}});
......@@ -1806,7 +1721,7 @@ WASM_EXEC_COMPILED_TEST(S8x16ZipRight) {
{{8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15}});
}
WASM_EXEC_COMPILED_TEST(S8x16UnzipLeft) {
WASM_SIMD_TEST(S8x16UnzipLeft) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}});
......@@ -1814,7 +1729,7 @@ WASM_EXEC_COMPILED_TEST(S8x16UnzipLeft) {
2, 4, 6, 8, 10, 12, 14}});
}
WASM_EXEC_COMPILED_TEST(S8x16UnzipRight) {
WASM_SIMD_TEST(S8x16UnzipRight) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}});
......@@ -1822,7 +1737,7 @@ WASM_EXEC_COMPILED_TEST(S8x16UnzipRight) {
3, 5, 7, 9, 11, 13, 15}});
}
WASM_EXEC_COMPILED_TEST(S8x16TransposeLeft) {
WASM_SIMD_TEST(S8x16TransposeLeft) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30}});
......@@ -1830,7 +1745,7 @@ WASM_EXEC_COMPILED_TEST(S8x16TransposeLeft) {
10, 10, 12, 12, 14, 14}});
}
WASM_EXEC_COMPILED_TEST(S8x16TransposeRight) {
WASM_SIMD_TEST(S8x16TransposeRight) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31}});
......@@ -1838,22 +1753,22 @@ WASM_EXEC_COMPILED_TEST(S8x16TransposeRight) {
11, 11, 13, 13, 15, 15}});
}
WASM_EXEC_COMPILED_TEST(S8x8Reverse) {
WASM_SIMD_TEST(S8x8Reverse) {
RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{7, 6, 5, 4, 3, 2, 1, 0, 15,
14, 13, 12, 11, 10, 9, 8}});
}
WASM_EXEC_COMPILED_TEST(S8x4Reverse) {
WASM_SIMD_TEST(S8x4Reverse) {
RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4, 11,
10, 9, 8, 15, 14, 13, 12}});
}
WASM_EXEC_COMPILED_TEST(S8x2Reverse) {
WASM_SIMD_TEST(S8x2Reverse) {
RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8,
11, 10, 13, 12, 15, 14}});
}
WASM_EXEC_COMPILED_TEST(S8x16Irregular) {
WASM_SIMD_TEST(S8x16Irregular) {
RunBinaryLaneOpTest<int8_t>(
kExprS8x16Shuffle,
{{0, 16, 0, 16, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}});
......@@ -1880,24 +1795,17 @@ void RunConcatOpTest(WasmOpcode simd_op) {
}
}
WASM_EXEC_COMPILED_TEST(S32x4Concat) {
RunConcatOpTest<int32_t>(kExprS32x4Shuffle);
}
WASM_SIMD_TEST(S32x4Concat) { RunConcatOpTest<int32_t>(kExprS32x4Shuffle); }
WASM_EXEC_COMPILED_TEST(S16x8Concat) {
RunConcatOpTest<int16_t>(kExprS16x8Shuffle);
}
WASM_SIMD_TEST(S16x8Concat) { RunConcatOpTest<int16_t>(kExprS16x8Shuffle); }
WASM_EXEC_COMPILED_TEST(S8x16Concat) {
RunConcatOpTest<int8_t>(kExprS8x16Shuffle);
}
WASM_SIMD_TEST(S8x16Concat) { RunConcatOpTest<int8_t>(kExprS8x16Shuffle); }
// Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer
// result. Use relational ops on numeric vectors to create the boolean vector
// test inputs. Test inputs with all true, all false, one true, and one false.
#define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \
WASM_EXEC_TEST(ReductionTest##lanes) { \
FLAG_wasm_simd_prototype = true; \
WASM_SIMD_TEST(ReductionTest##lanes) { \
WasmRunner<int32_t> r(kExecuteCompiled); \
byte zero = r.AllocateLocal(kWasmS128); \
byte one_one = r.AllocateLocal(kWasmS128); \
......@@ -1973,7 +1881,6 @@ WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16)
#define WASM_SIMD_UNOP_HELPER(format, lanes, lane_size) \
void RunS1x##lanes##UnOpTest(WasmOpcode simd_op, \
Int##lane_size##UnOp expected_op) { \
FLAG_wasm_simd_prototype = true; \
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \
byte a = 0; \
byte expected = 1; \
......@@ -2001,18 +1908,15 @@ WASM_SIMD_UNOP_HELPER(16x8, 8, 16);
WASM_SIMD_UNOP_HELPER(8x16, 16, 8);
#undef WASM_SIMD_UNOP_HELPER
WASM_EXEC_COMPILED_TEST(S1x4Not) { RunS1x4UnOpTest(kExprS1x4Not, LogicalNot); }
WASM_SIMD_TEST(S1x4Not) { RunS1x4UnOpTest(kExprS1x4Not, LogicalNot); }
WASM_EXEC_COMPILED_TEST(S1x8Not) { RunS1x8UnOpTest(kExprS1x8Not, LogicalNot); }
WASM_SIMD_TEST(S1x8Not) { RunS1x8UnOpTest(kExprS1x8Not, LogicalNot); }
WASM_EXEC_COMPILED_TEST(S1x16Not) {
RunS1x16UnOpTest(kExprS1x16Not, LogicalNot);
}
WASM_SIMD_TEST(S1x16Not) { RunS1x16UnOpTest(kExprS1x16Not, LogicalNot); }
#define WASM_SIMD_BINOP_HELPER(format, lanes, lane_size) \
void RunS1x##lanes##BinOpTest(WasmOpcode simd_op, \
Int##lane_size##BinOp expected_op) { \
FLAG_wasm_simd_prototype = true; \
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); \
byte a = 0; \
byte b = 1; \
......@@ -2049,28 +1953,27 @@ WASM_SIMD_BINOP_HELPER(16x8, 8, 16);
WASM_SIMD_BINOP_HELPER(8x16, 16, 8);
#undef WASM_SIMD_BINOP_HELPER
WASM_EXEC_COMPILED_TEST(S1x4And) { RunS1x4BinOpTest(kExprS1x4And, And); }
WASM_SIMD_TEST(S1x4And) { RunS1x4BinOpTest(kExprS1x4And, And); }
WASM_EXEC_COMPILED_TEST(S1x4Or) { RunS1x4BinOpTest(kExprS1x4Or, Or); }
WASM_SIMD_TEST(S1x4Or) { RunS1x4BinOpTest(kExprS1x4Or, Or); }
WASM_EXEC_COMPILED_TEST(S1x4Xor) { RunS1x4BinOpTest(kExprS1x4Xor, Xor); }
WASM_SIMD_TEST(S1x4Xor) { RunS1x4BinOpTest(kExprS1x4Xor, Xor); }
WASM_EXEC_COMPILED_TEST(S1x8And) { RunS1x8BinOpTest(kExprS1x8And, And); }
WASM_SIMD_TEST(S1x8And) { RunS1x8BinOpTest(kExprS1x8And, And); }
WASM_EXEC_COMPILED_TEST(S1x8Or) { RunS1x8BinOpTest(kExprS1x8Or, Or); }
WASM_SIMD_TEST(S1x8Or) { RunS1x8BinOpTest(kExprS1x8Or, Or); }
WASM_EXEC_COMPILED_TEST(S1x8Xor) { RunS1x8BinOpTest(kExprS1x8Xor, Xor); }
WASM_SIMD_TEST(S1x8Xor) { RunS1x8BinOpTest(kExprS1x8Xor, Xor); }
WASM_EXEC_COMPILED_TEST(S1x16And) { RunS1x16BinOpTest(kExprS1x16And, And); }
WASM_SIMD_TEST(S1x16And) { RunS1x16BinOpTest(kExprS1x16And, And); }
WASM_EXEC_COMPILED_TEST(S1x16Or) { RunS1x16BinOpTest(kExprS1x16Or, Or); }
WASM_SIMD_TEST(S1x16Or) { RunS1x16BinOpTest(kExprS1x16Or, Or); }
WASM_EXEC_COMPILED_TEST(S1x16Xor) { RunS1x16BinOpTest(kExprS1x16Xor, Xor); }
WASM_SIMD_TEST(S1x16Xor) { RunS1x16BinOpTest(kExprS1x16Xor, Xor); }
#endif // !V8_TARGET_ARCH_ARM
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
WASM_EXEC_COMPILED_TEST(SimdI32x4ExtractWithF32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) {
WasmRunner<int32_t> r(kExecuteCompiled);
BUILD(r, WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
......@@ -2080,8 +1983,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4ExtractWithF32x4) {
CHECK_EQ(1, r.Call());
}
WASM_EXEC_COMPILED_TEST(SimdF32x4ExtractWithI32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdF32x4ExtractWithI32x4) {
WasmRunner<int32_t> r(kExecuteCompiled);
BUILD(r,
WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
......@@ -2091,8 +1993,7 @@ WASM_EXEC_COMPILED_TEST(SimdF32x4ExtractWithI32x4) {
CHECK_EQ(1, r.Call());
}
WASM_EXEC_COMPILED_TEST(SimdF32x4AddWithI32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdF32x4AddWithI32x4) {
// Choose two floating point values whose sum is normal and exactly
// representable as a float.
const int kOne = 0x3f800000;
......@@ -2111,8 +2012,7 @@ WASM_EXEC_COMPILED_TEST(SimdF32x4AddWithI32x4) {
CHECK_EQ(1, r.Call());
}
WASM_EXEC_COMPILED_TEST(SimdI32x4AddWithF32x4) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4AddWithF32x4) {
WasmRunner<int32_t> r(kExecuteCompiled);
BUILD(r,
WASM_IF_ELSE_I(
......@@ -2129,8 +2029,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4AddWithF32x4) {
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64
WASM_EXEC_COMPILED_TEST(SimdI32x4Local) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4Local) {
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
......@@ -2139,8 +2038,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4Local) {
CHECK_EQ(31, r.Call());
}
WASM_EXEC_COMPILED_TEST(SimdI32x4SplatFromExtract) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4SplatFromExtract) {
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128);
......@@ -2151,8 +2049,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4SplatFromExtract) {
CHECK_EQ(76, r.Call());
}
WASM_EXEC_COMPILED_TEST(SimdI32x4For) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4For) {
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128);
......@@ -2188,8 +2085,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4For) {
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
WASM_EXEC_COMPILED_TEST(SimdF32x4For) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdF32x4For) {
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128);
......@@ -2241,8 +2137,7 @@ const T& GetScalar(T* v, int lane) {
return v[index];
}
WASM_EXEC_COMPILED_TEST(SimdI32x4GetGlobal) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4GetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128);
SetVectorByLanes(global, {{0, 1, 2, 3}});
......@@ -2265,8 +2160,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4GetGlobal) {
CHECK_EQ(1, r.Call(0));
}
WASM_EXEC_COMPILED_TEST(SimdI32x4SetGlobal) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdI32x4SetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))),
......@@ -2286,8 +2180,7 @@ WASM_EXEC_COMPILED_TEST(SimdI32x4SetGlobal) {
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
WASM_EXEC_COMPILED_TEST(SimdF32x4GetGlobal) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdF32x4GetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
float* global = r.module().AddGlobal<float>(kWasmS128);
SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}});
......@@ -2310,8 +2203,7 @@ WASM_EXEC_COMPILED_TEST(SimdF32x4GetGlobal) {
CHECK_EQ(1, r.Call(0));
}
WASM_EXEC_COMPILED_TEST(SimdF32x4SetGlobal) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdF32x4SetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
float* global = r.module().AddGlobal<float>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))),
......@@ -2331,8 +2223,7 @@ WASM_EXEC_COMPILED_TEST(SimdF32x4SetGlobal) {
#endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64
WASM_EXEC_COMPILED_TEST(SimdLoadStoreLoad) {
FLAG_wasm_simd_prototype = true;
WASM_SIMD_TEST(SimdLoadStoreLoad) {
WasmRunner<int32_t> r(kExecuteCompiled);
int32_t* memory = r.module().AddMemoryElems<int32_t>(4);
......
......@@ -109,14 +109,14 @@ static void RunInt32AddTest(WasmExecutionMode execution_mode, const byte* code,
}
WASM_EXEC_TEST(Int32Add_P2) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
static const byte code[] = {
WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
RunInt32AddTest(execution_mode, code, sizeof(code));
}
WASM_EXEC_TEST(Int32Add_block1) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
static const byte code[] = {
WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
kExprI32Add};
......@@ -124,7 +124,7 @@ WASM_EXEC_TEST(Int32Add_block1) {
}
WASM_EXEC_TEST(Int32Add_block2) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
static const byte code[] = {
WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
kExprBr, DEPTH_0),
......@@ -133,7 +133,7 @@ WASM_EXEC_TEST(Int32Add_block2) {
}
WASM_EXEC_TEST(Int32Add_multi_if) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
static const byte code[] = {
WASM_IF_ELSE_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
WASM_SEQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
......@@ -2398,7 +2398,7 @@ WASM_EXEC_TEST(AddCall) {
}
WASM_EXEC_TEST(MultiReturnSub) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
ValueType storage[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32};
......@@ -2420,7 +2420,7 @@ WASM_EXEC_TEST(MultiReturnSub) {
template <typename T>
void RunMultiReturnSelect(WasmExecutionMode execution_mode, const T* inputs) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
ValueType type = WasmOpcodes::ValueTypeFor(MachineTypeForC<T>());
ValueType storage[] = {type, type, type, type, type, type};
const size_t kNumReturns = 2;
......
......@@ -13,8 +13,6 @@
#include <memory>
#include "src/base/utils/random-number-generator.h"
#include "src/zone/accounting-allocator.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/int64-lowering.h"
......@@ -32,12 +30,13 @@
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/zone/accounting-allocator.h"
#include "src/zone/zone.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/call-tester.h"
#include "test/cctest/compiler/graph-builder-tester.h"
#include "test/common/wasm/flag-utils.h"
static const uint32_t kMaxFunctions = 10;
......@@ -839,11 +838,6 @@ bool WasmRunnerBase::trap_happened;
} \
void RunWasm_##name(WasmExecutionMode execution_mode)
#define WASM_EXEC_COMPILED_TEST(name) \
void RunWasm_##name(WasmExecutionMode execution_mode); \
TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
void RunWasm_##name(WasmExecutionMode execution_mode)
} // namespace
#endif
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TEST_COMMON_FLAG_UTILS_H
#define V8_TEST_COMMON_FLAG_UTILS_H
class EnableFlagScope {
public:
EnableFlagScope(bool* flag, bool new_value = true)
: flag_(flag), previous_value_(flag) {
*flag = new_value;
}
~EnableFlagScope() { *flag_ = previous_value_; }
private:
bool* flag_;
bool previous_value_;
};
#define EXPERIMENTAL_FLAG_SCOPE(flag) \
EnableFlagScope __flag_scope_##__LINE__(&FLAG_experimental_wasm_##flag)
#endif // V8_TEST_COMMON_FLAG_UTILS_H
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm --wasm-eh-prototype
// Flags: --expose-wasm --experimental-wasm-eh
load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
......
......@@ -15,12 +15,13 @@
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {
using namespace v8::internal;
using namespace v8::internal::wasm;
using namespace v8::internal::wasm::testing;
#define B1(a) WASM_BLOCK(a)
#define B2(a, b) WASM_BLOCK(a, b)
......@@ -82,21 +83,12 @@ static const WasmOpcode kInt32BinopOpcodes[] = {
Verify(false, sigs.sig(), code, code + sizeof(code)); \
} while (false)
static bool old_eh_flag;
class FunctionBodyDecoderTest : public TestWithZone {
public:
typedef std::pair<uint32_t, ValueType> LocalsDecl;
FunctionBodyDecoderTest() : module(nullptr), local_decls(zone()) {}
static void SetUpTestCase() { old_eh_flag = FLAG_wasm_eh_prototype; }
static void TearDownTestCase() {
// Reset the wasm_eh_prototype flag
FLAG_wasm_eh_prototype = old_eh_flag;
}
TestSignatures sigs;
ModuleEnv* module;
LocalDeclEncoder local_decls;
......@@ -1446,7 +1438,7 @@ TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs3) {
}
TEST_F(FunctionBodyDecoderTest, MultiReturn) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
ValueType storage[] = {kWasmI32, kWasmI32};
FunctionSig sig_ii_v(2, 0, storage);
FunctionSig sig_v_ii(0, 2, storage);
......@@ -1462,7 +1454,7 @@ TEST_F(FunctionBodyDecoderTest, MultiReturn) {
}
TEST_F(FunctionBodyDecoderTest, MultiReturnType) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
for (size_t a = 0; a < arraysize(kValueTypes); a++) {
for (size_t b = 0; b < arraysize(kValueTypes); b++) {
for (size_t c = 0; c < arraysize(kValueTypes); c++) {
......@@ -2247,7 +2239,7 @@ TEST_F(FunctionBodyDecoderTest, Select_TypeCheck) {
}
TEST_F(FunctionBodyDecoderTest, Throw) {
FLAG_wasm_eh_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(eh);
EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow);
EXPECT_FAILURE(i_d, WASM_GET_LOCAL(0), kExprThrow, WASM_I32V(0));
......@@ -2257,7 +2249,7 @@ TEST_F(FunctionBodyDecoderTest, Throw) {
TEST_F(FunctionBodyDecoderTest, ThrowUnreachable) {
// TODO(titzer): unreachable code after throw should validate.
// FLAG_wasm_eh_prototype = true;
// EXPERIMENTAL_FLAG_SCOPE(eh);
// EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow, kExprSetLocal, 0);
}
......@@ -2266,7 +2258,7 @@ TEST_F(FunctionBodyDecoderTest, ThrowUnreachable) {
#define WASM_CATCH(local) kExprCatch, static_cast<byte>(local)
TEST_F(FunctionBodyDecoderTest, TryCatch) {
FLAG_wasm_eh_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(eh);
EXPECT_VERIFIES(v_i, WASM_TRY_OP, WASM_CATCH(0), kExprEnd);
// Missing catch.
......@@ -2280,21 +2272,21 @@ TEST_F(FunctionBodyDecoderTest, TryCatch) {
}
TEST_F(FunctionBodyDecoderTest, MultiValBlock1) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1)),
kExprI32Add);
}
TEST_F(FunctionBodyDecoderTest, MultiValBlock2) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1)),
WASM_I32_ADD(WASM_NOP, WASM_NOP));
}
TEST_F(FunctionBodyDecoderTest, MultiValBlockBr1) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
EXPECT_FAILURE(
i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), WASM_BR(0)),
kExprI32Add);
......@@ -2304,7 +2296,7 @@ TEST_F(FunctionBodyDecoderTest, MultiValBlockBr1) {
}
TEST_F(FunctionBodyDecoderTest, MultiValIf1) {
FLAG_wasm_mv_prototype = true;
EXPERIMENTAL_FLAG_SCOPE(mv);
EXPECT_FAILURE(
i_ii, WASM_IF_ELSE_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
WASM_SEQ(WASM_GET_LOCAL(0)),
......@@ -2826,7 +2818,3 @@ TEST_F(BytecodeIteratorTest, WithLocalDecls) {
iter.next();
EXPECT_FALSE(iter.has_next());
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -9,6 +9,7 @@
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-opcodes.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
......@@ -833,18 +834,16 @@ TEST_F(WasmSignatureDecodeTest, TooManyParams) {
}
TEST_F(WasmSignatureDecodeTest, TooManyReturns) {
bool prev = FLAG_wasm_mv_prototype;
for (int i = 0; i < 2; i++) {
FLAG_wasm_mv_prototype = i != 0;
const int max_return_count =
static_cast<int>(FLAG_wasm_mv_prototype ? kV8MaxWasmFunctionMultiReturns
EnableFlagScope flag_scope(&FLAG_experimental_wasm_mv, i != 0);
const int max_return_count = static_cast<int>(
FLAG_experimental_wasm_mv ? kV8MaxWasmFunctionMultiReturns
: kV8MaxWasmFunctionReturns);
byte data[] = {kWasmFunctionTypeForm, 0, WASM_I32V_3(max_return_count + 1),
kLocalI32};
FunctionSig* sig =
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
FLAG_wasm_mv_prototype = prev;
}
}
......
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