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

[wasm] Rename TestingModule to TestingModuleBuilder.

This is a followup to moving the ModuleEnv to the compiler directory and
making it immutable.

R=mtrofin@chromium.org, ahaas@chromium.org

Bug: 
Change-Id: I0f5ec1b697bdcfad0b4dc2bca577cc0f40de8dc0
Reviewed-on: https://chromium-review.googlesource.com/616762
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47419}
parent d04660db
...@@ -36,8 +36,8 @@ class CWasmEntryArgTester { ...@@ -36,8 +36,8 @@ class CWasmEntryArgTester {
sig_(runner_.template CreateSig<ReturnType, Args...>()) { sig_(runner_.template CreateSig<ReturnType, Args...>()) {
std::vector<uint8_t> code{wasm_function_bytes}; std::vector<uint8_t> code{wasm_function_bytes};
runner_.Build(code.data(), code.data() + code.size()); runner_.Build(code.data(), code.data() + code.size());
wasm_code_ = runner_.module().GetFunctionCode(0); wasm_code_ = runner_.builder().GetFunctionCode(0);
Handle<WasmInstanceObject> instance(runner_.module().instance_object()); Handle<WasmInstanceObject> instance(runner_.builder().instance_object());
Handle<WasmDebugInfo> debug_info = Handle<WasmDebugInfo> debug_info =
WasmInstanceObject::GetOrCreateDebugInfo(instance); WasmInstanceObject::GetOrCreateDebugInfo(instance);
c_wasm_entry_fn_ = WasmDebugInfo::GetCWasmEntry(debug_info, sig_); c_wasm_entry_fn_ = WasmDebugInfo::GetCWasmEntry(debug_info, sig_);
......
...@@ -1212,7 +1212,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) { ...@@ -1212,7 +1212,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) {
for (size_t m = 0; m < arraysize(loads); m++) { for (size_t m = 0; m < arraysize(loads); m++) {
WasmRunner<int64_t> r(execution_mode); WasmRunner<int64_t> r(execution_mode);
byte* memory = r.module().AddMemoryElems<byte>(16); byte* memory = r.builder().AddMemoryElems<byte>(16);
byte code[] = { byte code[] = {
kExprI32Const, 8, // -- kExprI32Const, 8, // --
...@@ -1234,7 +1234,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) { ...@@ -1234,7 +1234,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) {
// Try a bunch of different negative values. // Try a bunch of different negative values.
for (int i = -1; i >= -128; i -= 11) { for (int i = -1; i >= -128; i -= 11) {
int size = 1 << m; int size = 1 << m;
r.module().BlankMemory(); r.builder().BlankMemory();
memory[size - 1] = static_cast<byte>(i); // set the high order byte. memory[size - 1] = static_cast<byte>(i); // set the high order byte.
int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8);
...@@ -1309,14 +1309,14 @@ WASM_EXEC_TEST(I64UConvertF64b) { ...@@ -1309,14 +1309,14 @@ WASM_EXEC_TEST(I64UConvertF64b) {
WASM_EXEC_TEST(I64ReinterpretF64) { WASM_EXEC_TEST(I64ReinterpretF64) {
REQUIRE(I64ReinterpretF64); REQUIRE(I64ReinterpretF64);
WasmRunner<int64_t> r(execution_mode); WasmRunner<int64_t> r(execution_mode);
int64_t* memory = r.module().AddMemoryElems<int64_t>(8); int64_t* memory = r.builder().AddMemoryElems<int64_t>(8);
BUILD(r, WASM_I64_REINTERPRET_F64( BUILD(r, WASM_I64_REINTERPRET_F64(
WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO))); WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int64_t expected = static_cast<int64_t>(*i) * 0x300010001; int64_t expected = static_cast<int64_t>(*i) * 0x300010001;
r.module().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
} }
...@@ -1334,7 +1334,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) { ...@@ -1334,7 +1334,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) {
WASM_EXEC_TEST(F64ReinterpretI64) { WASM_EXEC_TEST(F64ReinterpretI64) {
REQUIRE(F64ReinterpretI64); REQUIRE(F64ReinterpretI64);
WasmRunner<int64_t, int64_t> r(execution_mode); WasmRunner<int64_t, int64_t> r(execution_mode);
int64_t* memory = r.module().AddMemoryElems<int64_t>(8); int64_t* memory = r.builder().AddMemoryElems<int64_t>(8);
BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO, BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO,
WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))), WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))),
...@@ -1343,25 +1343,25 @@ WASM_EXEC_TEST(F64ReinterpretI64) { ...@@ -1343,25 +1343,25 @@ WASM_EXEC_TEST(F64ReinterpretI64) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int64_t expected = static_cast<int64_t>(*i) * 0x300010001; int64_t expected = static_cast<int64_t>(*i) * 0x300010001;
CHECK_EQ(expected, r.Call(expected)); CHECK_EQ(expected, r.Call(expected));
CHECK_EQ(expected, r.module().ReadMemory<int64_t>(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory<int64_t>(&memory[0]));
} }
} }
WASM_EXEC_TEST(LoadMemI64) { WASM_EXEC_TEST(LoadMemI64) {
REQUIRE(I64LoadStore); REQUIRE(I64LoadStore);
WasmRunner<int64_t> r(execution_mode); WasmRunner<int64_t> r(execution_mode);
int64_t* memory = r.module().AddMemoryElems<int64_t>(8); int64_t* memory = r.builder().AddMemoryElems<int64_t>(8);
r.module().RandomizeMemory(1111); r.builder().RandomizeMemory(1111);
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO)); BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO));
r.module().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL); r.builder().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL);
CHECK_EQ(0x1abbccdd00112233LL, r.Call()); CHECK_EQ(0x1abbccdd00112233LL, r.Call());
r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL); r.builder().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
CHECK_EQ(0x33aabbccdd001122LL, r.Call()); CHECK_EQ(0x33aabbccdd001122LL, r.Call());
r.module().WriteMemory<int64_t>(&memory[0], 77777777); r.builder().WriteMemory<int64_t>(&memory[0], 77777777);
CHECK_EQ(77777777, r.Call()); CHECK_EQ(77777777, r.Call());
} }
...@@ -1369,19 +1369,19 @@ WASM_EXEC_TEST(LoadMemI64_alignment) { ...@@ -1369,19 +1369,19 @@ WASM_EXEC_TEST(LoadMemI64_alignment) {
REQUIRE(I64LoadStore); REQUIRE(I64LoadStore);
for (byte alignment = 0; alignment <= 3; alignment++) { for (byte alignment = 0; alignment <= 3; alignment++) {
WasmRunner<int64_t> r(execution_mode); WasmRunner<int64_t> r(execution_mode);
int64_t* memory = r.module().AddMemoryElems<int64_t>(8); int64_t* memory = r.builder().AddMemoryElems<int64_t>(8);
r.module().RandomizeMemory(1111); r.builder().RandomizeMemory(1111);
BUILD(r, BUILD(r,
WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, alignment)); WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, alignment));
r.module().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL); r.builder().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL);
CHECK_EQ(0x1abbccdd00112233LL, r.Call()); CHECK_EQ(0x1abbccdd00112233LL, r.Call());
r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL); r.builder().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
CHECK_EQ(0x33aabbccdd001122LL, r.Call()); CHECK_EQ(0x33aabbccdd001122LL, r.Call());
r.module().WriteMemory<int64_t>(&memory[0], 77777777); r.builder().WriteMemory<int64_t>(&memory[0], 77777777);
CHECK_EQ(77777777, r.Call()); CHECK_EQ(77777777, r.Call());
} }
} }
...@@ -1393,7 +1393,7 @@ WASM_EXEC_TEST(MemI64_Sum) { ...@@ -1393,7 +1393,7 @@ WASM_EXEC_TEST(MemI64_Sum) {
REQUIRE(I64Phi); REQUIRE(I64Phi);
const int kNumElems = 20; const int kNumElems = 20;
WasmRunner<uint64_t, int32_t> r(execution_mode); WasmRunner<uint64_t, int32_t> r(execution_mode);
uint64_t* memory = r.module().AddMemoryElems<uint64_t>(kNumElems); uint64_t* memory = r.builder().AddMemoryElems<uint64_t>(kNumElems);
const byte kSum = r.AllocateLocal(kWasmI64); const byte kSum = r.AllocateLocal(kWasmI64);
BUILD(r, WASM_WHILE( BUILD(r, WASM_WHILE(
...@@ -1409,10 +1409,10 @@ WASM_EXEC_TEST(MemI64_Sum) { ...@@ -1409,10 +1409,10 @@ WASM_EXEC_TEST(MemI64_Sum) {
// Run 4 trials. // Run 4 trials.
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
r.module().RandomizeMemory(i * 33); r.builder().RandomizeMemory(i * 33);
uint64_t expected = 0; uint64_t expected = 0;
for (size_t j = kNumElems - 1; j > 0; j--) { for (size_t j = kNumElems - 1; j > 0; j--) {
expected += r.module().ReadMemory(&memory[j]); expected += r.builder().ReadMemory(&memory[j]);
} }
uint64_t result = r.Call(8 * (kNumElems - 1)); uint64_t result = r.Call(8 * (kNumElems - 1));
CHECK_EQ(expected, result); CHECK_EQ(expected, result);
...@@ -1424,15 +1424,15 @@ WASM_EXEC_TEST(StoreMemI64_alignment) { ...@@ -1424,15 +1424,15 @@ WASM_EXEC_TEST(StoreMemI64_alignment) {
for (byte i = 0; i <= 3; i++) { for (byte i = 0; i <= 3; i++) {
WasmRunner<int64_t, int64_t> r(execution_mode); WasmRunner<int64_t, int64_t> r(execution_mode);
int64_t* memory = r.module().AddMemoryElems<int64_t>(4); int64_t* memory = r.builder().AddMemoryElems<int64_t>(4);
BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i, BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i,
WASM_GET_LOCAL(0)), WASM_GET_LOCAL(0)),
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
r.module().RandomizeMemory(1111); r.builder().RandomizeMemory(1111);
r.module().WriteMemory<int64_t>(&memory[0], 0); r.builder().WriteMemory<int64_t>(&memory[0], 0);
CHECK_EQ(kWritten, r.Call(kWritten)); CHECK_EQ(kWritten, r.Call(kWritten));
CHECK_EQ(kWritten, r.module().ReadMemory(&memory[0])); CHECK_EQ(kWritten, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -1442,14 +1442,14 @@ WASM_EXEC_TEST(I64Global) { ...@@ -1442,14 +1442,14 @@ WASM_EXEC_TEST(I64Global) {
REQUIRE(I64And); REQUIRE(I64And);
REQUIRE(DepthFirst); REQUIRE(DepthFirst);
WasmRunner<int32_t, int32_t> r(execution_mode); WasmRunner<int32_t, int32_t> r(execution_mode);
int64_t* global = r.module().AddGlobal<int64_t>(); int64_t* global = r.builder().AddGlobal<int64_t>();
// global = global + p0 // global = global + p0
BUILD(r, WASM_SET_GLOBAL( BUILD(r, WASM_SET_GLOBAL(
0, WASM_I64_AND(WASM_GET_GLOBAL(0), 0, WASM_I64_AND(WASM_GET_GLOBAL(0),
WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))), WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
WASM_ZERO); WASM_ZERO);
r.module().WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL); r.builder().WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL);
for (int i = 9; i < 444444; i += 111111) { for (int i = 9; i < 444444; i += 111111) {
int64_t expected = *global & i; int64_t expected = *global & i;
r.Call(i); r.Call(i);
...@@ -1506,8 +1506,8 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) { ...@@ -1506,8 +1506,8 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) {
for (size_t m = 0; m < arraysize(machineTypes); m++) { for (size_t m = 0; m < arraysize(machineTypes); m++) {
WasmRunner<int32_t, uint32_t> r(execution_mode); WasmRunner<int32_t, uint32_t> r(execution_mode);
byte* memory = r.module().AddMemoryElems<byte>(32); byte* memory = r.builder().AddMemoryElems<byte>(32);
r.module().RandomizeMemory(1119 + static_cast<int>(m)); r.builder().RandomizeMemory(1119 + static_cast<int>(m));
BUILD(r, WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0), BUILD(r, WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0),
WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)), WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)),
...@@ -1526,14 +1526,14 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) { ...@@ -1526,14 +1526,14 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) {
WASM_EXEC_TEST(UnalignedInt64Load) { WASM_EXEC_TEST(UnalignedInt64Load) {
WasmRunner<uint64_t> r(execution_mode); WasmRunner<uint64_t> r(execution_mode);
r.module().AddMemoryElems<int64_t>(8); r.builder().AddMemoryElems<int64_t>(8);
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3)); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3));
r.Call(); r.Call();
} }
WASM_EXEC_TEST(UnalignedInt64Store) { WASM_EXEC_TEST(UnalignedInt64Store) {
WasmRunner<int32_t> r(execution_mode); WasmRunner<int32_t> r(execution_mode);
r.module().AddMemoryElems<uint64_t>(8); r.builder().AddMemoryElems<uint64_t>(8);
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3, BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3,
WASM_I64V_1(1)), WASM_I64V_1(1)),
WASM_I32V_1(12))); WASM_I32V_1(12)));
...@@ -1554,9 +1554,9 @@ static void CompileCallIndirectMany(ValueType param) { ...@@ -1554,9 +1554,9 @@ static void CompileCallIndirectMany(ValueType param) {
WasmRunner<void> r(kExecuteCompiled); WasmRunner<void> r(kExecuteCompiled);
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params); FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
r.module().AddSignature(sig); r.builder().AddSignature(sig);
r.module().AddSignature(sig); r.builder().AddSignature(sig);
r.module().AddIndirectFunctionTable(nullptr, 0); r.builder().AddIndirectFunctionTable(nullptr, 0);
WasmFunctionCompiler& t = r.NewFunction(sig); WasmFunctionCompiler& t = r.NewFunction(sig);
...@@ -1590,7 +1590,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { ...@@ -1590,7 +1590,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
v8::internal::AccountingAllocator allocator; v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME); Zone zone(&allocator, ZONE_NAME);
WasmRunner<int32_t> r(execution_mode); WasmRunner<int32_t> r(execution_mode);
r.module().AddMemory(1024); r.builder().AddMemory(1024);
MachineType* memtypes = &mixed[start]; MachineType* memtypes = &mixed[start];
MachineType result = memtypes[which]; MachineType result = memtypes[which];
...@@ -1634,14 +1634,14 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { ...@@ -1634,14 +1634,14 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
// Run the code. // Run the code.
for (int t = 0; t < 10; t++) { for (int t = 0; t < 10; t++) {
r.module().RandomizeMemory(); r.builder().RandomizeMemory();
CHECK_EQ(kExpected, r.Call()); CHECK_EQ(kExpected, r.Call());
int size = WasmOpcodes::MemSize(result); int size = WasmOpcodes::MemSize(result);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
int base = (which + 1) * kElemSize; int base = (which + 1) * kElemSize;
byte expected = r.module().raw_mem_at<byte>(base + i); byte expected = r.builder().raw_mem_at<byte>(base + i);
byte result = r.module().raw_mem_at<byte>(i); byte result = r.builder().raw_mem_at<byte>(i);
CHECK_EQ(expected, result); CHECK_EQ(expected, result);
} }
} }
...@@ -1658,7 +1658,7 @@ WASM_EXEC_TEST(Regress5874) { ...@@ -1658,7 +1658,7 @@ WASM_EXEC_TEST(Regress5874) {
REQUIRE(I64LoadStore); REQUIRE(I64LoadStore);
REQUIRE(I64Const); REQUIRE(I64Const);
WasmRunner<int32_t> r(execution_mode); WasmRunner<int32_t> r(execution_mode);
r.module().AddMemoryElems<int64_t>(8); r.builder().AddMemoryElems<int64_t>(8);
BUILD(r, kExprI64Const, 0x00, // -- BUILD(r, kExprI64Const, 0x00, // --
kExprI32ConvertI64, // -- kExprI32ConvertI64, // --
......
...@@ -39,7 +39,7 @@ uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) { ...@@ -39,7 +39,7 @@ uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) {
WASM_EXEC_TEST(Int32AsmjsDivS) { WASM_EXEC_TEST(Int32AsmjsDivS) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min(); const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(0, r.Call(0, 100)); CHECK_EQ(0, r.Call(0, 100));
...@@ -51,7 +51,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS) { ...@@ -51,7 +51,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS) {
WASM_EXEC_TEST(Int32AsmjsRemS) { WASM_EXEC_TEST(Int32AsmjsRemS) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min(); const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(33, r.Call(133, 100)); CHECK_EQ(33, r.Call(133, 100));
...@@ -63,7 +63,7 @@ WASM_EXEC_TEST(Int32AsmjsRemS) { ...@@ -63,7 +63,7 @@ WASM_EXEC_TEST(Int32AsmjsRemS) {
WASM_EXEC_TEST(Int32AsmjsDivU) { WASM_EXEC_TEST(Int32AsmjsDivU) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min(); const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(0, r.Call(0, 100)); CHECK_EQ(0, r.Call(0, 100));
...@@ -75,7 +75,7 @@ WASM_EXEC_TEST(Int32AsmjsDivU) { ...@@ -75,7 +75,7 @@ WASM_EXEC_TEST(Int32AsmjsDivU) {
WASM_EXEC_TEST(Int32AsmjsRemU) { WASM_EXEC_TEST(Int32AsmjsRemU) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
const int32_t kMin = std::numeric_limits<int32_t>::min(); const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(17, r.Call(217, 100)); CHECK_EQ(17, r.Call(217, 100));
...@@ -87,7 +87,7 @@ WASM_EXEC_TEST(Int32AsmjsRemU) { ...@@ -87,7 +87,7 @@ WASM_EXEC_TEST(Int32AsmjsRemU) {
WASM_EXEC_TEST(I32AsmjsSConvertF32) { WASM_EXEC_TEST(I32AsmjsSConvertF32) {
WasmRunner<int32_t, float> r(execution_mode); WasmRunner<int32_t, float> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
...@@ -98,7 +98,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) { ...@@ -98,7 +98,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) {
WASM_EXEC_TEST(I32AsmjsSConvertF64) { WASM_EXEC_TEST(I32AsmjsSConvertF64) {
WasmRunner<int32_t, double> r(execution_mode); WasmRunner<int32_t, double> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
...@@ -109,7 +109,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) { ...@@ -109,7 +109,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) {
WASM_EXEC_TEST(I32AsmjsUConvertF32) { WASM_EXEC_TEST(I32AsmjsUConvertF32) {
WasmRunner<uint32_t, float> r(execution_mode); WasmRunner<uint32_t, float> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
...@@ -120,7 +120,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) { ...@@ -120,7 +120,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) {
WASM_EXEC_TEST(I32AsmjsUConvertF64) { WASM_EXEC_TEST(I32AsmjsUConvertF64) {
WasmRunner<uint32_t, double> r(execution_mode); WasmRunner<uint32_t, double> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
...@@ -131,9 +131,9 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) { ...@@ -131,9 +131,9 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) {
WASM_EXEC_TEST(LoadMemI32_oob_asm) { WASM_EXEC_TEST(LoadMemI32_oob_asm) {
WasmRunner<int32_t, uint32_t> r(execution_mode); WasmRunner<int32_t, uint32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
int32_t* memory = r.module().AddMemoryElems<int32_t>(8); int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
r.module().RandomizeMemory(1112); r.builder().RandomizeMemory(1112);
BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0)));
...@@ -151,9 +151,9 @@ WASM_EXEC_TEST(LoadMemI32_oob_asm) { ...@@ -151,9 +151,9 @@ WASM_EXEC_TEST(LoadMemI32_oob_asm) {
WASM_EXEC_TEST(LoadMemF32_oob_asm) { WASM_EXEC_TEST(LoadMemF32_oob_asm) {
WasmRunner<float, uint32_t> r(execution_mode); WasmRunner<float, uint32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
float* memory = r.module().AddMemoryElems<float>(8); float* memory = r.builder().AddMemoryElems<float>(8);
r.module().RandomizeMemory(1112); r.builder().RandomizeMemory(1112);
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
...@@ -171,9 +171,9 @@ WASM_EXEC_TEST(LoadMemF32_oob_asm) { ...@@ -171,9 +171,9 @@ WASM_EXEC_TEST(LoadMemF32_oob_asm) {
WASM_EXEC_TEST(LoadMemF64_oob_asm) { WASM_EXEC_TEST(LoadMemF64_oob_asm) {
WasmRunner<double, uint32_t> r(execution_mode); WasmRunner<double, uint32_t> r(execution_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
double* memory = r.module().AddMemoryElems<double>(8); double* memory = r.builder().AddMemoryElems<double>(8);
r.module().RandomizeMemory(1112); r.builder().RandomizeMemory(1112);
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
...@@ -193,9 +193,9 @@ WASM_EXEC_TEST(LoadMemF64_oob_asm) { ...@@ -193,9 +193,9 @@ WASM_EXEC_TEST(LoadMemF64_oob_asm) {
WASM_EXEC_TEST(StoreMemI32_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_mode);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
int32_t* memory = r.module().AddMemoryElems<int32_t>(8); int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
r.module().RandomizeMemory(1112); r.builder().RandomizeMemory(1112);
BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1))); WASM_GET_LOCAL(1)));
...@@ -228,12 +228,12 @@ WASM_EXEC_TEST(StoreMemI32_oob_asm) { ...@@ -228,12 +228,12 @@ WASM_EXEC_TEST(StoreMemI32_oob_asm) {
#define INT_LOAD_TEST(OP_TYPE) \ #define INT_LOAD_TEST(OP_TYPE) \
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \ WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \
r.module().ChangeOriginToAsmjs(); \ r.builder().ChangeOriginToAsmjs(); \
BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \ CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
RelocInfo::WASM_MEMORY_REFERENCE)); \ RelocInfo::WASM_MEMORY_REFERENCE)); \
CHECK_NE( \ CHECK_NE( \
0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \ 0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
} }
...@@ -242,12 +242,12 @@ FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) ...@@ -242,12 +242,12 @@ FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
#define INT_STORE_TEST(OP_TYPE) \ #define INT_STORE_TEST(OP_TYPE) \
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \ WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \
r.module().ChangeOriginToAsmjs(); \ r.builder().ChangeOriginToAsmjs(); \
BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \ CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
RelocInfo::WASM_MEMORY_REFERENCE)); \ RelocInfo::WASM_MEMORY_REFERENCE)); \
CHECK_NE( \ CHECK_NE( \
0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \ 0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
} }
...@@ -255,46 +255,46 @@ FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) ...@@ -255,46 +255,46 @@ FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
WasmRunner<float, uint32_t> r(kExecuteCompiled); WasmRunner<float, uint32_t> r(kExecuteCompiled);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_REFERENCE)); RelocInfo::WASM_MEMORY_REFERENCE));
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
} }
TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
WasmRunner<float, uint32_t, float> r(kExecuteCompiled); WasmRunner<float, uint32_t, float> r(kExecuteCompiled);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1))); WASM_GET_LOCAL(1)));
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_REFERENCE)); RelocInfo::WASM_MEMORY_REFERENCE));
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
} }
TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
WasmRunner<double, uint32_t> r(kExecuteCompiled); WasmRunner<double, uint32_t> r(kExecuteCompiled);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_REFERENCE)); RelocInfo::WASM_MEMORY_REFERENCE));
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
} }
TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
WasmRunner<double, uint32_t, double> r(kExecuteCompiled); WasmRunner<double, uint32_t, double> r(kExecuteCompiled);
r.module().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();
BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1))); WASM_GET_LOCAL(1)));
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_REFERENCE)); RelocInfo::WASM_MEMORY_REFERENCE));
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
} }
...@@ -42,17 +42,17 @@ T Xor(T a, T b) { ...@@ -42,17 +42,17 @@ T Xor(T a, T b) {
void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) { void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads); EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
uint32_t* memory = r.module().AddMemoryElems<uint32_t>(8); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8);
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0))); BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0)));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t initial = *i; uint32_t initial = *i;
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
r.module().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(*j));
uint32_t expected = expected_op(*i, *j); uint32_t expected = expected_op(*i, *j);
CHECK_EQ(expected, r.module().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
} }
...@@ -66,17 +66,17 @@ WASM_EXEC_TEST(I32Xor) { RunU32BinOp(kExprI32AtomicXor, Xor); } ...@@ -66,17 +66,17 @@ WASM_EXEC_TEST(I32Xor) { RunU32BinOp(kExprI32AtomicXor, Xor); }
void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) { void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads); EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
uint16_t* memory = r.module().AddMemoryElems<uint16_t>(8); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8);
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0))); BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0)));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t initial = *i; uint16_t initial = *i;
FOR_UINT16_INPUTS(j) { FOR_UINT16_INPUTS(j) {
r.module().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(*j));
uint16_t expected = expected_op(*i, *j); uint16_t expected = expected_op(*i, *j);
CHECK_EQ(expected, r.module().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
} }
...@@ -90,17 +90,17 @@ WASM_EXEC_TEST(I32Xor16U) { RunU16BinOp(kExprI32AtomicXor16U, Xor); } ...@@ -90,17 +90,17 @@ WASM_EXEC_TEST(I32Xor16U) { RunU16BinOp(kExprI32AtomicXor16U, Xor); }
void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) { void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) {
EXPERIMENTAL_FLAG_SCOPE(threads); EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled);
uint8_t* memory = r.module().AddMemoryElems<uint8_t>(8); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8);
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0))); BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0)));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t initial = *i; uint8_t initial = *i;
FOR_UINT8_INPUTS(j) { FOR_UINT8_INPUTS(j) {
r.module().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(*j));
uint8_t expected = expected_op(*i, *j); uint8_t expected = expected_op(*i, *j);
CHECK_EQ(expected, r.module().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
} }
......
...@@ -298,15 +298,15 @@ TEST(Breakpoint_I32And_disable) { ...@@ -298,15 +298,15 @@ TEST(Breakpoint_I32And_disable) {
TEST(GrowMemory) { TEST(GrowMemory) {
{ {
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted);
r.module().AddMemory(WasmModule::kPageSize); r.builder().AddMemory(WasmModule::kPageSize);
r.module().SetMaxMemPages(10); r.builder().SetMaxMemPages(10);
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
CHECK_EQ(1, r.Call(1)); CHECK_EQ(1, r.Call(1));
} }
{ {
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted);
r.module().AddMemory(WasmModule::kPageSize); r.builder().AddMemory(WasmModule::kPageSize);
r.module().SetMaxMemPages(10); r.builder().SetMaxMemPages(10);
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
CHECK_EQ(-1, r.Call(11)); CHECK_EQ(-1, r.Call(11));
} }
...@@ -316,7 +316,7 @@ TEST(GrowMemoryPreservesData) { ...@@ -316,7 +316,7 @@ TEST(GrowMemoryPreservesData) {
int32_t index = 16; int32_t index = 16;
int32_t value = 2335; int32_t value = 2335;
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted);
r.module().AddMemory(WasmModule::kPageSize); r.builder().AddMemory(WasmModule::kPageSize);
BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
WASM_I32V(value)), WASM_I32V(value)),
WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP,
...@@ -327,7 +327,7 @@ TEST(GrowMemoryPreservesData) { ...@@ -327,7 +327,7 @@ TEST(GrowMemoryPreservesData) {
TEST(GrowMemoryInvalidSize) { TEST(GrowMemoryInvalidSize) {
// Grow memory by an invalid amount without initial memory. // Grow memory by an invalid amount without initial memory.
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted);
r.module().AddMemory(WasmModule::kPageSize); r.builder().AddMemory(WasmModule::kPageSize);
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
CHECK_EQ(-1, r.Call(1048575)); CHECK_EQ(-1, r.Call(1048575));
} }
...@@ -368,7 +368,7 @@ TEST(TestPossibleNondeterminism) { ...@@ -368,7 +368,7 @@ TEST(TestPossibleNondeterminism) {
{ {
int32_t index = 16; int32_t index = 16;
WasmRunner<int32_t, float> r(kExecuteInterpreted); WasmRunner<int32_t, float> r(kExecuteInterpreted);
r.module().AddMemory(WasmModule::kPageSize); r.builder().AddMemory(WasmModule::kPageSize);
BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index), BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index),
WASM_GET_LOCAL(0)), WASM_GET_LOCAL(0)),
WASM_I32V(index)); WASM_I32V(index));
...@@ -380,7 +380,7 @@ TEST(TestPossibleNondeterminism) { ...@@ -380,7 +380,7 @@ TEST(TestPossibleNondeterminism) {
{ {
int32_t index = 16; int32_t index = 16;
WasmRunner<int32_t, double> r(kExecuteInterpreted); WasmRunner<int32_t, double> r(kExecuteInterpreted);
r.module().AddMemory(WasmModule::kPageSize); r.builder().AddMemory(WasmModule::kPageSize);
BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index), BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index),
WASM_GET_LOCAL(0)), WASM_GET_LOCAL(0)),
WASM_I32V(index)); WASM_I32V(index));
...@@ -423,7 +423,7 @@ TEST(WasmInterpreterActivations) { ...@@ -423,7 +423,7 @@ TEST(WasmInterpreterActivations) {
TEST(InterpreterLoadWithoutMemory) { TEST(InterpreterLoadWithoutMemory) {
WasmRunner<int32_t, int32_t> r(kExecuteInterpreted); WasmRunner<int32_t, int32_t> r(kExecuteInterpreted);
r.module().AddMemory(0); r.builder().AddMemory(0);
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
CHECK_TRAP32(r.Call(0)); CHECK_TRAP32(r.Call(0));
} }
......
...@@ -46,7 +46,8 @@ class PredictableInputValues { ...@@ -46,7 +46,8 @@ class PredictableInputValues {
} }
}; };
uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) { uint32_t AddJSSelector(TestingModuleBuilder* builder, FunctionSig* sig,
int which) {
const int kMaxParams = 11; const int kMaxParams = 11;
static const char* formals[kMaxParams] = {"", static const char* formals[kMaxParams] = {"",
"a", "a",
...@@ -67,7 +68,7 @@ uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) { ...@@ -67,7 +68,7 @@ uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) {
SNPrintF(source, "(function(%s) { return %c; })", SNPrintF(source, "(function(%s) { return %c; })",
formals[sig->parameter_count()], param); formals[sig->parameter_count()], param);
return module->AddJsFunction(sig, source.start()); return builder->AddJsFunction(sig, source.start());
} }
void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc,
...@@ -99,7 +100,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, double a, ...@@ -99,7 +100,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, double a,
TEST(Run_Int32Sub_jswrapped) { TEST(Run_Int32Sub_jswrapped) {
WasmRunner<int, int, int> r(kExecuteCompiled); WasmRunner<int, int, int> r(kExecuteCompiled);
BUILD(r, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index);
EXPECT_CALL(33, jsfunc, 44, 11); EXPECT_CALL(33, jsfunc, 44, 11);
EXPECT_CALL(-8723487, jsfunc, -8000000, 723487); EXPECT_CALL(-8723487, jsfunc, -8000000, 723487);
...@@ -108,7 +109,7 @@ TEST(Run_Int32Sub_jswrapped) { ...@@ -108,7 +109,7 @@ TEST(Run_Int32Sub_jswrapped) {
TEST(Run_Float32Div_jswrapped) { TEST(Run_Float32Div_jswrapped) {
WasmRunner<float, float, float> r(kExecuteCompiled); WasmRunner<float, float, float> r(kExecuteCompiled);
BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index);
EXPECT_CALL(92, jsfunc, 46, 0.5); EXPECT_CALL(92, jsfunc, 46, 0.5);
EXPECT_CALL(64, jsfunc, -16, -0.25); EXPECT_CALL(64, jsfunc, -16, -0.25);
...@@ -117,7 +118,7 @@ TEST(Run_Float32Div_jswrapped) { ...@@ -117,7 +118,7 @@ TEST(Run_Float32Div_jswrapped) {
TEST(Run_Float64Add_jswrapped) { TEST(Run_Float64Add_jswrapped) {
WasmRunner<double, double, double> r(kExecuteCompiled); WasmRunner<double, double, double> r(kExecuteCompiled);
BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index);
EXPECT_CALL(3, jsfunc, 2, 1); EXPECT_CALL(3, jsfunc, 2, 1);
EXPECT_CALL(-5.5, jsfunc, -5.25, -0.25); EXPECT_CALL(-5.5, jsfunc, -5.25, -0.25);
...@@ -126,7 +127,7 @@ TEST(Run_Float64Add_jswrapped) { ...@@ -126,7 +127,7 @@ TEST(Run_Float64Add_jswrapped) {
TEST(Run_I32Popcount_jswrapped) { TEST(Run_I32Popcount_jswrapped) {
WasmRunner<int, int> r(kExecuteCompiled); WasmRunner<int, int> r(kExecuteCompiled);
BUILD(r, WASM_I32_POPCNT(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_POPCNT(WASM_GET_LOCAL(0)));
Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index);
EXPECT_CALL(2, jsfunc, 9, 0); EXPECT_CALL(2, jsfunc, 9, 0);
EXPECT_CALL(3, jsfunc, 11, 0); EXPECT_CALL(3, jsfunc, 11, 0);
...@@ -137,10 +138,10 @@ TEST(Run_CallJS_Add_jswrapped) { ...@@ -137,10 +138,10 @@ TEST(Run_CallJS_Add_jswrapped) {
WasmRunner<int, int> r(kExecuteCompiled); WasmRunner<int, int> r(kExecuteCompiled);
TestSignatures sigs; TestSignatures sigs;
uint32_t js_index = uint32_t js_index =
r.module().AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })"); r.builder().AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })");
BUILD(r, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0))); BUILD(r, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0)));
Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index);
EXPECT_CALL(101, jsfunc, 2, -8); EXPECT_CALL(101, jsfunc, 2, -8);
EXPECT_CALL(199, jsfunc, 100, -1); EXPECT_CALL(199, jsfunc, 100, -1);
...@@ -158,7 +159,7 @@ void RunJSSelectTest(int which) { ...@@ -158,7 +159,7 @@ void RunJSSelectTest(int which) {
FunctionSig sig(1, num_params, types); FunctionSig sig(1, num_params, types);
WasmRunner<void> r(kExecuteCompiled); WasmRunner<void> r(kExecuteCompiled);
uint32_t js_index = AddJSSelector(&r.module(), &sig, which); uint32_t js_index = AddJSSelector(&r.builder(), &sig, which);
WasmFunctionCompiler& t = r.NewFunction(&sig); WasmFunctionCompiler& t = r.NewFunction(&sig);
{ {
...@@ -175,7 +176,7 @@ void RunJSSelectTest(int which) { ...@@ -175,7 +176,7 @@ void RunJSSelectTest(int which) {
t.Build(&code[0], &code[end]); t.Build(&code[0], &code[end]);
} }
Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index());
double expected = inputs.arg_d(which); double expected = inputs.arg_d(which);
EXPECT_CALL(expected, jsfunc, 0.0, 0.0); EXPECT_CALL(expected, jsfunc, 0.0, 0.0);
} }
...@@ -234,7 +235,7 @@ void RunWASMSelectTest(int which) { ...@@ -234,7 +235,7 @@ void RunWASMSelectTest(int which) {
WasmRunner<void> r(kExecuteCompiled); WasmRunner<void> r(kExecuteCompiled);
WasmFunctionCompiler& t = r.NewFunction(&sig); WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_GET_LOCAL(which)); BUILD(t, WASM_GET_LOCAL(which));
Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index());
Handle<Object> args[] = { Handle<Object> args[] = {
isolate->factory()->NewNumber(inputs.arg_d(0)), isolate->factory()->NewNumber(inputs.arg_d(0)),
...@@ -306,7 +307,7 @@ void RunWASMSelectAlignTest(int num_args, int num_params) { ...@@ -306,7 +307,7 @@ void RunWASMSelectAlignTest(int num_args, int num_params) {
WasmRunner<void> r(kExecuteCompiled); WasmRunner<void> r(kExecuteCompiled);
WasmFunctionCompiler& t = r.NewFunction(&sig); WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_GET_LOCAL(which)); BUILD(t, WASM_GET_LOCAL(which));
Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index());
Handle<Object> args[] = {isolate->factory()->NewNumber(inputs.arg_d(0)), Handle<Object> args[] = {isolate->factory()->NewNumber(inputs.arg_d(0)),
isolate->factory()->NewNumber(inputs.arg_d(1)), isolate->factory()->NewNumber(inputs.arg_d(1)),
...@@ -416,12 +417,12 @@ void RunJSSelectAlignTest(int num_args, int num_params) { ...@@ -416,12 +417,12 @@ void RunJSSelectAlignTest(int num_args, int num_params) {
// Call different select JS functions. // Call different select JS functions.
for (int which = 0; which < num_params; which++) { for (int which = 0; which < num_params; which++) {
WasmRunner<void> r(kExecuteCompiled); WasmRunner<void> r(kExecuteCompiled);
uint32_t js_index = AddJSSelector(&r.module(), &sig, which); uint32_t js_index = AddJSSelector(&r.builder(), &sig, which);
CHECK_EQ(predicted_js_index, js_index); CHECK_EQ(predicted_js_index, js_index);
WasmFunctionCompiler& t = r.NewFunction(&sig); WasmFunctionCompiler& t = r.NewFunction(&sig);
t.Build(&code[0], &code[end]); t.Build(&code[0], &code[end]);
Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index());
Handle<Object> args[] = { Handle<Object> args[] = {
factory->NewNumber(inputs.arg_d(0)), factory->NewNumber(inputs.arg_d(0)),
......
...@@ -26,19 +26,19 @@ using namespace v8::internal::compiler; ...@@ -26,19 +26,19 @@ using namespace v8::internal::compiler;
WasmRunner<C_TYPE, C_TYPE> r(kExecuteCompiled); \ WasmRunner<C_TYPE, C_TYPE> r(kExecuteCompiled); \
Isolate* isolate = CcTest::i_isolate(); \ Isolate* isolate = CcTest::i_isolate(); \
\ \
r.module().AddGlobal<C_TYPE>(); \ r.builder().AddGlobal<C_TYPE>(); \
r.module().AddGlobal<C_TYPE>(); \ r.builder().AddGlobal<C_TYPE>(); \
\ \
/* global = global + p0 */ \ /* global = global + p0 */ \
BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \ BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \
WASM_GET_GLOBAL(0)); \ WASM_GET_GLOBAL(0)); \
CHECK_EQ(1, r.module().CodeTableLength()); \ CHECK_EQ(1, r.builder().CodeTableLength()); \
\ \
int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \ int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \
\ \
Handle<Code> code = r.module().GetFunctionCode(0); \ Handle<Code> code = r.builder().GetFunctionCode(0); \
\ \
Address old_start = r.module().globals_start(); \ Address old_start = r.builder().globals_start(); \
Address new_start = old_start + 1; \ Address new_start = old_start + 1; \
\ \
Address old_addresses[4]; \ Address old_addresses[4]; \
......
...@@ -1534,8 +1534,8 @@ void RunBinaryLaneOpTest( ...@@ -1534,8 +1534,8 @@ void RunBinaryLaneOpTest(
const std::array<T, kSimd128Size / sizeof(T)>& expected) { const std::array<T, kSimd128Size / sizeof(T)>& expected) {
WasmRunner<int32_t> r(kExecuteCompiled); WasmRunner<int32_t> r(kExecuteCompiled);
// Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7]. // 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); T* src0 = r.builder().AddGlobal<T>(kWasmS128);
T* src1 = r.module().AddGlobal<T>(kWasmS128); T* src1 = r.builder().AddGlobal<T>(kWasmS128);
static const int kElems = kSimd128Size / sizeof(T); static const int kElems = kSimd128Size / sizeof(T);
for (int i = 0; i < kElems; i++) { for (int i = 0; i < kElems; i++) {
src0[i] = i; src0[i] = i;
...@@ -2096,7 +2096,7 @@ const T& GetScalar(T* v, int lane) { ...@@ -2096,7 +2096,7 @@ const T& GetScalar(T* v, int lane) {
WASM_SIMD_TEST(SimdI32x4GetGlobal) { WASM_SIMD_TEST(SimdI32x4GetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled); WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128); int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128);
SetVectorByLanes(global, {{0, 1, 2, 3}}); SetVectorByLanes(global, {{0, 1, 2, 3}});
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
BUILD( BUILD(
...@@ -2119,7 +2119,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) { ...@@ -2119,7 +2119,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) {
WASM_SIMD_TEST(SimdI32x4SetGlobal) { WASM_SIMD_TEST(SimdI32x4SetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled); WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128); int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))), BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))),
WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
WASM_I32V(34))), WASM_I32V(34))),
...@@ -2141,7 +2141,7 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) { ...@@ -2141,7 +2141,7 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) {
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_SIMD_TEST(SimdF32x4GetGlobal) { WASM_SIMD_TEST(SimdF32x4GetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled); WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
float* global = r.module().AddGlobal<float>(kWasmS128); float* global = r.builder().AddGlobal<float>(kWasmS128);
SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}}); SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}});
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
BUILD( BUILD(
...@@ -2164,7 +2164,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) { ...@@ -2164,7 +2164,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) {
WASM_SIMD_TEST(SimdF32x4SetGlobal) { WASM_SIMD_TEST(SimdF32x4SetGlobal) {
WasmRunner<int32_t, int32_t> r(kExecuteCompiled); WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
float* global = r.module().AddGlobal<float>(kWasmS128); float* global = r.builder().AddGlobal<float>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))), BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))),
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
WASM_F32(45.5))), WASM_F32(45.5))),
...@@ -2186,14 +2186,14 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) { ...@@ -2186,14 +2186,14 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) {
V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_SIMD_TEST(SimdLoadStoreLoad) { WASM_SIMD_TEST(SimdLoadStoreLoad) {
WasmRunner<int32_t> r(kExecuteCompiled); WasmRunner<int32_t> r(kExecuteCompiled);
int32_t* memory = r.module().AddMemoryElems<int32_t>(4); int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
BUILD(r, WASM_SIMD_STORE_MEM(WASM_ZERO, WASM_SIMD_LOAD_MEM(WASM_ZERO)), BUILD(r, WASM_SIMD_STORE_MEM(WASM_ZERO, WASM_SIMD_LOAD_MEM(WASM_ZERO)),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_ZERO))); WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_ZERO)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i; int32_t expected = *i;
r.module().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
} }
......
This diff is collapsed.
...@@ -141,10 +141,10 @@ Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) { ...@@ -141,10 +141,10 @@ Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) {
void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset, void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset,
int expected_set_byte_offset = -1) { int expected_set_byte_offset = -1) {
int func_offset = int func_offset =
runner.module().GetFunctionAt(function_index)->code.offset(); runner.builder().GetFunctionAt(function_index)->code.offset();
int code_offset = func_offset + byte_offset; int code_offset = func_offset + byte_offset;
if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset; if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset;
Handle<WasmInstanceObject> instance = runner.module().instance_object(); Handle<WasmInstanceObject> instance = runner.builder().instance_object();
Handle<WasmCompiledModule> compiled_module(instance->compiled_module()); Handle<WasmCompiledModule> compiled_module(instance->compiled_module());
Handle<JSObject> fake_breakpoint_object = Handle<JSObject> fake_breakpoint_object =
MakeFakeBreakpoint(runner.main_isolate(), code_offset); MakeFakeBreakpoint(runner.main_isolate(), code_offset);
...@@ -270,7 +270,7 @@ TEST(WasmCollectPossibleBreakpoints) { ...@@ -270,7 +270,7 @@ TEST(WasmCollectPossibleBreakpoints) {
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE)); BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE));
Handle<WasmInstanceObject> instance = runner.module().instance_object(); Handle<WasmInstanceObject> instance = runner.builder().instance_object();
std::vector<debug::Location> locations; std::vector<debug::Location> locations;
// Check all locations for function 0. // Check all locations for function 0.
CheckLocations(instance->compiled_module(), {0, 0}, {1, 0}, CheckLocations(instance->compiled_module(), {0, 0}, {1, 0},
...@@ -297,7 +297,7 @@ TEST(WasmSimpleBreak) { ...@@ -297,7 +297,7 @@ TEST(WasmSimpleBreak) {
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))); BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
Handle<JSFunction> main_fun_wrapper = Handle<JSFunction> main_fun_wrapper =
runner.module().WrapCode(runner.function_index()); runner.builder().WrapCode(runner.function_index());
SetBreakpoint(runner, runner.function_index(), 4, 4); SetBreakpoint(runner, runner.function_index(), 4, 4);
BreakHandler count_breaks(isolate, {{4, BreakHandler::Continue}}); BreakHandler count_breaks(isolate, {{4, BreakHandler::Continue}});
...@@ -317,7 +317,7 @@ TEST(WasmSimpleStepping) { ...@@ -317,7 +317,7 @@ TEST(WasmSimpleStepping) {
Isolate* isolate = runner.main_isolate(); Isolate* isolate = runner.main_isolate();
Handle<JSFunction> main_fun_wrapper = Handle<JSFunction> main_fun_wrapper =
runner.module().WrapCode(runner.function_index()); runner.builder().WrapCode(runner.function_index());
// Set breakpoint at the first I32Const. // Set breakpoint at the first I32Const.
SetBreakpoint(runner, runner.function_index(), 1, 1); SetBreakpoint(runner, runner.function_index(), 1, 1);
...@@ -360,7 +360,7 @@ TEST(WasmStepInAndOut) { ...@@ -360,7 +360,7 @@ TEST(WasmStepInAndOut) {
Isolate* isolate = runner.main_isolate(); Isolate* isolate = runner.main_isolate();
Handle<JSFunction> main_fun_wrapper = Handle<JSFunction> main_fun_wrapper =
runner.module().WrapCode(f2.function_index()); runner.builder().WrapCode(f2.function_index());
// Set first breakpoint on the GetLocal (offset 19) before the Call. // Set first breakpoint on the GetLocal (offset 19) before the Call.
SetBreakpoint(runner, f2.function_index(), 19, 19); SetBreakpoint(runner, f2.function_index(), 19, 19);
...@@ -395,7 +395,7 @@ TEST(WasmGetLocalsAndStack) { ...@@ -395,7 +395,7 @@ TEST(WasmGetLocalsAndStack) {
Isolate* isolate = runner.main_isolate(); Isolate* isolate = runner.main_isolate();
Handle<JSFunction> main_fun_wrapper = Handle<JSFunction> main_fun_wrapper =
runner.module().WrapCode(runner.function_index()); runner.builder().WrapCode(runner.function_index());
// Set breakpoint at the first instruction (7 bytes for local decls: num // Set breakpoint at the first instruction (7 bytes for local decls: num
// entries + 3x<count, type>). // entries + 3x<count, type>).
......
...@@ -38,7 +38,7 @@ class ArgPassingHelper { ...@@ -38,7 +38,7 @@ class ArgPassingHelper {
: isolate_(runner.main_isolate()), : isolate_(runner.main_isolate()),
expected_lambda_(expected_lambda), expected_lambda_(expected_lambda),
debug_info_(WasmInstanceObject::GetOrCreateDebugInfo( debug_info_(WasmInstanceObject::GetOrCreateDebugInfo(
runner.module().instance_object())) { runner.builder().instance_object())) {
std::vector<uint8_t> inner_code{bytes_inner_function}; std::vector<uint8_t> inner_code{bytes_inner_function};
inner_compiler.Build(inner_code.data(), inner_compiler.Build(inner_code.data(),
inner_code.data() + inner_code.size()); inner_code.data() + inner_code.size());
...@@ -49,7 +49,7 @@ class ArgPassingHelper { ...@@ -49,7 +49,7 @@ class ArgPassingHelper {
int funcs_to_redict[] = {static_cast<int>(inner_compiler.function_index())}; int funcs_to_redict[] = {static_cast<int>(inner_compiler.function_index())};
WasmDebugInfo::RedirectToInterpreter(debug_info_, WasmDebugInfo::RedirectToInterpreter(debug_info_,
ArrayVector(funcs_to_redict)); ArrayVector(funcs_to_redict));
main_fun_wrapper_ = runner.module().WrapCode(runner.function_index()); main_fun_wrapper_ = runner.builder().WrapCode(runner.function_index());
} }
template <typename... Args> template <typename... Args>
......
...@@ -79,7 +79,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) { ...@@ -79,7 +79,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
WasmRunner<void> r(kExecuteCompiled); WasmRunner<void> r(kExecuteCompiled);
TestSignatures sigs; TestSignatures sigs;
uint32_t js_throwing_index = r.module().AddJsFunction( uint32_t js_throwing_index = r.builder().AddJsFunction(
sigs.v_v(), sigs.v_v(),
"(function js() {\n function a() {\n throw new Error(); };\n a(); })"); "(function js() {\n function a() {\n throw new Error(); };\n a(); })");
...@@ -91,7 +91,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) { ...@@ -91,7 +91,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
BUILD(f2, WASM_CALL_FUNCTION0(wasm_index_1)); BUILD(f2, WASM_CALL_FUNCTION0(wasm_index_1));
uint32_t wasm_index_2 = f2.function_index(); uint32_t wasm_index_2 = f2.function_index();
Handle<JSFunction> js_wasm_wrapper = r.module().WrapCode(wasm_index_2); Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2);
Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
...@@ -132,7 +132,7 @@ TEST(CollectDetailedWasmStack_WasmError) { ...@@ -132,7 +132,7 @@ TEST(CollectDetailedWasmStack_WasmError) {
BUILD(f2, WASM_CALL_FUNCTION0(0)); BUILD(f2, WASM_CALL_FUNCTION0(0));
uint32_t wasm_index_2 = f2.function_index(); uint32_t wasm_index_2 = f2.function_index();
Handle<JSFunction> js_wasm_wrapper = r.module().WrapCode(wasm_index_2); Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2);
Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
......
...@@ -71,7 +71,7 @@ TEST(Unreachable) { ...@@ -71,7 +71,7 @@ TEST(Unreachable) {
BUILD(r, WASM_UNREACHABLE); BUILD(r, WASM_UNREACHABLE);
uint32_t wasm_index = r.function()->func_index; uint32_t wasm_index = r.function()->func_index;
Handle<JSFunction> js_wasm_wrapper = r.module().WrapCode(wasm_index); Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index);
Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
...@@ -101,7 +101,7 @@ TEST(IllegalLoad) { ...@@ -101,7 +101,7 @@ TEST(IllegalLoad) {
WasmRunner<void> r(kExecuteCompiled, "main", true); WasmRunner<void> r(kExecuteCompiled, "main", true);
TestSignatures sigs; TestSignatures sigs;
r.module().AddMemory(0L); r.builder().AddMemory(0L);
BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(), BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(),
WASM_I32V_1(-3)), WASM_I32V_1(-3)),
...@@ -113,7 +113,7 @@ TEST(IllegalLoad) { ...@@ -113,7 +113,7 @@ TEST(IllegalLoad) {
BUILD(f2, WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1)); BUILD(f2, WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1));
uint32_t wasm_index_2 = f2.function_index(); uint32_t wasm_index_2 = f2.function_index();
Handle<JSFunction> js_wasm_wrapper = r.module().WrapCode(wasm_index_2); Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2);
Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
......
...@@ -73,9 +73,10 @@ const uint32_t kMaxGlobalsSize = 128; ...@@ -73,9 +73,10 @@ const uint32_t kMaxGlobalsSize = 128;
// progressively added by a test. In turn, we piecemeal update the runtime // progressively added by a test. In turn, we piecemeal update the runtime
// objects, i.e. {WasmInstanceObject}, {WasmCompiledModule} and, if necessary, // objects, i.e. {WasmInstanceObject}, {WasmCompiledModule} and, if necessary,
// the interpreter. // the interpreter.
class TestingModule { class TestingModuleBuilder {
public: public:
explicit TestingModule(Zone* zone, WasmExecutionMode mode = kExecuteCompiled) explicit TestingModuleBuilder(Zone* zone,
WasmExecutionMode mode = kExecuteCompiled)
: test_module_ptr_(&test_module_), : test_module_ptr_(&test_module_),
isolate_(CcTest::InitIsolateOnce()), isolate_(CcTest::InitIsolateOnce()),
global_offset(0), global_offset(0),
...@@ -561,7 +562,7 @@ class WasmFunctionWrapper : private GraphAndBuilders { ...@@ -561,7 +562,7 @@ class WasmFunctionWrapper : private GraphAndBuilders {
// interpretation (by adding to the interpreter manually). // interpretation (by adding to the interpreter manually).
class WasmFunctionCompiler : private GraphAndBuilders { class WasmFunctionCompiler : private GraphAndBuilders {
public: public:
Isolate* isolate() { return testing_module_->isolate(); } Isolate* isolate() { return builder_->isolate(); }
Graph* graph() const { return main_graph_; } Graph* graph() const { return main_graph_; }
Zone* zone() const { return graph()->zone(); } Zone* zone() const { return graph()->zone(); }
CommonOperatorBuilder* common() { return &main_common_; } CommonOperatorBuilder* common() { return &main_common_; }
...@@ -590,9 +591,8 @@ class WasmFunctionCompiler : private GraphAndBuilders { ...@@ -590,9 +591,8 @@ class WasmFunctionCompiler : private GraphAndBuilders {
CHECK_GE(kMaxInt, end - start); CHECK_GE(kMaxInt, end - start);
int len = static_cast<int>(end - start); int len = static_cast<int>(end - start);
function_->code = { function_->code = {builder_->AddBytes(Vector<const byte>(start, len)),
testing_module_->AddBytes(Vector<const byte>(start, len)), static_cast<uint32_t>(len)};
static_cast<uint32_t>(len)};
if (interpreter_) { if (interpreter_) {
// Add the code to the interpreter. // Add the code to the interpreter.
...@@ -600,16 +600,16 @@ class WasmFunctionCompiler : private GraphAndBuilders { ...@@ -600,16 +600,16 @@ class WasmFunctionCompiler : private GraphAndBuilders {
} }
// Build the TurboFan graph. // Build the TurboFan graph.
compiler::ModuleEnv module_env = testing_module_->CreateModuleEnv(); compiler::ModuleEnv module_env = builder_->CreateModuleEnv();
TestBuildingGraph(zone(), &jsgraph, &module_env, sig, TestBuildingGraph(zone(), &jsgraph, &module_env, sig,
&source_position_table_, start, end, &source_position_table_, start, end,
runtime_exception_support_); runtime_exception_support_);
Handle<Code> code = Compile(); Handle<Code> code = Compile();
testing_module_->SetFunctionCode(function_index(), code); builder_->SetFunctionCode(function_index(), code);
// Add to code table. // Add to code table.
Handle<WasmCompiledModule> compiled_module( Handle<WasmCompiledModule> compiled_module(
testing_module_->instance_object()->compiled_module(), isolate()); builder_->instance_object()->compiled_module(), isolate());
Handle<FixedArray> code_table = compiled_module->code_table(); Handle<FixedArray> code_table = compiled_module->code_table();
if (static_cast<int>(function_index()) >= code_table->length()) { if (static_cast<int>(function_index()) >= code_table->length()) {
Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray(
...@@ -639,21 +639,21 @@ class WasmFunctionCompiler : private GraphAndBuilders { ...@@ -639,21 +639,21 @@ class WasmFunctionCompiler : private GraphAndBuilders {
friend class WasmRunnerBase; friend class WasmRunnerBase;
explicit WasmFunctionCompiler(Zone* zone, FunctionSig* sig, explicit WasmFunctionCompiler(Zone* zone, FunctionSig* sig,
TestingModule* module, const char* name, TestingModuleBuilder* builder, const char* name,
bool runtime_exception_support) bool runtime_exception_support)
: GraphAndBuilders(zone), : GraphAndBuilders(zone),
jsgraph(module->isolate(), this->graph(), this->common(), nullptr, jsgraph(builder->isolate(), this->graph(), this->common(), nullptr,
nullptr, this->machine()), nullptr, this->machine()),
sig(sig), sig(sig),
descriptor_(nullptr), descriptor_(nullptr),
testing_module_(module), builder_(builder),
local_decls(zone, sig), local_decls(zone, sig),
source_position_table_(this->graph()), source_position_table_(this->graph()),
interpreter_(module->interpreter()), interpreter_(builder->interpreter()),
runtime_exception_support_(runtime_exception_support) { runtime_exception_support_(runtime_exception_support) {
// Get a new function from the testing module. // Get a new function from the testing module.
int index = module->AddFunction(sig, Handle<Code>::null(), name); int index = builder->AddFunction(sig, Handle<Code>::null(), name);
function_ = testing_module_->GetFunctionAt(index); function_ = builder_->GetFunctionAt(index);
} }
Handle<Code> Compile() { Handle<Code> Compile() {
...@@ -681,7 +681,7 @@ class WasmFunctionCompiler : private GraphAndBuilders { ...@@ -681,7 +681,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
Handle<FixedArray> deopt_data = Handle<FixedArray> deopt_data =
isolate()->factory()->NewFixedArray(2, TENURED); isolate()->factory()->NewFixedArray(2, TENURED);
Handle<Object> weak_instance = Handle<Object> weak_instance =
isolate()->factory()->NewWeakCell(testing_module_->instance_object()); isolate()->factory()->NewWeakCell(builder_->instance_object());
deopt_data->set(0, *weak_instance); deopt_data->set(0, *weak_instance);
deopt_data->set(1, Smi::FromInt(static_cast<int>(function_index()))); deopt_data->set(1, Smi::FromInt(static_cast<int>(function_index())));
code->set_deoptimization_data(*deopt_data); code->set_deoptimization_data(*deopt_data);
...@@ -700,7 +700,7 @@ class WasmFunctionCompiler : private GraphAndBuilders { ...@@ -700,7 +700,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
FunctionSig* sig; FunctionSig* sig;
// The call descriptor is initialized when the function is compiled. // The call descriptor is initialized when the function is compiled.
CallDescriptor* descriptor_; CallDescriptor* descriptor_;
TestingModule* testing_module_; TestingModuleBuilder* builder_;
Vector<const char> debug_name_; Vector<const char> debug_name_;
WasmFunction* function_; WasmFunction* function_;
LocalDeclEncoder local_decls; LocalDeclEncoder local_decls;
...@@ -716,7 +716,7 @@ class WasmRunnerBase : public HandleAndZoneScope { ...@@ -716,7 +716,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
explicit WasmRunnerBase(WasmExecutionMode execution_mode, int num_params, explicit WasmRunnerBase(WasmExecutionMode execution_mode, int num_params,
bool runtime_exception_support) bool runtime_exception_support)
: zone_(&allocator_, ZONE_NAME), : zone_(&allocator_, ZONE_NAME),
module_(&zone_, execution_mode), builder_(&zone_, execution_mode),
wrapper_(&zone_, num_params), wrapper_(&zone_, num_params),
runtime_exception_support_(runtime_exception_support) {} runtime_exception_support_(runtime_exception_support) {}
...@@ -742,7 +742,7 @@ class WasmRunnerBase : public HandleAndZoneScope { ...@@ -742,7 +742,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
WasmFunctionCompiler& NewFunction(FunctionSig* sig, WasmFunctionCompiler& NewFunction(FunctionSig* sig,
const char* name = nullptr) { const char* name = nullptr) {
functions_.emplace_back(new WasmFunctionCompiler( functions_.emplace_back(new WasmFunctionCompiler(
&zone_, sig, &module_, name, runtime_exception_support_)); &zone_, sig, &builder_, name, runtime_exception_support_));
return *functions_.back(); return *functions_.back();
} }
...@@ -757,10 +757,10 @@ class WasmRunnerBase : public HandleAndZoneScope { ...@@ -757,10 +757,10 @@ class WasmRunnerBase : public HandleAndZoneScope {
return functions_[0]->interpreter_; return functions_[0]->interpreter_;
} }
bool possible_nondeterminism() { return possible_nondeterminism_; } bool possible_nondeterminism() { return possible_nondeterminism_; }
TestingModule& module() { return module_; } TestingModuleBuilder& builder() { return builder_; }
Zone* zone() { return &zone_; } Zone* zone() { return &zone_; }
bool interpret() { return module_.interpret(); } bool interpret() { return builder_.interpret(); }
template <typename ReturnType, typename... ParamTypes> template <typename ReturnType, typename... ParamTypes>
FunctionSig* CreateSig() { FunctionSig* CreateSig() {
...@@ -795,7 +795,7 @@ class WasmRunnerBase : public HandleAndZoneScope { ...@@ -795,7 +795,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
protected: protected:
v8::internal::AccountingAllocator allocator_; v8::internal::AccountingAllocator allocator_;
Zone zone_; Zone zone_;
TestingModule module_; TestingModuleBuilder builder_;
std::vector<std::unique_ptr<WasmFunctionCompiler>> functions_; std::vector<std::unique_ptr<WasmFunctionCompiler>> functions_;
WasmFunctionWrapper wrapper_; WasmFunctionWrapper wrapper_;
bool compiled_ = false; bool compiled_ = false;
...@@ -834,7 +834,7 @@ class WasmRunner : public WasmRunnerBase { ...@@ -834,7 +834,7 @@ class WasmRunner : public WasmRunnerBase {
}; };
set_trap_callback_for_testing(trap_callback); set_trap_callback_for_testing(trap_callback);
wrapper_.SetInnerCode(module_.GetFunctionCode(0)); wrapper_.SetInnerCode(builder_.GetFunctionCode(0));
CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(),
wrapper_.GetWrapperCode(), wrapper_.signature()); wrapper_.GetWrapperCode(), wrapper_.signature());
int32_t result = runner.Call(static_cast<void*>(&p)..., int32_t result = runner.Call(static_cast<void*>(&p)...,
...@@ -851,7 +851,7 @@ class WasmRunner : public WasmRunnerBase { ...@@ -851,7 +851,7 @@ class WasmRunner : public WasmRunnerBase {
std::array<WasmValue, sizeof...(p)> args{{WasmValue(p)...}}; std::array<WasmValue, sizeof...(p)> args{{WasmValue(p)...}};
thread->InitFrame(function(), args.data()); thread->InitFrame(function(), args.data());
WasmInterpreter::HeapObjectsScope heap_objects_scope( WasmInterpreter::HeapObjectsScope heap_objects_scope(
interpreter(), module().instance_object()); interpreter(), builder().instance_object());
if (thread->Run() == WasmInterpreter::FINISHED) { if (thread->Run() == WasmInterpreter::FINISHED) {
WasmValue val = thread->GetReturnValue(); WasmValue val = thread->GetReturnValue();
possible_nondeterminism_ |= thread->PossibleNondeterminism(); possible_nondeterminism_ |= thread->PossibleNondeterminism();
......
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