Commit 3d35921e authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm] Unify all enums representing execution tiers

R=mstarzinger@chromium.org

Change-Id: Iacdff28dd1383d77d7708de4ee22d9f2a77d872a
Reviewed-on: https://chromium-review.googlesource.com/1183440
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55284}
parent 2650fc33
......@@ -2556,6 +2556,7 @@ v8_source_set("v8_base") {
"src/wasm/wasm-serialization.h",
"src/wasm/wasm-text.cc",
"src/wasm/wasm-text.h",
"src/wasm/wasm-tier.h",
"src/wasm/wasm-value.h",
"src/zone/accounting-allocator.cc",
"src/zone/accounting-allocator.h",
......
......@@ -1040,10 +1040,10 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
// TODO(titzer): eliminate dependency on WasmModule definition here.
int func_start =
frame->wasm_instance()->module()->functions[func_index].code.offset();
wasm::ExecutionEngine eng = frame->wasm_code()->is_liftoff()
? wasm::ExecutionEngine::kLiftoff
: wasm::ExecutionEngine::kTurbofan;
wasm::TraceMemoryOperation(eng, info, func_index, pos - func_start,
wasm::ExecutionTier tier = frame->wasm_code()->is_liftoff()
? wasm::ExecutionTier::kBaseline
: wasm::ExecutionTier::kOptimized;
wasm::TraceMemoryOperation(tier, info, func_index, pos - func_start,
mem_start);
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -1055,7 +1055,7 @@ RUNTIME_FUNCTION(Runtime_WasmTierUpFunction) {
CONVERT_SMI_ARG_CHECKED(function_index, 1);
if (!isolate->wasm_engine()->CompileFunction(
isolate, instance->module_object()->native_module(), function_index,
wasm::WasmEngine::kOptimizedTier)) {
wasm::ExecutionTier::kOptimized)) {
return ReadOnlyRoots(isolate).exception();
}
return ReadOnlyRoots(isolate).undefined_value();
......
......@@ -16,13 +16,14 @@ namespace wasm {
namespace {
const char* GetCompilationModeAsString(
WasmCompilationUnit::CompilationMode mode) {
const char* GetExecutionTierAsString(ExecutionTier mode) {
switch (mode) {
case WasmCompilationUnit::CompilationMode::kLiftoff:
case ExecutionTier::kBaseline:
return "liftoff";
case WasmCompilationUnit::CompilationMode::kTurbofan:
case ExecutionTier::kOptimized:
return "turbofan";
case ExecutionTier::kInterpreter:
return "interpreter";
}
UNREACHABLE();
}
......@@ -37,9 +38,8 @@ void RecordStats(const WasmCode* code, Counters* counters) {
} // namespace
// static
WasmCompilationUnit::CompilationMode
WasmCompilationUnit::GetDefaultCompilationMode() {
return FLAG_liftoff ? CompilationMode::kLiftoff : CompilationMode::kTurbofan;
ExecutionTier WasmCompilationUnit::GetDefaultExecutionTier() {
return FLAG_liftoff ? ExecutionTier::kBaseline : ExecutionTier::kOptimized;
}
WasmCompilationUnit::WasmCompilationUnit(WasmEngine* wasm_engine,
......@@ -47,7 +47,7 @@ WasmCompilationUnit::WasmCompilationUnit(WasmEngine* wasm_engine,
NativeModule* native_module,
FunctionBody body, WasmName name,
int index, Counters* counters,
CompilationMode mode)
ExecutionTier mode)
: env_(env),
wasm_engine_(wasm_engine),
func_body_(body),
......@@ -61,10 +61,10 @@ WasmCompilationUnit::WasmCompilationUnit(WasmEngine* wasm_engine,
// Always disable Liftoff for asm.js, for two reasons:
// 1) asm-specific opcodes are not implemented, and
// 2) tier-up does not work with lazy compilation.
if (env->module->origin == kAsmJsOrigin) mode = CompilationMode::kTurbofan;
if (env->module->origin == kAsmJsOrigin) mode = ExecutionTier::kOptimized;
if (V8_UNLIKELY(FLAG_wasm_tier_mask_for_testing) && index < 32 &&
(FLAG_wasm_tier_mask_for_testing & (1 << index))) {
mode = CompilationMode::kTurbofan;
mode = ExecutionTier::kOptimized;
}
SwitchMode(mode);
}
......@@ -84,32 +84,34 @@ void WasmCompilationUnit::ExecuteCompilation() {
if (FLAG_trace_wasm_compiler) {
PrintF("Compiling wasm function %d with %s\n\n", func_index_,
GetCompilationModeAsString(mode_));
GetExecutionTierAsString(mode_));
}
switch (mode_) {
case WasmCompilationUnit::CompilationMode::kLiftoff:
case ExecutionTier::kBaseline:
if (liftoff_unit_->ExecuteCompilation()) break;
// Otherwise, fall back to turbofan.
SwitchMode(CompilationMode::kTurbofan);
SwitchMode(ExecutionTier::kOptimized);
V8_FALLTHROUGH;
case WasmCompilationUnit::CompilationMode::kTurbofan:
case ExecutionTier::kOptimized:
turbofan_unit_->ExecuteCompilation();
break;
case ExecutionTier::kInterpreter:
UNREACHABLE(); // TODO(titzer): compile interpreter entry stub.
}
}
WasmCode* WasmCompilationUnit::FinishCompilation(ErrorThrower* thrower) {
WasmCode* ret;
switch (mode_) {
case CompilationMode::kLiftoff:
case ExecutionTier::kBaseline:
ret = liftoff_unit_->FinishCompilation(thrower);
break;
case CompilationMode::kTurbofan:
case ExecutionTier::kOptimized:
ret = turbofan_unit_->FinishCompilation(thrower);
break;
default:
UNREACHABLE();
case ExecutionTier::kInterpreter:
UNREACHABLE(); // TODO(titzer): finish interpreter entry stub.
}
if (ret == nullptr) {
thrower->RuntimeError("Error finalizing code.");
......@@ -119,22 +121,24 @@ WasmCode* WasmCompilationUnit::FinishCompilation(ErrorThrower* thrower) {
return ret;
}
void WasmCompilationUnit::SwitchMode(CompilationMode new_mode) {
void WasmCompilationUnit::SwitchMode(ExecutionTier new_mode) {
// This method is being called in the constructor, where neither
// {liftoff_unit_} nor {turbofan_unit_} are set, or to switch mode from
// kLiftoff to kTurbofan, in which case {liftoff_unit_} is already set.
mode_ = new_mode;
switch (new_mode) {
case CompilationMode::kLiftoff:
case ExecutionTier::kBaseline:
DCHECK(!turbofan_unit_);
DCHECK(!liftoff_unit_);
liftoff_unit_.reset(new LiftoffCompilationUnit(this));
return;
case CompilationMode::kTurbofan:
case ExecutionTier::kOptimized:
DCHECK(!turbofan_unit_);
liftoff_unit_.reset();
turbofan_unit_.reset(new compiler::TurbofanWasmCompilationUnit(this));
return;
case ExecutionTier::kInterpreter:
UNREACHABLE(); // TODO(titzer): allow compiling interpreter entry stub.
}
UNREACHABLE();
}
......@@ -142,7 +146,7 @@ void WasmCompilationUnit::SwitchMode(CompilationMode new_mode) {
// static
WasmCode* WasmCompilationUnit::CompileWasmFunction(
NativeModule* native_module, ErrorThrower* thrower, Isolate* isolate,
ModuleEnv* env, const WasmFunction* function, CompilationMode mode) {
ModuleEnv* env, const WasmFunction* function, ExecutionTier mode) {
ModuleWireBytes wire_bytes(native_module->wire_bytes());
FunctionBody function_body{function->sig, function->code.offset(),
wire_bytes.start() + function->code.offset(),
......
......@@ -8,6 +8,7 @@
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-tier.h"
namespace v8 {
namespace internal {
......@@ -77,8 +78,7 @@ struct ModuleEnv {
class WasmCompilationUnit final {
public:
enum class CompilationMode : uint8_t { kLiftoff, kTurbofan };
static CompilationMode GetDefaultCompilationMode();
static ExecutionTier GetDefaultExecutionTier();
// If constructing from a background thread, pass in a Counters*, and ensure
// that the Counters live at least as long as this compilation unit (which
......@@ -87,7 +87,7 @@ class WasmCompilationUnit final {
// used by callers to pass Counters.
WasmCompilationUnit(WasmEngine* wasm_engine, ModuleEnv*, NativeModule*,
FunctionBody, WasmName, int index, Counters*,
CompilationMode = GetDefaultCompilationMode());
ExecutionTier = GetDefaultExecutionTier());
~WasmCompilationUnit();
......@@ -97,10 +97,10 @@ class WasmCompilationUnit final {
static WasmCode* CompileWasmFunction(
NativeModule* native_module, ErrorThrower* thrower, Isolate* isolate,
ModuleEnv* env, const WasmFunction* function,
CompilationMode = GetDefaultCompilationMode());
ExecutionTier = GetDefaultExecutionTier());
NativeModule* native_module() const { return native_module_; }
CompilationMode mode() const { return mode_; }
ExecutionTier mode() const { return mode_; }
private:
friend class LiftoffCompilationUnit;
......@@ -113,13 +113,13 @@ class WasmCompilationUnit final {
Counters* counters_;
int func_index_;
NativeModule* native_module_;
CompilationMode mode_;
ExecutionTier mode_;
// LiftoffCompilationUnit, set if {mode_ == kLiftoff}.
std::unique_ptr<LiftoffCompilationUnit> liftoff_unit_;
// TurbofanWasmCompilationUnit, set if {mode_ == kTurbofan}.
std::unique_ptr<compiler::TurbofanWasmCompilationUnit> turbofan_unit_;
void SwitchMode(CompilationMode new_mode);
void SwitchMode(ExecutionTier new_mode);
DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit);
};
......
......@@ -11,7 +11,7 @@ namespace v8 {
namespace internal {
namespace wasm {
void TraceMemoryOperation(ExecutionEngine engine, const MemoryTracingInfo* info,
void TraceMemoryOperation(ExecutionTier tier, const MemoryTracingInfo* info,
int func_index, int position, uint8_t* mem_start) {
EmbeddedVector<char, 64> value;
auto mem_rep = static_cast<MachineRepresentation>(info->mem_rep);
......@@ -35,14 +35,14 @@ void TraceMemoryOperation(ExecutionEngine engine, const MemoryTracingInfo* info,
SNPrintF(value, "???");
}
const char* eng = "?";
switch (engine) {
case ExecutionEngine::kTurbofan:
switch (tier) {
case ExecutionTier::kOptimized:
eng = "turbofan";
break;
case ExecutionEngine::kLiftoff:
case ExecutionTier::kBaseline:
eng = "liftoff";
break;
case ExecutionEngine::kInterpreter:
case ExecutionTier::kInterpreter:
eng = "interpreter";
break;
}
......
......@@ -8,13 +8,12 @@
#include <cstdint>
#include "src/machine-type.h"
#include "src/wasm/wasm-tier.h"
namespace v8 {
namespace internal {
namespace wasm {
enum class ExecutionEngine { kTurbofan, kLiftoff, kInterpreter };
// This struct is create in generated code, hence use low-level types.
struct MemoryTracingInfo {
uint32_t address;
......@@ -31,7 +30,7 @@ struct MemoryTracingInfo {
// Callback for tracing a memory operation for debugging.
// Triggered by --wasm-trace-memory.
void TraceMemoryOperation(ExecutionEngine, const MemoryTracingInfo* info,
void TraceMemoryOperation(ExecutionTier, const MemoryTracingInfo* info,
int func_index, int position, uint8_t* mem_start);
} // namespace wasm
......
......@@ -88,7 +88,7 @@ class CompilationState {
void OnError(ErrorThrower* thrower);
void OnFinishedUnit();
void ScheduleUnitForFinishing(std::unique_ptr<WasmCompilationUnit> unit,
WasmCompilationUnit::CompilationMode mode);
ExecutionTier mode);
void OnBackgroundTaskStopped();
void RestartBackgroundTasks(size_t max = std::numeric_limits<size_t>::max());
......@@ -450,17 +450,15 @@ class CompilationUnitBuilder {
Vector<const uint8_t> bytes, WasmName name) {
switch (compilation_state_->compile_mode()) {
case CompileMode::kTiering:
tiering_units_.emplace_back(
CreateUnit(function, buffer_offset, bytes, name,
WasmCompilationUnit::CompilationMode::kTurbofan));
baseline_units_.emplace_back(
CreateUnit(function, buffer_offset, bytes, name,
WasmCompilationUnit::CompilationMode::kLiftoff));
tiering_units_.emplace_back(CreateUnit(
function, buffer_offset, bytes, name, ExecutionTier::kOptimized));
baseline_units_.emplace_back(CreateUnit(
function, buffer_offset, bytes, name, ExecutionTier::kBaseline));
return;
case CompileMode::kRegular:
baseline_units_.emplace_back(
CreateUnit(function, buffer_offset, bytes, name,
WasmCompilationUnit::GetDefaultCompilationMode()));
WasmCompilationUnit::GetDefaultExecutionTier()));
return;
}
UNREACHABLE();
......@@ -479,10 +477,11 @@ class CompilationUnitBuilder {
}
private:
std::unique_ptr<WasmCompilationUnit> CreateUnit(
const WasmFunction* function, uint32_t buffer_offset,
Vector<const uint8_t> bytes, WasmName name,
WasmCompilationUnit::CompilationMode mode) {
std::unique_ptr<WasmCompilationUnit> CreateUnit(const WasmFunction* function,
uint32_t buffer_offset,
Vector<const uint8_t> bytes,
WasmName name,
ExecutionTier mode) {
return base::make_unique<WasmCompilationUnit>(
compilation_state_->wasm_engine(), compilation_state_->module_env(),
native_module_,
......@@ -513,7 +512,7 @@ bool FetchAndExecuteCompilationUnit(CompilationState* compilation_state) {
// to Turbofan if it cannot be compiled using Liftoff. This can be removed
// later as soon as Liftoff can compile any function. Then, we can directly
// access {unit->mode()} within {ScheduleUnitForFinishing()}.
WasmCompilationUnit::CompilationMode mode = unit->mode();
ExecutionTier mode = unit->mode();
unit->ExecuteCompilation();
compilation_state->ScheduleUnitForFinishing(std::move(unit), mode);
......@@ -2778,8 +2777,7 @@ void CompilationState::AddCompilationUnits(
if (compile_mode_ == CompileMode::kTiering) {
DCHECK_EQ(baseline_units.size(), tiering_units.size());
DCHECK_EQ(tiering_units.back()->mode(),
WasmCompilationUnit::CompilationMode::kTurbofan);
DCHECK_EQ(tiering_units.back()->mode(), ExecutionTier::kOptimized);
tiering_compilation_units_.insert(
tiering_compilation_units_.end(),
std::make_move_iterator(tiering_units.begin()),
......@@ -2866,11 +2864,10 @@ void CompilationState::OnFinishedUnit() {
}
void CompilationState::ScheduleUnitForFinishing(
std::unique_ptr<WasmCompilationUnit> unit,
WasmCompilationUnit::CompilationMode mode) {
std::unique_ptr<WasmCompilationUnit> unit, ExecutionTier mode) {
base::LockGuard<base::Mutex> guard(&mutex_);
if (compile_mode_ == CompileMode::kTiering &&
mode == WasmCompilationUnit::CompilationMode::kTurbofan) {
mode == ExecutionTier::kOptimized) {
tiering_finish_units_.push_back(std::move(unit));
} else {
baseline_finish_units_.push_back(std::move(unit));
......
......@@ -169,16 +169,12 @@ std::shared_ptr<StreamingDecoder> WasmEngine::StartStreamingCompilation(
}
bool WasmEngine::CompileFunction(Isolate* isolate, NativeModule* native_module,
uint32_t function_index,
CompilationTier tier) {
uint32_t function_index, ExecutionTier tier) {
ErrorThrower thrower(isolate, "Manually requested tier up");
WasmCompilationUnit::CompilationMode mode =
(tier == kBaselineTier) ? WasmCompilationUnit::CompilationMode::kLiftoff
: WasmCompilationUnit::CompilationMode::kTurbofan;
WasmCode* ret = WasmCompilationUnit::CompileWasmFunction(
native_module, &thrower, isolate,
GetModuleEnv(native_module->compilation_state()),
&native_module->module()->functions[function_index], mode);
&native_module->module()->functions[function_index], tier);
return ret != nullptr;
}
......
......@@ -9,6 +9,7 @@
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-memory.h"
#include "src/wasm/wasm-tier.h"
#include "src/zone/accounting-allocator.h"
namespace v8 {
......@@ -94,9 +95,8 @@ class V8_EXPORT_PRIVATE WasmEngine {
// Compiles the function with the given index at a specific compilation tier
// and returns true on success, false (and pending exception) otherwise. This
// is mostly used for testing to force a function into a specific tier.
enum CompilationTier { kBaselineTier, kOptimizedTier };
bool CompileFunction(Isolate* isolate, NativeModule* native_module,
uint32_t function_index, CompilationTier tier);
uint32_t function_index, ExecutionTier tier);
// Exports the sharable parts of the given module object so that they can be
// transferred to a different Context/Isolate using the same engine.
......
......@@ -1428,7 +1428,7 @@ class ThreadImpl {
if (FLAG_wasm_trace_memory) {
MemoryTracingInfo info(imm.offset + index, false, rep);
TraceMemoryOperation(ExecutionEngine::kInterpreter, &info,
TraceMemoryOperation(ExecutionTier::kInterpreter, &info,
code->function->func_index, static_cast<int>(pc),
instance_object_->memory_start());
}
......@@ -1454,7 +1454,7 @@ class ThreadImpl {
if (FLAG_wasm_trace_memory) {
MemoryTracingInfo info(imm.offset + index, true, rep);
TraceMemoryOperation(ExecutionEngine::kInterpreter, &info,
TraceMemoryOperation(ExecutionTier::kInterpreter, &info,
code->function->func_index, static_cast<int>(pc),
instance_object_->memory_start());
}
......
// Copyright 2018 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_WASM_WASM_TIER_H_
#define V8_WASM_WASM_TIER_H_
namespace v8 {
namespace internal {
namespace wasm {
// All the tiers of WASM execution.
enum class ExecutionTier {
kInterpreter, // interpreter (used to provide debugging services).
kBaseline, // Liftoff.
kOptimized // TurboFan.
};
} // namespace wasm
} // namespace internal
} // namespace v8
#endif // V8_WASM_WASM_TIER_H_
......@@ -30,7 +30,7 @@ class CWasmEntryArgTester {
public:
CWasmEntryArgTester(std::initializer_list<uint8_t> wasm_function_bytes,
std::function<ReturnType(Args...)> expected_fn)
: runner_(kExecuteTurbofan),
: runner_(ExecutionTier::kOptimized),
isolate_(runner_.main_isolate()),
expected_fn_(expected_fn),
sig_(runner_.template CreateSig<ReturnType, Args...>()) {
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ namespace internal {
namespace wasm {
WASM_EXEC_TEST(Int32AsmjsDivS) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min();
......@@ -32,7 +32,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS) {
}
WASM_EXEC_TEST(Int32AsmjsRemS) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min();
......@@ -44,7 +44,7 @@ WASM_EXEC_TEST(Int32AsmjsRemS) {
}
WASM_EXEC_TEST(Int32AsmjsDivU) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min();
......@@ -56,7 +56,7 @@ WASM_EXEC_TEST(Int32AsmjsDivU) {
}
WASM_EXEC_TEST(Int32AsmjsRemU) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min();
......@@ -68,7 +68,7 @@ WASM_EXEC_TEST(Int32AsmjsRemU) {
}
WASM_EXEC_TEST(I32AsmjsSConvertF32) {
WasmRunner<int32_t, float> r(execution_mode);
WasmRunner<int32_t, float> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
......@@ -79,7 +79,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) {
}
WASM_EXEC_TEST(I32AsmjsSConvertF64) {
WasmRunner<int32_t, double> r(execution_mode);
WasmRunner<int32_t, double> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
......@@ -90,7 +90,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) {
}
WASM_EXEC_TEST(I32AsmjsUConvertF32) {
WasmRunner<uint32_t, float> r(execution_mode);
WasmRunner<uint32_t, float> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
......@@ -101,7 +101,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) {
}
WASM_EXEC_TEST(I32AsmjsUConvertF64) {
WasmRunner<uint32_t, double> r(execution_mode);
WasmRunner<uint32_t, double> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
......@@ -112,7 +112,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) {
}
WASM_EXEC_TEST(LoadMemI32_oob_asm) {
WasmRunner<int32_t, uint32_t> r(execution_mode);
WasmRunner<int32_t, uint32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
r.builder().RandomizeMemory(1112);
......@@ -132,7 +132,7 @@ WASM_EXEC_TEST(LoadMemI32_oob_asm) {
}
WASM_EXEC_TEST(LoadMemF32_oob_asm) {
WasmRunner<float, uint32_t> r(execution_mode);
WasmRunner<float, uint32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
float* memory = r.builder().AddMemoryElems<float>(8);
r.builder().RandomizeMemory(1112);
......@@ -152,7 +152,7 @@ WASM_EXEC_TEST(LoadMemF32_oob_asm) {
}
WASM_EXEC_TEST(LoadMemF64_oob_asm) {
WasmRunner<double, uint32_t> r(execution_mode);
WasmRunner<double, uint32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
double* memory = r.builder().AddMemoryElems<double>(8);
r.builder().RandomizeMemory(1112);
......@@ -174,7 +174,7 @@ WASM_EXEC_TEST(LoadMemF64_oob_asm) {
}
WASM_EXEC_TEST(StoreMemI32_oob_asm) {
WasmRunner<int32_t, uint32_t, uint32_t> r(execution_mode);
WasmRunner<int32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().ChangeOriginToAsmjs();
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
r.builder().RandomizeMemory(1112);
......
......@@ -10,10 +10,10 @@ namespace internal {
namespace wasm {
namespace test_run_wasm_atomics {
void RunU32BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op,
void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
Uint32BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
r.builder().SetHasSharedMemory();
......@@ -33,28 +33,28 @@ void RunU32BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op,
}
WASM_EXEC_TEST(I32AtomicAdd) {
RunU32BinOp(execution_mode, kExprI32AtomicAdd, Add);
RunU32BinOp(execution_tier, kExprI32AtomicAdd, Add);
}
WASM_EXEC_TEST(I32AtomicSub) {
RunU32BinOp(execution_mode, kExprI32AtomicSub, Sub);
RunU32BinOp(execution_tier, kExprI32AtomicSub, Sub);
}
WASM_EXEC_TEST(I32AtomicAnd) {
RunU32BinOp(execution_mode, kExprI32AtomicAnd, And);
RunU32BinOp(execution_tier, kExprI32AtomicAnd, And);
}
WASM_EXEC_TEST(I32AtomicOr) {
RunU32BinOp(execution_mode, kExprI32AtomicOr, Or);
RunU32BinOp(execution_tier, kExprI32AtomicOr, Or);
}
WASM_EXEC_TEST(I32AtomicXor) {
RunU32BinOp(execution_mode, kExprI32AtomicXor, Xor);
RunU32BinOp(execution_tier, kExprI32AtomicXor, Xor);
}
WASM_EXEC_TEST(I32AtomicExchange) {
RunU32BinOp(execution_mode, kExprI32AtomicExchange, Exchange);
RunU32BinOp(execution_tier, kExprI32AtomicExchange, Exchange);
}
void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op,
void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op,
Uint16BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(mode);
WasmRunner<uint32_t, uint32_t> r(tier);
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
......@@ -74,28 +74,28 @@ void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op,
}
WASM_EXEC_TEST(I32AtomicAdd16U) {
RunU16BinOp(execution_mode, kExprI32AtomicAdd16U, Add);
RunU16BinOp(execution_tier, kExprI32AtomicAdd16U, Add);
}
WASM_EXEC_TEST(I32AtomicSub16U) {
RunU16BinOp(execution_mode, kExprI32AtomicSub16U, Sub);
RunU16BinOp(execution_tier, kExprI32AtomicSub16U, Sub);
}
WASM_EXEC_TEST(I32AtomicAnd16U) {
RunU16BinOp(execution_mode, kExprI32AtomicAnd16U, And);
RunU16BinOp(execution_tier, kExprI32AtomicAnd16U, And);
}
WASM_EXEC_TEST(I32AtomicOr16U) {
RunU16BinOp(execution_mode, kExprI32AtomicOr16U, Or);
RunU16BinOp(execution_tier, kExprI32AtomicOr16U, Or);
}
WASM_EXEC_TEST(I32AtomicXor16U) {
RunU16BinOp(execution_mode, kExprI32AtomicXor16U, Xor);
RunU16BinOp(execution_tier, kExprI32AtomicXor16U, Xor);
}
WASM_EXEC_TEST(I32AtomicExchange16U) {
RunU16BinOp(execution_mode, kExprI32AtomicExchange16U, Exchange);
RunU16BinOp(execution_tier, kExprI32AtomicExchange16U, Exchange);
}
void RunU8BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op,
void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
Uint8BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
......@@ -114,27 +114,27 @@ void RunU8BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op,
}
WASM_EXEC_TEST(I32AtomicAdd8U) {
RunU8BinOp(execution_mode, kExprI32AtomicAdd8U, Add);
RunU8BinOp(execution_tier, kExprI32AtomicAdd8U, Add);
}
WASM_EXEC_TEST(I32AtomicSub8U) {
RunU8BinOp(execution_mode, kExprI32AtomicSub8U, Sub);
RunU8BinOp(execution_tier, kExprI32AtomicSub8U, Sub);
}
WASM_EXEC_TEST(I32AtomicAnd8U) {
RunU8BinOp(execution_mode, kExprI32AtomicAnd8U, And);
RunU8BinOp(execution_tier, kExprI32AtomicAnd8U, And);
}
WASM_EXEC_TEST(I32AtomicOr8U) {
RunU8BinOp(execution_mode, kExprI32AtomicOr8U, Or);
RunU8BinOp(execution_tier, kExprI32AtomicOr8U, Or);
}
WASM_EXEC_TEST(I32AtomicXor8U) {
RunU8BinOp(execution_mode, kExprI32AtomicXor8U, Xor);
RunU8BinOp(execution_tier, kExprI32AtomicXor8U, Xor);
}
WASM_EXEC_TEST(I32AtomicExchange8U) {
RunU8BinOp(execution_mode, kExprI32AtomicExchange8U, Exchange);
RunU8BinOp(execution_tier, kExprI32AtomicExchange8U, Exchange);
}
WASM_EXEC_TEST(I32AtomicCompareExchange) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
......@@ -155,7 +155,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange) {
WASM_EXEC_TEST(I32AtomicCompareExchange16U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
......@@ -177,7 +177,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange16U) {
WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r,
......@@ -198,7 +198,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
WASM_EXEC_TEST(I32AtomicLoad) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(execution_mode);
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
......@@ -214,7 +214,7 @@ WASM_EXEC_TEST(I32AtomicLoad) {
WASM_EXEC_TEST(I32AtomicLoad16U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(execution_mode);
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
......@@ -230,7 +230,7 @@ WASM_EXEC_TEST(I32AtomicLoad16U) {
WASM_EXEC_TEST(I32AtomicLoad8U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(execution_mode);
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
......@@ -245,7 +245,7 @@ WASM_EXEC_TEST(I32AtomicLoad8U) {
WASM_EXEC_TEST(I32AtomicStoreLoad) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
......@@ -265,7 +265,7 @@ WASM_EXEC_TEST(I32AtomicStoreLoad) {
WASM_EXEC_TEST(I32AtomicStoreLoad16U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
......@@ -286,7 +286,7 @@ WASM_EXEC_TEST(I32AtomicStoreLoad16U) {
WASM_EXEC_TEST(I32AtomicStoreLoad8U) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
......@@ -305,7 +305,7 @@ WASM_EXEC_TEST(I32AtomicStoreLoad8U) {
WASM_EXEC_TEST(I32AtomicStoreParameter) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(execution_mode);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
r.builder().SetHasSharedMemory();
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ namespace wasm {
namespace test_run_wasm_interpreter {
TEST(Run_WasmInt8Const_i) {
WasmRunner<int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t> r(ExecutionTier::kInterpreter);
const byte kExpectedValue = 109;
// return(kExpectedValue)
BUILD(r, WASM_I32V_2(kExpectedValue));
......@@ -30,14 +30,14 @@ TEST(Run_WasmInt8Const_i) {
}
TEST(Run_WasmIfElse) {
WasmRunner<int32_t, int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, int32_t> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I32V_1(9), WASM_I32V_1(10)));
CHECK_EQ(10, r.Call(0));
CHECK_EQ(9, r.Call(1));
}
TEST(Run_WasmIfReturn) {
WasmRunner<int32_t, int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, int32_t> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_RETURN1(WASM_I32V_2(77))),
WASM_I32V_2(65));
CHECK_EQ(65, r.Call(0));
......@@ -53,7 +53,7 @@ TEST(Run_WasmNopsN) {
code[nops] = kExprI32Const;
code[nops + 1] = expected;
WasmRunner<int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + nops + 2);
CHECK_EQ(expected, r.Call());
}
......@@ -76,7 +76,7 @@ TEST(Run_WasmConstsN) {
}
}
WasmRunner<int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + (count * 3));
CHECK_EQ(expected, r.Call());
}
......@@ -95,7 +95,7 @@ TEST(Run_WasmBlocksN) {
code[2 + nops + 1] = expected;
code[2 + nops + 2] = kExprEnd;
WasmRunner<int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + nops + kExtra);
CHECK_EQ(expected, r.Call());
}
......@@ -120,7 +120,7 @@ TEST(Run_WasmBlockBreakN) {
code[2 + index + 2] = kExprBr;
code[2 + index + 3] = 0;
WasmRunner<int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + kMaxNops + kExtra);
CHECK_EQ(expected, r.Call());
}
......@@ -128,7 +128,7 @@ TEST(Run_WasmBlockBreakN) {
}
TEST(Run_Wasm_nested_ifs_i) {
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, int32_t, int32_t> r(ExecutionTier::kInterpreter);
BUILD(
r,
......@@ -178,7 +178,7 @@ TEST(Breakpoint_I32Add) {
Find(code, sizeof(code), kNumBreakpoints, kExprGetLocal, kExprGetLocal,
kExprI32Add);
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + arraysize(code));
......@@ -217,7 +217,7 @@ TEST(Step_I32Mul) {
static const int kTraceLength = 4;
byte code[] = {WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + arraysize(code));
......@@ -255,7 +255,7 @@ TEST(Breakpoint_I32And_disable) {
std::unique_ptr<int[]> offsets =
Find(code, sizeof(code), kNumBreakpoints, kExprI32And);
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.Build(code, code + arraysize(code));
......@@ -293,14 +293,14 @@ TEST(Breakpoint_I32And_disable) {
TEST(GrowMemory) {
{
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
r.builder().SetMaxMemPages(10);
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
CHECK_EQ(1, r.Call(1));
}
{
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
r.builder().SetMaxMemPages(10);
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
......@@ -311,7 +311,7 @@ TEST(GrowMemory) {
TEST(GrowMemoryPreservesData) {
int32_t index = 16;
int32_t value = 2335;
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
WASM_I32V(value)),
......@@ -322,7 +322,7 @@ TEST(GrowMemoryPreservesData) {
TEST(GrowMemoryInvalidSize) {
// Grow memory by an invalid amount without initial memory.
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
CHECK_EQ(-1, r.Call(1048575));
......@@ -330,7 +330,7 @@ TEST(GrowMemoryInvalidSize) {
TEST(TestPossibleNondeterminism) {
{
WasmRunner<int32_t, float> r(kExecuteInterpreter);
WasmRunner<int32_t, float> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_I32_REINTERPRET_F32(WASM_GET_LOCAL(0)));
r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
......@@ -338,7 +338,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(!r.possible_nondeterminism());
}
{
WasmRunner<int64_t, double> r(kExecuteInterpreter);
WasmRunner<int64_t, double> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_I64_REINTERPRET_F64(WASM_GET_LOCAL(0)));
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
......@@ -346,7 +346,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(!r.possible_nondeterminism());
}
{
WasmRunner<float, float> r(kExecuteInterpreter);
WasmRunner<float, float> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F32_COPYSIGN(WASM_F32(42.0f), WASM_GET_LOCAL(0)));
r.Call(16.0f);
CHECK(!r.possible_nondeterminism());
......@@ -354,7 +354,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(!r.possible_nondeterminism());
}
{
WasmRunner<double, double> r(kExecuteInterpreter);
WasmRunner<double, double> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F64_COPYSIGN(WASM_F64(42.0), WASM_GET_LOCAL(0)));
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
......@@ -363,7 +363,7 @@ TEST(TestPossibleNondeterminism) {
}
{
int32_t index = 16;
WasmRunner<int32_t, float> r(kExecuteInterpreter);
WasmRunner<int32_t, float> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index),
WASM_GET_LOCAL(0)),
......@@ -375,7 +375,7 @@ TEST(TestPossibleNondeterminism) {
}
{
int32_t index = 16;
WasmRunner<int32_t, double> r(kExecuteInterpreter);
WasmRunner<int32_t, double> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index),
WASM_GET_LOCAL(0)),
......@@ -386,7 +386,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(!r.possible_nondeterminism());
}
{
WasmRunner<float, float> r(kExecuteInterpreter);
WasmRunner<float, float> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
......@@ -394,7 +394,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(r.possible_nondeterminism());
}
{
WasmRunner<double, double> r(kExecuteInterpreter);
WasmRunner<double, double> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
......@@ -402,7 +402,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(r.possible_nondeterminism());
}
{
WasmRunner<int32_t, float> r(kExecuteInterpreter);
WasmRunner<int32_t, float> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
......@@ -410,7 +410,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(!r.possible_nondeterminism());
}
{
WasmRunner<int32_t, double> r(kExecuteInterpreter);
WasmRunner<int32_t, double> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
......@@ -418,7 +418,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(!r.possible_nondeterminism());
}
{
WasmRunner<float, float> r(kExecuteInterpreter);
WasmRunner<float, float> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
......@@ -426,7 +426,7 @@ TEST(TestPossibleNondeterminism) {
CHECK(r.possible_nondeterminism());
}
{
WasmRunner<double, double> r(kExecuteInterpreter);
WasmRunner<double, double> r(ExecutionTier::kInterpreter);
BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
......@@ -436,7 +436,7 @@ TEST(TestPossibleNondeterminism) {
}
TEST(WasmInterpreterActivations) {
WasmRunner<void> r(kExecuteInterpreter);
WasmRunner<void> r(ExecutionTier::kInterpreter);
Isolate* isolate = r.main_isolate();
BUILD(r, WASM_NOP);
......@@ -466,7 +466,7 @@ TEST(WasmInterpreterActivations) {
}
TEST(InterpreterLoadWithoutMemory) {
WasmRunner<int32_t, int32_t> r(kExecuteInterpreter);
WasmRunner<int32_t, int32_t> r(ExecutionTier::kInterpreter);
r.builder().AddMemory(0);
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
CHECK_TRAP32(r.Call(0));
......
This diff is collapsed.
......@@ -13,7 +13,7 @@ namespace wasm {
// TODO(gdeepti): Enable tests to run in the interpreter.
WASM_EXEC_TEST(I32SExtendI8) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int32_t, int32_t> r(execution_mode);
WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_I32_SIGN_EXT_I8(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
......@@ -24,7 +24,7 @@ WASM_EXEC_TEST(I32SExtendI8) {
WASM_EXEC_TEST(I32SExtendI16) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int32_t, int32_t> r(execution_mode);
WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_I32_SIGN_EXT_I16(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
......@@ -35,7 +35,7 @@ WASM_EXEC_TEST(I32SExtendI16) {
WASM_EXEC_TEST(I64SExtendI8) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int64_t, int64_t> r(execution_mode);
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I8(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
......@@ -46,7 +46,7 @@ WASM_EXEC_TEST(I64SExtendI8) {
WASM_EXEC_TEST(I64SExtendI16) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int64_t, int64_t> r(execution_mode);
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I16(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
......@@ -57,7 +57,7 @@ WASM_EXEC_TEST(I64SExtendI16) {
WASM_EXEC_TEST(I64SExtendI32) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int64_t, int64_t> r(execution_mode);
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I32(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
......
This diff is collapsed.
This diff is collapsed.
......@@ -242,7 +242,7 @@ std::vector<WasmValue> wasmVec(Args... args) {
} // namespace
WASM_COMPILED_EXEC_TEST(WasmCollectPossibleBreakpoints) {
WasmRunner<int> runner(execution_mode);
WasmRunner<int> runner(execution_tier);
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE));
......@@ -269,7 +269,7 @@ WASM_COMPILED_EXEC_TEST(WasmCollectPossibleBreakpoints) {
}
WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) {
WasmRunner<int> runner(execution_mode);
WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
......@@ -290,7 +290,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) {
}
WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) {
WasmRunner<int> runner(execution_mode);
WasmRunner<int> runner(execution_tier);
BUILD(runner, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
Isolate* isolate = runner.main_isolate();
......@@ -317,7 +317,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) {
}
WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) {
WasmRunner<int, int> runner(execution_mode);
WasmRunner<int, int> runner(execution_tier);
WasmFunctionCompiler& f2 = runner.NewFunction<void>();
f2.AllocateLocal(kWasmI32);
......@@ -357,7 +357,7 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) {
}
WASM_COMPILED_EXEC_TEST(WasmGetLocalsAndStack) {
WasmRunner<void, int> runner(execution_mode);
WasmRunner<void, int> runner(execution_tier);
runner.AllocateLocal(kWasmI64);
runner.AllocateLocal(kWasmF32);
runner.AllocateLocal(kWasmF64);
......
......@@ -91,7 +91,7 @@ static ArgPassingHelper<T> GetHelper(
// Pass int32_t, return int32_t.
TEST(TestArgumentPassing_int32) {
WasmRunner<int32_t, int32_t> runner(kExecuteTurbofan);
WasmRunner<int32_t, int32_t> runner(ExecutionTier::kOptimized);
WasmFunctionCompiler& f2 = runner.NewFunction<int32_t, int32_t>();
auto helper = GetHelper(
......@@ -107,7 +107,7 @@ TEST(TestArgumentPassing_int32) {
// Pass int64_t, return double.
TEST(TestArgumentPassing_double_int64) {
WasmRunner<double, int32_t, int32_t> runner(kExecuteTurbofan);
WasmRunner<double, int32_t, int32_t> runner(ExecutionTier::kOptimized);
WasmFunctionCompiler& f2 = runner.NewFunction<double, int64_t>();
auto helper = GetHelper(
......@@ -140,7 +140,7 @@ TEST(TestArgumentPassing_double_int64) {
// Pass double, return int64_t.
TEST(TestArgumentPassing_int64_double) {
// Outer function still returns double.
WasmRunner<double, double> runner(kExecuteTurbofan);
WasmRunner<double, double> runner(ExecutionTier::kOptimized);
WasmFunctionCompiler& f2 = runner.NewFunction<int64_t, double>();
auto helper = GetHelper(
......@@ -159,7 +159,7 @@ TEST(TestArgumentPassing_int64_double) {
// Pass float, return double.
TEST(TestArgumentPassing_float_double) {
WasmRunner<double, float> runner(kExecuteTurbofan);
WasmRunner<double, float> runner(ExecutionTier::kOptimized);
WasmFunctionCompiler& f2 = runner.NewFunction<double, float>();
auto helper = GetHelper(
......@@ -177,7 +177,7 @@ TEST(TestArgumentPassing_float_double) {
// Pass two doubles, return double.
TEST(TestArgumentPassing_double_double) {
WasmRunner<double, double, double> runner(kExecuteTurbofan);
WasmRunner<double, double, double> runner(ExecutionTier::kOptimized);
WasmFunctionCompiler& f2 = runner.NewFunction<double, double, double>();
auto helper = GetHelper(runner, f2,
......@@ -197,7 +197,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(
kExecuteTurbofan);
ExecutionTier::kOptimized);
WasmFunctionCompiler& f2 =
runner.NewFunction<double, int32_t, int64_t, float, double>();
......
......@@ -355,8 +355,7 @@ TEST(SharedEngineRunThreadedTierUp) {
WasmCompilationUnit::CompileWasmFunction(
module.get(), &thrower, isolate.isolate(),
GetModuleEnv(module->compilation_state()),
&module->module()->functions[0],
WasmCompilationUnit::CompilationMode::kTurbofan);
&module->module()->functions[0], ExecutionTier::kOptimized);
CHECK_EQ(23, isolate.Run(instance));
});
for (auto& thread : threads) thread.Start();
......
......@@ -111,7 +111,7 @@ WASM_EXEC_TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
*v8::Local<v8::Function>::Cast(CompileRun(source))));
ManuallyImportedJSFunction import = {sigs.v_v(), js_function};
uint32_t js_throwing_index = 0;
WasmRunner<void> r(execution_mode, &import);
WasmRunner<void> r(execution_tier, &import);
// Add a nop such that we don't always get position 1.
BUILD(r, WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index));
......@@ -157,7 +157,7 @@ WASM_EXEC_TEST(CollectDetailedWasmStack_WasmError) {
int unreachable_pos = 1 << (8 * pos_shift);
TestSignatures sigs;
// Create a WasmRunner with stack checks and traps enabled.
WasmRunner<int> r(execution_mode, 0, "main", kRuntimeExceptionSupport);
WasmRunner<int> r(execution_tier, 0, "main", kRuntimeExceptionSupport);
std::vector<byte> code(unreachable_pos + 1, kExprNop);
code[unreachable_pos] = kExprUnreachable;
......
......@@ -69,7 +69,7 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc,
// Trigger a trap for executing unreachable.
WASM_EXEC_TEST(Unreachable) {
// Create a WasmRunner with stack checks and traps enabled.
WasmRunner<void> r(execution_mode, 0, "main", kRuntimeExceptionSupport);
WasmRunner<void> r(execution_tier, 0, "main", kRuntimeExceptionSupport);
TestSignatures sigs;
BUILD(r, WASM_UNREACHABLE);
......@@ -103,7 +103,7 @@ WASM_EXEC_TEST(Unreachable) {
// Trigger a trap for loading from out-of-bounds.
WASM_EXEC_TEST(IllegalLoad) {
WasmRunner<void> r(execution_mode, 0, "main", kRuntimeExceptionSupport);
WasmRunner<void> r(execution_tier, 0, "main", kRuntimeExceptionSupport);
TestSignatures sigs;
r.builder().AddMemory(0L);
......
......@@ -14,14 +14,13 @@ namespace internal {
namespace wasm {
TestingModuleBuilder::TestingModuleBuilder(
Zone* zone, ManuallyImportedJSFunction* maybe_import,
WasmExecutionMode mode, RuntimeExceptionSupport exception_support,
LowerSimd lower_simd)
Zone* zone, ManuallyImportedJSFunction* maybe_import, ExecutionTier tier,
RuntimeExceptionSupport exception_support, LowerSimd lower_simd)
: test_module_(std::make_shared<WasmModule>()),
test_module_ptr_(test_module_.get()),
isolate_(CcTest::InitIsolateOnce()),
enabled_features_(WasmFeaturesFromIsolate(isolate_)),
execution_mode_(mode),
execution_tier_(tier),
runtime_exception_support_(exception_support),
lower_simd_(lower_simd) {
WasmJs::Install(isolate_, true);
......@@ -54,7 +53,7 @@ TestingModuleBuilder::TestingModuleBuilder(
.set_wasm_to_js(*maybe_import->js_function, wasm_to_js_wrapper);
}
if (mode == kExecuteInterpreter) {
if (tier == ExecutionTier::kInterpreter) {
interpreter_ = WasmDebugInfo::SetupForTesting(instance_object_);
}
}
......@@ -403,6 +402,13 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
interpreter_->SetFunctionCodeForTesting(function_, start, end);
}
// TODO(wasm): tests that go through JS depend on having a compiled version
// of each function, even if the execution tier is the interpreter. Fix.
auto tier = builder_->execution_tier();
if (tier == ExecutionTier::kInterpreter) {
tier = ExecutionTier::kOptimized;
}
Vector<const uint8_t> wire_bytes = builder_->instance_object()
->module_object()
->native_module()
......@@ -421,15 +427,11 @@ 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()};
WasmCompilationUnit::CompilationMode comp_mode =
builder_->execution_mode() == WasmExecutionMode::kExecuteLiftoff
? WasmCompilationUnit::CompilationMode::kLiftoff
: WasmCompilationUnit::CompilationMode::kTurbofan;
NativeModule* native_module =
builder_->instance_object()->module_object()->native_module();
WasmCompilationUnit unit(isolate()->wasm_engine(), &module_env, native_module,
func_body, func_name, function_->func_index,
isolate()->counters(), comp_mode);
isolate()->counters(), tier);
unit.ExecuteCompilation();
WasmCode* wasm_code = unit.FinishCompilation(&thrower);
if (WasmCode::ShouldBeLogged(isolate())) {
......
......@@ -33,6 +33,7 @@
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-tier.h"
#include "src/zone/accounting-allocator.h"
#include "src/zone/zone.h"
......@@ -48,12 +49,6 @@ namespace wasm {
constexpr uint32_t kMaxFunctions = 10;
constexpr uint32_t kMaxGlobalsSize = 128;
enum WasmExecutionMode {
kExecuteInterpreter,
kExecuteTurbofan,
kExecuteLiftoff
};
using compiler::CallDescriptor;
using compiler::MachineTypeForC;
using compiler::Node;
......@@ -88,7 +83,7 @@ struct ManuallyImportedJSFunction {
// the interpreter.
class TestingModuleBuilder {
public:
TestingModuleBuilder(Zone*, ManuallyImportedJSFunction*, WasmExecutionMode,
TestingModuleBuilder(Zone*, ManuallyImportedJSFunction*, ExecutionTier,
RuntimeExceptionSupport, LowerSimd);
void ChangeOriginToAsmjs() { test_module_->origin = kAsmJsOrigin; }
......@@ -215,7 +210,7 @@ class TestingModuleBuilder {
ModuleEnv CreateModuleEnv();
WasmExecutionMode execution_mode() const { return execution_mode_; }
ExecutionTier execution_tier() const { return execution_tier_; }
RuntimeExceptionSupport runtime_exception_support() const {
return runtime_exception_support_;
......@@ -231,7 +226,7 @@ class TestingModuleBuilder {
uint32_t mem_size_ = 0;
V8_ALIGNED(16) byte globals_data_[kMaxGlobalsSize];
WasmInterpreter* interpreter_ = nullptr;
WasmExecutionMode execution_mode_;
ExecutionTier execution_tier_;
Handle<WasmInstanceObject> instance_object_;
NativeModule* native_module_ = nullptr;
bool linked_ = false;
......@@ -346,11 +341,11 @@ class WasmFunctionCompiler : public compiler::GraphAndBuilders {
class WasmRunnerBase : public HandleAndZoneScope {
public:
WasmRunnerBase(ManuallyImportedJSFunction* maybe_import,
WasmExecutionMode execution_mode, int num_params,
ExecutionTier execution_tier, int num_params,
RuntimeExceptionSupport runtime_exception_support,
LowerSimd lower_simd)
: zone_(&allocator_, ZONE_NAME),
builder_(&zone_, maybe_import, execution_mode,
builder_(&zone_, maybe_import, execution_tier,
runtime_exception_support, lower_simd),
wrapper_(&zone_, num_params) {}
......@@ -427,13 +422,13 @@ class WasmRunnerBase : public HandleAndZoneScope {
template <typename ReturnType, typename... ParamTypes>
class WasmRunner : public WasmRunnerBase {
public:
WasmRunner(WasmExecutionMode execution_mode,
WasmRunner(ExecutionTier execution_tier,
ManuallyImportedJSFunction* maybe_import = nullptr,
const char* main_fn_name = "main",
RuntimeExceptionSupport runtime_exception_support =
kNoRuntimeExceptionSupport,
LowerSimd lower_simd = kNoLowerSimd)
: WasmRunnerBase(maybe_import, execution_mode, sizeof...(ParamTypes),
: WasmRunnerBase(maybe_import, execution_tier, sizeof...(ParamTypes),
runtime_exception_support, lower_simd) {
NewFunction<ReturnType, ParamTypes...>(main_fn_name);
if (!interpret()) {
......@@ -441,8 +436,8 @@ class WasmRunner : public WasmRunnerBase {
}
}
WasmRunner(WasmExecutionMode execution_mode, LowerSimd lower_simd)
: WasmRunner(execution_mode, nullptr, "main", kNoRuntimeExceptionSupport,
WasmRunner(ExecutionTier execution_tier, LowerSimd lower_simd)
: WasmRunner(execution_tier, nullptr, "main", kNoRuntimeExceptionSupport,
lower_simd) {}
ReturnType Call(ParamTypes... p) {
......@@ -500,18 +495,20 @@ 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(RunWasmTurbofan_##name) { RunWasm_##name(kExecuteTurbofan); } \
TEST(RunWasmLiftoff_##name) { RunWasm_##name(kExecuteLiftoff); } \
TEST(RunWasmInterpreter_##name) { RunWasm_##name(kExecuteInterpreter); } \
void RunWasm_##name(WasmExecutionMode execution_mode)
#define WASM_COMPILED_EXEC_TEST(name) \
void RunWasm_##name(WasmExecutionMode execution_mode); \
TEST(RunWasmTurbofan_##name) { RunWasm_##name(kExecuteTurbofan); } \
TEST(RunWasmLiftoff_##name) { RunWasm_##name(kExecuteLiftoff); } \
void RunWasm_##name(WasmExecutionMode execution_mode)
#define WASM_EXEC_TEST(name) \
void RunWasm_##name(ExecutionTier execution_tier); \
TEST(RunWasmTurbofan_##name) { RunWasm_##name(ExecutionTier::kOptimized); } \
TEST(RunWasmLiftoff_##name) { RunWasm_##name(ExecutionTier::kBaseline); } \
TEST(RunWasmInterpreter_##name) { \
RunWasm_##name(ExecutionTier::kInterpreter); \
} \
void RunWasm_##name(ExecutionTier execution_tier)
#define WASM_COMPILED_EXEC_TEST(name) \
void RunWasm_##name(ExecutionTier execution_tier); \
TEST(RunWasmTurbofan_##name) { RunWasm_##name(ExecutionTier::kOptimized); } \
TEST(RunWasmLiftoff_##name) { RunWasm_##name(ExecutionTier::kBaseline); } \
void RunWasm_##name(ExecutionTier execution_tier)
} // namespace wasm
} // namespace internal
......
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