Commit e5f064d3 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Enable tests for Liftoff

This extends the WASM_EXEC_TEST to also execute the test in Liftoff
(our new baseline compiler).
Use WASM_COMPILED_EXEC_TEST to execute in both compilers, but not in
the interpreter.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: I0b76a5cff9af1b8c4aaec3cceb154ad29ca1b58e
Reviewed-on: https://chromium-review.googlesource.com/733560
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48932}
parent 32141e93
......@@ -87,10 +87,6 @@ class LiftoffCompiler {
}
void StartFunction(Decoder* decoder) {
if (!kLiftoffAssemblerImplementedOnThisPlatform) {
unsupported(decoder, "platform");
return;
}
int num_locals = decoder->NumLocals();
__ set_num_locals(num_locals);
for (int i = 0; i < num_locals; ++i) {
......@@ -99,6 +95,10 @@ class LiftoffCompiler {
}
void StartFunctionBody(Decoder* decoder, Control* block) {
if (!kLiftoffAssemblerImplementedOnThisPlatform) {
unsupported(decoder, "platform");
return;
}
__ EnterFrame(StackFrame::WASM_COMPILED);
__ ReserveStackSpace(kPointerSize *
(__ num_locals() + kMaxValueStackHeight));
......
......@@ -30,7 +30,7 @@ class CWasmEntryArgTester {
public:
CWasmEntryArgTester(std::initializer_list<uint8_t> wasm_function_bytes,
std::function<ReturnType(Args...)> expected_fn)
: runner_(kExecuteCompiled),
: runner_(kExecuteTurbofan),
isolate_(runner_.main_isolate()),
expected_fn_(expected_fn),
sig_(runner_.template CreateSig<ReturnType, Args...>()) {
......
......@@ -1545,12 +1545,12 @@ WASM_EXEC_TEST(UnalignedInt64Store) {
for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \
} while (false)
static void CompileCallIndirectMany(ValueType param) {
static void CompileCallIndirectMany(WasmExecutionMode mode, ValueType param) {
// Make sure we don't run out of registers when compiling indirect calls
// with many many parameters.
TestSignatures sigs;
for (byte num_params = 0; num_params < 40; num_params++) {
WasmRunner<void> r(kExecuteCompiled);
WasmRunner<void> r(mode);
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
r.builder().AddSignature(sig);
......@@ -1570,7 +1570,9 @@ static void CompileCallIndirectMany(ValueType param) {
}
}
TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kWasmI64); }
WASM_EXEC_TEST(Compile_Wasm_CallIndirect_Many_i64) {
CompileCallIndirectMany(execution_mode, kWasmI64);
}
static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
const int kExpected = 6333;
......
......@@ -52,9 +52,10 @@ T CompareExchange(T initial, T a, T b) {
return a;
}
void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) {
void RunU32BinOp(WasmExecutionMode mode, WasmOpcode wasm_op,
Uint32BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t> r(mode);
uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8);
r.builder().SetHasSharedMemory();
......@@ -72,16 +73,29 @@ void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) {
}
}
TEST(I32AtomicAdd) { RunU32BinOp(kExprI32AtomicAdd, Add); }
TEST(I32AtomicSub) { RunU32BinOp(kExprI32AtomicSub, Sub); }
TEST(I32AtomicAnd) { RunU32BinOp(kExprI32AtomicAnd, And); }
TEST(I32AtomicOr) { RunU32BinOp(kExprI32AtomicOr, Or); }
TEST(I32AtomicXor) { RunU32BinOp(kExprI32AtomicXor, Xor); }
TEST(I32AtomicExchange) { RunU32BinOp(kExprI32AtomicExchange, Exchange); }
WASM_COMPILED_EXEC_TEST(I32AtomicAdd) {
RunU32BinOp(execution_mode, kExprI32AtomicAdd, Add);
}
WASM_COMPILED_EXEC_TEST(I32AtomicSub) {
RunU32BinOp(execution_mode, kExprI32AtomicSub, Sub);
}
WASM_COMPILED_EXEC_TEST(I32AtomicAnd) {
RunU32BinOp(execution_mode, kExprI32AtomicAnd, And);
}
WASM_COMPILED_EXEC_TEST(I32AtomicOr) {
RunU32BinOp(execution_mode, kExprI32AtomicOr, Or);
}
WASM_COMPILED_EXEC_TEST(I32AtomicXor) {
RunU32BinOp(execution_mode, kExprI32AtomicXor, Xor);
}
WASM_COMPILED_EXEC_TEST(I32AtomicExchange) {
RunU32BinOp(execution_mode, kExprI32AtomicExchange, Exchange);
}
void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) {
void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op,
Uint16BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t> r(mode);
r.builder().SetHasSharedMemory();
uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8);
......@@ -99,16 +113,29 @@ void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) {
}
}
TEST(I32AtomicAdd16U) { RunU16BinOp(kExprI32AtomicAdd16U, Add); }
TEST(I32AtomicSub16U) { RunU16BinOp(kExprI32AtomicSub16U, Sub); }
TEST(I32AtomicAnd16U) { RunU16BinOp(kExprI32AtomicAnd16U, And); }
TEST(I32AtomicOr16U) { RunU16BinOp(kExprI32AtomicOr16U, Or); }
TEST(I32AtomicXor16U) { RunU16BinOp(kExprI32AtomicXor16U, Xor); }
TEST(I32AtomicExchange16U) { RunU16BinOp(kExprI32AtomicExchange16U, Exchange); }
WASM_COMPILED_EXEC_TEST(I32AtomicAdd16U) {
RunU16BinOp(execution_mode, kExprI32AtomicAdd16U, Add);
}
WASM_COMPILED_EXEC_TEST(I32AtomicSub16U) {
RunU16BinOp(execution_mode, kExprI32AtomicSub16U, Sub);
}
WASM_COMPILED_EXEC_TEST(I32AtomicAnd16U) {
RunU16BinOp(execution_mode, kExprI32AtomicAnd16U, And);
}
WASM_COMPILED_EXEC_TEST(I32AtomicOr16U) {
RunU16BinOp(execution_mode, kExprI32AtomicOr16U, Or);
}
WASM_COMPILED_EXEC_TEST(I32AtomicXor16U) {
RunU16BinOp(execution_mode, kExprI32AtomicXor16U, Xor);
}
WASM_COMPILED_EXEC_TEST(I32AtomicExchange16U) {
RunU16BinOp(execution_mode, kExprI32AtomicExchange16U, Exchange);
}
void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) {
void RunU8BinOp(WasmExecutionMode mode, WasmOpcode wasm_op,
Uint8BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t> r(mode);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8);
......@@ -126,16 +153,28 @@ void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) {
}
}
TEST(I32AtomicAdd8U) { RunU8BinOp(kExprI32AtomicAdd8U, Add); }
TEST(I32AtomicSub8U) { RunU8BinOp(kExprI32AtomicSub8U, Sub); }
TEST(I32AtomicAnd8U) { RunU8BinOp(kExprI32AtomicAnd8U, And); }
TEST(I32AtomicOr8U) { RunU8BinOp(kExprI32AtomicOr8U, Or); }
TEST(I32AtomicXor8U) { RunU8BinOp(kExprI32AtomicXor8U, Xor); }
TEST(I32AtomicExchange8U) { RunU8BinOp(kExprI32AtomicExchange8U, Exchange); }
WASM_COMPILED_EXEC_TEST(I32AtomicAdd8U) {
RunU8BinOp(execution_mode, kExprI32AtomicAdd8U, Add);
}
WASM_COMPILED_EXEC_TEST(I32AtomicSub8U) {
RunU8BinOp(execution_mode, kExprI32AtomicSub8U, Sub);
}
WASM_COMPILED_EXEC_TEST(I32AtomicAnd8U) {
RunU8BinOp(execution_mode, kExprI32AtomicAnd8U, And);
}
WASM_COMPILED_EXEC_TEST(I32AtomicOr8U) {
RunU8BinOp(execution_mode, kExprI32AtomicOr8U, Or);
}
WASM_COMPILED_EXEC_TEST(I32AtomicXor8U) {
RunU8BinOp(execution_mode, kExprI32AtomicXor8U, Xor);
}
WASM_COMPILED_EXEC_TEST(I32AtomicExchange8U) {
RunU8BinOp(execution_mode, kExprI32AtomicExchange8U, Exchange);
}
TEST(I32AtomicCompareExchange) {
WASM_COMPILED_EXEC_TEST(I32AtomicCompareExchange) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8);
BUILD(r, WASM_ATOMICS_TERNARY_OP(
......@@ -153,9 +192,9 @@ TEST(I32AtomicCompareExchange) {
}
}
TEST(I32AtomicCompareExchange16U) {
WASM_COMPILED_EXEC_TEST(I32AtomicCompareExchange16U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8);
BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange16U,
......@@ -174,9 +213,9 @@ TEST(I32AtomicCompareExchange16U) {
}
}
TEST(I32AtomicCompareExchange8U) {
WASM_COMPILED_EXEC_TEST(I32AtomicCompareExchange8U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8);
BUILD(r,
......@@ -195,9 +234,9 @@ TEST(I32AtomicCompareExchange8U) {
}
}
TEST(I32AtomicLoad) {
WASM_COMPILED_EXEC_TEST(I32AtomicLoad) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
......@@ -210,9 +249,9 @@ TEST(I32AtomicLoad) {
}
}
TEST(I32AtomicLoad16U) {
WASM_COMPILED_EXEC_TEST(I32AtomicLoad16U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
......@@ -225,9 +264,9 @@ TEST(I32AtomicLoad16U) {
}
}
TEST(I32AtomicLoad8U) {
WASM_COMPILED_EXEC_TEST(I32AtomicLoad8U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
......@@ -240,9 +279,9 @@ TEST(I32AtomicLoad8U) {
}
}
TEST(I32AtomicStoreLoad) {
WASM_COMPILED_EXEC_TEST(I32AtomicStoreLoad) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8);
......@@ -259,9 +298,9 @@ TEST(I32AtomicStoreLoad) {
}
}
TEST(I32AtomicStoreLoad16U) {
WASM_COMPILED_EXEC_TEST(I32AtomicStoreLoad16U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8);
......@@ -279,9 +318,9 @@ TEST(I32AtomicStoreLoad16U) {
}
}
TEST(I32AtomicStoreLoad8U) {
WASM_COMPILED_EXEC_TEST(I32AtomicStoreLoad8U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8);
......
......@@ -17,8 +17,8 @@ namespace internal {
namespace wasm {
namespace test_run_wasm_relocation {
TEST(RunPatchWasmContext) {
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(RunPatchWasmContext) {
WasmRunner<uint32_t, uint32_t> r(execution_mode);
Isolate* isolate = CcTest::i_isolate();
r.builder().AddGlobal<uint32_t>();
......
......@@ -35,7 +35,7 @@ typedef int8_t (*Int8ShiftOp)(int8_t, int);
void RunWasm_##name##_Impl(WasmExecutionMode execution_mode); \
TEST(RunWasm_##name##_compiled) { \
EXPERIMENTAL_FLAG_SCOPE(simd); \
RunWasm_##name##_Impl(kExecuteCompiled); \
RunWasm_##name##_Impl(kExecuteTurbofan); \
} \
TEST(RunWasm_##name##_simd_lowered) { \
EXPERIMENTAL_FLAG_SCOPE(simd); \
......@@ -47,7 +47,7 @@ typedef int8_t (*Int8ShiftOp)(int8_t, int);
void RunWasm_##name##_Impl(WasmExecutionMode execution_mode); \
TEST(RunWasm_##name##_compiled) { \
EXPERIMENTAL_FLAG_SCOPE(simd); \
RunWasm_##name##_Impl(kExecuteCompiled); \
RunWasm_##name##_Impl(kExecuteTurbofan); \
} \
void RunWasm_##name##_Impl(WasmExecutionMode execution_mode)
......
......@@ -1867,30 +1867,30 @@ WASM_EXEC_TEST(Unreachable0b) {
CHECK_EQ(7, r.Call(1));
}
TEST(Build_Wasm_Unreachable1) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(Build_Wasm_Unreachable1) {
WasmRunner<int32_t, int32_t> r(execution_mode);
BUILD(r, WASM_UNREACHABLE);
}
TEST(Build_Wasm_Unreachable2) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(Build_Wasm_Unreachable2) {
WasmRunner<int32_t, int32_t> r(execution_mode);
BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE);
}
TEST(Build_Wasm_Unreachable3) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(Build_Wasm_Unreachable3) {
WasmRunner<int32_t, int32_t> r(execution_mode);
BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE, WASM_UNREACHABLE);
}
TEST(Build_Wasm_UnreachableIf1) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(Build_Wasm_UnreachableIf1) {
WasmRunner<int32_t, int32_t> r(execution_mode);
BUILD(r, WASM_UNREACHABLE,
WASM_IF(WASM_GET_LOCAL(0), WASM_SEQ(WASM_GET_LOCAL(0), WASM_DROP)),
WASM_ZERO);
}
TEST(Build_Wasm_UnreachableIf2) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(Build_Wasm_UnreachableIf2) {
WasmRunner<int32_t, int32_t> r(execution_mode);
BUILD(r, WASM_UNREACHABLE,
WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_UNREACHABLE));
}
......@@ -2931,12 +2931,12 @@ WASM_EXEC_TEST(F32CopySign) {
}
}
static void CompileCallIndirectMany(ValueType param) {
static void CompileCallIndirectMany(WasmExecutionMode mode, ValueType param) {
// Make sure we don't run out of registers when compiling indirect calls
// with many many parameters.
TestSignatures sigs;
for (byte num_params = 0; num_params < 40; ++num_params) {
WasmRunner<void> r(kExecuteCompiled);
WasmRunner<void> r(mode);
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
r.builder().AddSignature(sig);
......@@ -2956,11 +2956,17 @@ static void CompileCallIndirectMany(ValueType param) {
}
}
TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kWasmI32); }
WASM_COMPILED_EXEC_TEST(Compile_Wasm_CallIndirect_Many_i32) {
CompileCallIndirectMany(execution_mode, kWasmI32);
}
TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kWasmF32); }
WASM_COMPILED_EXEC_TEST(Compile_Wasm_CallIndirect_Many_f32) {
CompileCallIndirectMany(execution_mode, kWasmF32);
}
TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kWasmF64); }
WASM_COMPILED_EXEC_TEST(Compile_Wasm_CallIndirect_Many_f64) {
CompileCallIndirectMany(execution_mode, kWasmF64);
}
WASM_EXEC_TEST(Int32RemS_dead) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
......
......@@ -265,8 +265,8 @@ std::vector<WasmValue> wasmVec(Args... args) {
} // namespace
TEST(WasmCollectPossibleBreakpoints) {
WasmRunner<int> runner(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(WasmCollectPossibleBreakpoints) {
WasmRunner<int> runner(execution_mode);
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE));
......@@ -290,8 +290,8 @@ TEST(WasmCollectPossibleBreakpoints) {
CheckLocationsFail(instance->compiled_module(), {0, 9}, {1, 0});
}
TEST(WasmSimpleBreak) {
WasmRunner<int> runner(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) {
WasmRunner<int> runner(execution_mode);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
......@@ -311,8 +311,8 @@ TEST(WasmSimpleBreak) {
CHECK_EQ(14, result);
}
TEST(WasmSimpleStepping) {
WasmRunner<int> runner(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) {
WasmRunner<int> runner(execution_mode);
BUILD(runner, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
Isolate* isolate = runner.main_isolate();
......@@ -338,8 +338,8 @@ TEST(WasmSimpleStepping) {
CHECK_EQ(14, result);
}
TEST(WasmStepInAndOut) {
WasmRunner<int, int> runner(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) {
WasmRunner<int, int> runner(execution_mode);
WasmFunctionCompiler& f2 = runner.NewFunction<void>();
f2.AllocateLocal(ValueType::kWord32);
......@@ -378,8 +378,8 @@ TEST(WasmStepInAndOut) {
.is_null());
}
TEST(WasmGetLocalsAndStack) {
WasmRunner<void, int> runner(kExecuteCompiled);
WASM_COMPILED_EXEC_TEST(WasmGetLocalsAndStack) {
WasmRunner<void, int> runner(execution_mode);
runner.AllocateLocal(ValueType::kWord64);
runner.AllocateLocal(ValueType::kFloat32);
runner.AllocateLocal(ValueType::kFloat64);
......
......@@ -90,7 +90,7 @@ static ArgPassingHelper<T> GetHelper(
// Pass int32_t, return int32_t.
TEST(TestArgumentPassing_int32) {
WasmRunner<int32_t, int32_t> runner(kExecuteCompiled);
WasmRunner<int32_t, int32_t> runner(kExecuteTurbofan);
WasmFunctionCompiler& f2 = runner.NewFunction<int32_t, int32_t>();
auto helper = GetHelper(
......@@ -106,7 +106,7 @@ TEST(TestArgumentPassing_int32) {
// Pass int64_t, return double.
TEST(TestArgumentPassing_double_int64) {
WasmRunner<double, int32_t, int32_t> runner(kExecuteCompiled);
WasmRunner<double, int32_t, int32_t> runner(kExecuteTurbofan);
WasmFunctionCompiler& f2 = runner.NewFunction<double, int64_t>();
auto helper = GetHelper(
......@@ -139,7 +139,7 @@ TEST(TestArgumentPassing_double_int64) {
// Pass double, return int64_t.
TEST(TestArgumentPassing_int64_double) {
// Outer function still returns double.
WasmRunner<double, double> runner(kExecuteCompiled);
WasmRunner<double, double> runner(kExecuteTurbofan);
WasmFunctionCompiler& f2 = runner.NewFunction<int64_t, double>();
auto helper = GetHelper(
......@@ -158,7 +158,7 @@ TEST(TestArgumentPassing_int64_double) {
// Pass float, return double.
TEST(TestArgumentPassing_float_double) {
WasmRunner<double, float> runner(kExecuteCompiled);
WasmRunner<double, float> runner(kExecuteTurbofan);
WasmFunctionCompiler& f2 = runner.NewFunction<double, float>();
auto helper = GetHelper(
......@@ -176,7 +176,7 @@ TEST(TestArgumentPassing_float_double) {
// Pass two doubles, return double.
TEST(TestArgumentPassing_double_double) {
WasmRunner<double, double, double> runner(kExecuteCompiled);
WasmRunner<double, double, double> runner(kExecuteTurbofan);
WasmFunctionCompiler& f2 = runner.NewFunction<double, double, double>();
auto helper = GetHelper(runner, f2,
......@@ -196,7 +196,7 @@ TEST(TestArgumentPassing_double_double) {
TEST(TestArgumentPassing_AllTypes) {
// The second and third argument will be combined to an i64.
WasmRunner<double, int32_t, int32_t, int32_t, float, double> runner(
kExecuteCompiled);
kExecuteTurbofan);
WasmFunctionCompiler& f2 =
runner.NewFunction<double, int32_t, int64_t, float, double>();
......
......@@ -101,8 +101,8 @@ void CheckComputeLocation(v8::internal::Isolate* i_isolate, Handle<Object> exc,
} // namespace
// Call from JS to wasm to JS and throw an Error from JS.
TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
WasmRunner<void> r(kExecuteCompiled);
WASM_EXEC_TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
WasmRunner<void> r(execution_mode);
TestSignatures sigs;
Handle<FixedArray> js_imports_table =
......@@ -150,13 +150,13 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
}
// Trigger a trap in wasm, stack should be JS -> wasm -> wasm.
TEST(CollectDetailedWasmStack_WasmError) {
WASM_EXEC_TEST(CollectDetailedWasmStack_WasmError) {
for (int pos_shift = 0; pos_shift < 3; ++pos_shift) {
// Test a position with 1, 2 or 3 bytes needed to represent it.
int unreachable_pos = 1 << (8 * pos_shift);
TestSignatures sigs;
// Create a WasmRunner with stack checks and traps enabled.
WasmRunner<int> r(kExecuteCompiled, "main",
WasmRunner<int> r(execution_mode, "main",
compiler::kRuntimeExceptionSupport);
std::vector<byte> code(unreachable_pos + 1, kExprNop);
......
......@@ -22,6 +22,7 @@ TestingModuleBuilder::TestingModuleBuilder(
mem_start_(nullptr),
mem_size_(0),
interpreter_(nullptr),
execution_mode_(mode),
runtime_exception_support_(exception_support),
lower_simd_(mode == kExecuteSimdLowered) {
WasmJs::Install(isolate_, true);
......@@ -407,12 +408,14 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
FunctionBody func_body{function_->sig, function_->code.offset(),
func_wire_bytes.start(), func_wire_bytes.end()};
compiler::WasmCompilationUnit::CompilationMode comp_mode =
builder_->execution_mode() == WasmExecutionMode::kExecuteLiftoff
? compiler::WasmCompilationUnit::CompilationMode::kLiftoff
: compiler::WasmCompilationUnit::CompilationMode::kTurbofan;
compiler::WasmCompilationUnit unit(
isolate(), &module_env, func_body, func_name, function_->func_index,
CEntryStub(isolate(), 1).GetCode(),
compiler::WasmCompilationUnit::GetDefaultCompilationMode(),
isolate()->counters(), builder_->runtime_exception_support(),
builder_->lower_simd());
CEntryStub(isolate(), 1).GetCode(), comp_mode, isolate()->counters(),
builder_->runtime_exception_support(), builder_->lower_simd());
unit.ExecuteCompilation();
Handle<Code> code = unit.FinishCompilation(&thrower).ToHandleChecked();
CHECK(!thrower.error());
......
......@@ -49,7 +49,8 @@ constexpr uint32_t kMaxGlobalsSize = 128;
enum WasmExecutionMode {
kExecuteInterpreted,
kExecuteCompiled,
kExecuteTurbofan,
kExecuteLiftoff,
kExecuteSimdLowered
};
......@@ -206,6 +207,8 @@ class TestingModuleBuilder {
compiler::ModuleEnv CreateModuleEnv();
WasmExecutionMode execution_mode() const { return execution_mode_; }
compiler::RuntimeExceptionSupport runtime_exception_support() const {
return runtime_exception_support_;
}
......@@ -222,6 +225,7 @@ class TestingModuleBuilder {
std::vector<GlobalHandleAddress> signature_tables_;
V8_ALIGNED(16) byte globals_data_[kMaxGlobalsSize];
WasmInterpreter* interpreter_;
WasmExecutionMode execution_mode_;
Handle<WasmInstanceObject> instance_object_;
compiler::RuntimeExceptionSupport runtime_exception_support_;
bool lower_simd_;
......@@ -477,22 +481,29 @@ class WasmRunner : public WasmRunnerBase {
// A macro to define tests that run in different engine configurations.
#define WASM_EXEC_TEST(name) \
void RunWasm_##name(WasmExecutionMode execution_mode); \
TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
TEST(RunWasmTFCompiled_##name) { RunWasm_##name(kExecuteTurbofan); } \
TEST(RunWasmLiftoffCompiled_##name) { RunWasm_##name(kExecuteLiftoff); } \
TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
void RunWasm_##name(WasmExecutionMode execution_mode)
#define WASM_COMPILED_EXEC_TEST(name) \
void RunWasm_##name(WasmExecutionMode execution_mode); \
TEST(RunWasmTFCompiled_##name) { RunWasm_##name(kExecuteTurbofan); } \
TEST(RunWasmLiftoffCompiled_##name) { RunWasm_##name(kExecuteLiftoff); } \
void RunWasm_##name(WasmExecutionMode execution_mode)
#define WASM_EXEC_TEST_WITH_TRAP(name) \
void RunWasm_##name(WasmExecutionMode execution_mode); \
TEST(RunWasmCompiled_##name) { \
if (trap_handler::UseTrapHandler()) { \
return; \
} \
RunWasm_##name(kExecuteCompiled); \
if (trap_handler::UseTrapHandler()) return; \
RunWasm_##name(kExecuteTurbofan); \
} \
TEST(RunWasmLiftoffCompiled_##name) { \
if (trap_handler::UseTrapHandler()) return; \
RunWasm_##name(kExecuteLiftoff); \
} \
TEST(RunWasmInterpreted_##name) { \
if (trap_handler::UseTrapHandler()) { \
return; \
} \
if (trap_handler::UseTrapHandler()) return; \
RunWasm_##name(kExecuteInterpreted); \
} \
void RunWasm_##name(WasmExecutionMode execution_mode)
......
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