[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: Mircea Trofin <mtrofin@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#47419}
This commit is contained in:
parent
d04660db3f
commit
ed06fc9127
@ -36,8 +36,8 @@ class CWasmEntryArgTester {
|
||||
sig_(runner_.template CreateSig<ReturnType, Args...>()) {
|
||||
std::vector<uint8_t> code{wasm_function_bytes};
|
||||
runner_.Build(code.data(), code.data() + code.size());
|
||||
wasm_code_ = runner_.module().GetFunctionCode(0);
|
||||
Handle<WasmInstanceObject> instance(runner_.module().instance_object());
|
||||
wasm_code_ = runner_.builder().GetFunctionCode(0);
|
||||
Handle<WasmInstanceObject> instance(runner_.builder().instance_object());
|
||||
Handle<WasmDebugInfo> debug_info =
|
||||
WasmInstanceObject::GetOrCreateDebugInfo(instance);
|
||||
c_wasm_entry_fn_ = WasmDebugInfo::GetCWasmEntry(debug_info, sig_);
|
||||
|
@ -1212,7 +1212,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) {
|
||||
|
||||
for (size_t m = 0; m < arraysize(loads); m++) {
|
||||
WasmRunner<int64_t> r(execution_mode);
|
||||
byte* memory = r.module().AddMemoryElems<byte>(16);
|
||||
byte* memory = r.builder().AddMemoryElems<byte>(16);
|
||||
|
||||
byte code[] = {
|
||||
kExprI32Const, 8, // --
|
||||
@ -1234,7 +1234,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) {
|
||||
// Try a bunch of different negative values.
|
||||
for (int i = -1; i >= -128; i -= 11) {
|
||||
int size = 1 << m;
|
||||
r.module().BlankMemory();
|
||||
r.builder().BlankMemory();
|
||||
memory[size - 1] = static_cast<byte>(i); // set the high order byte.
|
||||
|
||||
int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8);
|
||||
@ -1309,14 +1309,14 @@ WASM_EXEC_TEST(I64UConvertF64b) {
|
||||
WASM_EXEC_TEST(I64ReinterpretF64) {
|
||||
REQUIRE(I64ReinterpretF64);
|
||||
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(
|
||||
WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)));
|
||||
|
||||
FOR_INT32_INPUTS(i) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -1334,7 +1334,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) {
|
||||
WASM_EXEC_TEST(F64ReinterpretI64) {
|
||||
REQUIRE(F64ReinterpretI64);
|
||||
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,
|
||||
WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))),
|
||||
@ -1343,25 +1343,25 @@ WASM_EXEC_TEST(F64ReinterpretI64) {
|
||||
FOR_INT32_INPUTS(i) {
|
||||
int64_t expected = static_cast<int64_t>(*i) * 0x300010001;
|
||||
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) {
|
||||
REQUIRE(I64LoadStore);
|
||||
WasmRunner<int64_t> r(execution_mode);
|
||||
int64_t* memory = r.module().AddMemoryElems<int64_t>(8);
|
||||
r.module().RandomizeMemory(1111);
|
||||
int64_t* memory = r.builder().AddMemoryElems<int64_t>(8);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
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());
|
||||
|
||||
r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
|
||||
r.builder().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
|
||||
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());
|
||||
}
|
||||
|
||||
@ -1369,19 +1369,19 @@ WASM_EXEC_TEST(LoadMemI64_alignment) {
|
||||
REQUIRE(I64LoadStore);
|
||||
for (byte alignment = 0; alignment <= 3; alignment++) {
|
||||
WasmRunner<int64_t> r(execution_mode);
|
||||
int64_t* memory = r.module().AddMemoryElems<int64_t>(8);
|
||||
r.module().RandomizeMemory(1111);
|
||||
int64_t* memory = r.builder().AddMemoryElems<int64_t>(8);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r,
|
||||
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());
|
||||
|
||||
r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
|
||||
r.builder().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -1393,7 +1393,7 @@ WASM_EXEC_TEST(MemI64_Sum) {
|
||||
REQUIRE(I64Phi);
|
||||
const int kNumElems = 20;
|
||||
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);
|
||||
|
||||
BUILD(r, WASM_WHILE(
|
||||
@ -1409,10 +1409,10 @@ WASM_EXEC_TEST(MemI64_Sum) {
|
||||
|
||||
// Run 4 trials.
|
||||
for (int i = 0; i < 3; i++) {
|
||||
r.module().RandomizeMemory(i * 33);
|
||||
r.builder().RandomizeMemory(i * 33);
|
||||
uint64_t expected = 0;
|
||||
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));
|
||||
CHECK_EQ(expected, result);
|
||||
@ -1424,15 +1424,15 @@ WASM_EXEC_TEST(StoreMemI64_alignment) {
|
||||
|
||||
for (byte i = 0; i <= 3; i++) {
|
||||
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,
|
||||
WASM_GET_LOCAL(0)),
|
||||
WASM_GET_LOCAL(0));
|
||||
r.module().RandomizeMemory(1111);
|
||||
r.module().WriteMemory<int64_t>(&memory[0], 0);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
r.builder().WriteMemory<int64_t>(&memory[0], 0);
|
||||
|
||||
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) {
|
||||
REQUIRE(I64And);
|
||||
REQUIRE(DepthFirst);
|
||||
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
|
||||
BUILD(r, WASM_SET_GLOBAL(
|
||||
0, WASM_I64_AND(WASM_GET_GLOBAL(0),
|
||||
WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
|
||||
WASM_ZERO);
|
||||
|
||||
r.module().WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL);
|
||||
r.builder().WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL);
|
||||
for (int i = 9; i < 444444; i += 111111) {
|
||||
int64_t expected = *global & i;
|
||||
r.Call(i);
|
||||
@ -1506,8 +1506,8 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) {
|
||||
|
||||
for (size_t m = 0; m < arraysize(machineTypes); m++) {
|
||||
WasmRunner<int32_t, uint32_t> r(execution_mode);
|
||||
byte* memory = r.module().AddMemoryElems<byte>(32);
|
||||
r.module().RandomizeMemory(1119 + static_cast<int>(m));
|
||||
byte* memory = r.builder().AddMemoryElems<byte>(32);
|
||||
r.builder().RandomizeMemory(1119 + static_cast<int>(m));
|
||||
|
||||
BUILD(r, WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0),
|
||||
WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)),
|
||||
@ -1526,14 +1526,14 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) {
|
||||
|
||||
WASM_EXEC_TEST(UnalignedInt64Load) {
|
||||
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));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedInt64Store) {
|
||||
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,
|
||||
WASM_I64V_1(1)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1554,9 +1554,9 @@ static void CompileCallIndirectMany(ValueType param) {
|
||||
WasmRunner<void> r(kExecuteCompiled);
|
||||
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
|
||||
|
||||
r.module().AddSignature(sig);
|
||||
r.module().AddSignature(sig);
|
||||
r.module().AddIndirectFunctionTable(nullptr, 0);
|
||||
r.builder().AddSignature(sig);
|
||||
r.builder().AddSignature(sig);
|
||||
r.builder().AddIndirectFunctionTable(nullptr, 0);
|
||||
|
||||
WasmFunctionCompiler& t = r.NewFunction(sig);
|
||||
|
||||
@ -1590,7 +1590,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
|
||||
v8::internal::AccountingAllocator allocator;
|
||||
Zone zone(&allocator, ZONE_NAME);
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemory(1024);
|
||||
r.builder().AddMemory(1024);
|
||||
MachineType* memtypes = &mixed[start];
|
||||
MachineType result = memtypes[which];
|
||||
|
||||
@ -1634,14 +1634,14 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
|
||||
|
||||
// Run the code.
|
||||
for (int t = 0; t < 10; t++) {
|
||||
r.module().RandomizeMemory();
|
||||
r.builder().RandomizeMemory();
|
||||
CHECK_EQ(kExpected, r.Call());
|
||||
|
||||
int size = WasmOpcodes::MemSize(result);
|
||||
for (int i = 0; i < size; i++) {
|
||||
int base = (which + 1) * kElemSize;
|
||||
byte expected = r.module().raw_mem_at<byte>(base + i);
|
||||
byte result = r.module().raw_mem_at<byte>(i);
|
||||
byte expected = r.builder().raw_mem_at<byte>(base + i);
|
||||
byte result = r.builder().raw_mem_at<byte>(i);
|
||||
CHECK_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
@ -1658,7 +1658,7 @@ WASM_EXEC_TEST(Regress5874) {
|
||||
REQUIRE(I64LoadStore);
|
||||
REQUIRE(I64Const);
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<int64_t>(8);
|
||||
r.builder().AddMemoryElems<int64_t>(8);
|
||||
|
||||
BUILD(r, kExprI64Const, 0x00, // --
|
||||
kExprI32ConvertI64, // --
|
||||
|
@ -39,7 +39,7 @@ uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) {
|
||||
|
||||
WASM_EXEC_TEST(Int32AsmjsDivS) {
|
||||
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)));
|
||||
const int32_t kMin = std::numeric_limits<int32_t>::min();
|
||||
CHECK_EQ(0, r.Call(0, 100));
|
||||
@ -51,7 +51,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS) {
|
||||
|
||||
WASM_EXEC_TEST(Int32AsmjsRemS) {
|
||||
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)));
|
||||
const int32_t kMin = std::numeric_limits<int32_t>::min();
|
||||
CHECK_EQ(33, r.Call(133, 100));
|
||||
@ -63,7 +63,7 @@ WASM_EXEC_TEST(Int32AsmjsRemS) {
|
||||
|
||||
WASM_EXEC_TEST(Int32AsmjsDivU) {
|
||||
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)));
|
||||
const int32_t kMin = std::numeric_limits<int32_t>::min();
|
||||
CHECK_EQ(0, r.Call(0, 100));
|
||||
@ -75,7 +75,7 @@ WASM_EXEC_TEST(Int32AsmjsDivU) {
|
||||
|
||||
WASM_EXEC_TEST(Int32AsmjsRemU) {
|
||||
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)));
|
||||
const int32_t kMin = std::numeric_limits<int32_t>::min();
|
||||
CHECK_EQ(17, r.Call(217, 100));
|
||||
@ -87,7 +87,7 @@ WASM_EXEC_TEST(Int32AsmjsRemU) {
|
||||
|
||||
WASM_EXEC_TEST(I32AsmjsSConvertF32) {
|
||||
WasmRunner<int32_t, float> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
|
||||
|
||||
FOR_FLOAT32_INPUTS(i) {
|
||||
@ -98,7 +98,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) {
|
||||
|
||||
WASM_EXEC_TEST(I32AsmjsSConvertF64) {
|
||||
WasmRunner<int32_t, double> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
|
||||
|
||||
FOR_FLOAT64_INPUTS(i) {
|
||||
@ -109,7 +109,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) {
|
||||
|
||||
WASM_EXEC_TEST(I32AsmjsUConvertF32) {
|
||||
WasmRunner<uint32_t, float> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
|
||||
|
||||
FOR_FLOAT32_INPUTS(i) {
|
||||
@ -120,7 +120,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) {
|
||||
|
||||
WASM_EXEC_TEST(I32AsmjsUConvertF64) {
|
||||
WasmRunner<uint32_t, double> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
|
||||
|
||||
FOR_FLOAT64_INPUTS(i) {
|
||||
@ -131,9 +131,9 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemI32_oob_asm) {
|
||||
WasmRunner<int32_t, uint32_t> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
r.module().RandomizeMemory(1112);
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().RandomizeMemory(1112);
|
||||
|
||||
BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -151,9 +151,9 @@ WASM_EXEC_TEST(LoadMemI32_oob_asm) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemF32_oob_asm) {
|
||||
WasmRunner<float, uint32_t> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
float* memory = r.module().AddMemoryElems<float>(8);
|
||||
r.module().RandomizeMemory(1112);
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
float* memory = r.builder().AddMemoryElems<float>(8);
|
||||
r.builder().RandomizeMemory(1112);
|
||||
|
||||
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -171,9 +171,9 @@ WASM_EXEC_TEST(LoadMemF32_oob_asm) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemF64_oob_asm) {
|
||||
WasmRunner<double, uint32_t> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
double* memory = r.module().AddMemoryElems<double>(8);
|
||||
r.module().RandomizeMemory(1112);
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
double* memory = r.builder().AddMemoryElems<double>(8);
|
||||
r.builder().RandomizeMemory(1112);
|
||||
|
||||
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -193,9 +193,9 @@ WASM_EXEC_TEST(LoadMemF64_oob_asm) {
|
||||
|
||||
WASM_EXEC_TEST(StoreMemI32_oob_asm) {
|
||||
WasmRunner<int32_t, uint32_t, uint32_t> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
r.module().RandomizeMemory(1112);
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().RandomizeMemory(1112);
|
||||
|
||||
BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0),
|
||||
WASM_GET_LOCAL(1)));
|
||||
@ -228,12 +228,12 @@ WASM_EXEC_TEST(StoreMemI32_oob_asm) {
|
||||
#define INT_LOAD_TEST(OP_TYPE) \
|
||||
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
|
||||
WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \
|
||||
r.module().ChangeOriginToAsmjs(); \
|
||||
r.builder().ChangeOriginToAsmjs(); \
|
||||
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)); \
|
||||
CHECK_NE( \
|
||||
0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \
|
||||
0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
|
||||
}
|
||||
|
||||
@ -242,12 +242,12 @@ FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
|
||||
#define INT_STORE_TEST(OP_TYPE) \
|
||||
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
|
||||
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))); \
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
|
||||
RelocInfo::WASM_MEMORY_REFERENCE)); \
|
||||
CHECK_NE( \
|
||||
0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0), \
|
||||
0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
|
||||
}
|
||||
|
||||
@ -255,46 +255,46 @@ FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
|
||||
|
||||
TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
|
||||
WasmRunner<float, uint32_t> r(kExecuteCompiled);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
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));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0),
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
||||
TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
|
||||
WasmRunner<float, uint32_t, float> r(kExecuteCompiled);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, 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));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0),
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
||||
TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
|
||||
WasmRunner<double, uint32_t> r(kExecuteCompiled);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
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));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0),
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
||||
TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
|
||||
WasmRunner<double, uint32_t, double> r(kExecuteCompiled);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, 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));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.module().GetFunctionCode(0),
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
@ -42,17 +42,17 @@ T Xor(T a, T b) {
|
||||
void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) {
|
||||
EXPERIMENTAL_FLAG_SCOPE(threads);
|
||||
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)));
|
||||
|
||||
FOR_UINT32_INPUTS(i) {
|
||||
uint32_t initial = *i;
|
||||
FOR_UINT32_INPUTS(j) {
|
||||
r.module().WriteMemory(&memory[0], initial);
|
||||
r.builder().WriteMemory(&memory[0], initial);
|
||||
CHECK_EQ(initial, r.Call(*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); }
|
||||
void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) {
|
||||
EXPERIMENTAL_FLAG_SCOPE(threads);
|
||||
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)));
|
||||
|
||||
FOR_UINT16_INPUTS(i) {
|
||||
uint16_t initial = *i;
|
||||
FOR_UINT16_INPUTS(j) {
|
||||
r.module().WriteMemory(&memory[0], initial);
|
||||
r.builder().WriteMemory(&memory[0], initial);
|
||||
CHECK_EQ(initial, r.Call(*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); }
|
||||
void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) {
|
||||
EXPERIMENTAL_FLAG_SCOPE(threads);
|
||||
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)));
|
||||
|
||||
FOR_UINT8_INPUTS(i) {
|
||||
uint8_t initial = *i;
|
||||
FOR_UINT8_INPUTS(j) {
|
||||
r.module().WriteMemory(&memory[0], initial);
|
||||
r.builder().WriteMemory(&memory[0], initial);
|
||||
CHECK_EQ(initial, r.Call(*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) {
|
||||
TEST(GrowMemory) {
|
||||
{
|
||||
WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted);
|
||||
r.module().AddMemory(WasmModule::kPageSize);
|
||||
r.module().SetMaxMemPages(10);
|
||||
r.builder().AddMemory(WasmModule::kPageSize);
|
||||
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(kExecuteInterpreted);
|
||||
r.module().AddMemory(WasmModule::kPageSize);
|
||||
r.module().SetMaxMemPages(10);
|
||||
r.builder().AddMemory(WasmModule::kPageSize);
|
||||
r.builder().SetMaxMemPages(10);
|
||||
BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
|
||||
CHECK_EQ(-1, r.Call(11));
|
||||
}
|
||||
@ -316,7 +316,7 @@ TEST(GrowMemoryPreservesData) {
|
||||
int32_t index = 16;
|
||||
int32_t value = 2335;
|
||||
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),
|
||||
WASM_I32V(value)),
|
||||
WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP,
|
||||
@ -327,7 +327,7 @@ TEST(GrowMemoryPreservesData) {
|
||||
TEST(GrowMemoryInvalidSize) {
|
||||
// Grow memory by an invalid amount without initial memory.
|
||||
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)));
|
||||
CHECK_EQ(-1, r.Call(1048575));
|
||||
}
|
||||
@ -368,7 +368,7 @@ TEST(TestPossibleNondeterminism) {
|
||||
{
|
||||
int32_t index = 16;
|
||||
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),
|
||||
WASM_GET_LOCAL(0)),
|
||||
WASM_I32V(index));
|
||||
@ -380,7 +380,7 @@ TEST(TestPossibleNondeterminism) {
|
||||
{
|
||||
int32_t index = 16;
|
||||
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),
|
||||
WASM_GET_LOCAL(0)),
|
||||
WASM_I32V(index));
|
||||
@ -423,7 +423,7 @@ TEST(WasmInterpreterActivations) {
|
||||
|
||||
TEST(InterpreterLoadWithoutMemory) {
|
||||
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)));
|
||||
CHECK_TRAP32(r.Call(0));
|
||||
}
|
||||
|
@ -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;
|
||||
static const char* formals[kMaxParams] = {"",
|
||||
"a",
|
||||
@ -67,7 +68,7 @@ uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) {
|
||||
SNPrintF(source, "(function(%s) { return %c; })",
|
||||
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,
|
||||
@ -99,7 +100,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, double a,
|
||||
TEST(Run_Int32Sub_jswrapped) {
|
||||
WasmRunner<int, int, int> r(kExecuteCompiled);
|
||||
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(-8723487, jsfunc, -8000000, 723487);
|
||||
@ -108,7 +109,7 @@ TEST(Run_Int32Sub_jswrapped) {
|
||||
TEST(Run_Float32Div_jswrapped) {
|
||||
WasmRunner<float, float, float> r(kExecuteCompiled);
|
||||
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(64, jsfunc, -16, -0.25);
|
||||
@ -117,7 +118,7 @@ TEST(Run_Float32Div_jswrapped) {
|
||||
TEST(Run_Float64Add_jswrapped) {
|
||||
WasmRunner<double, double, double> r(kExecuteCompiled);
|
||||
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(-5.5, jsfunc, -5.25, -0.25);
|
||||
@ -126,7 +127,7 @@ TEST(Run_Float64Add_jswrapped) {
|
||||
TEST(Run_I32Popcount_jswrapped) {
|
||||
WasmRunner<int, int> r(kExecuteCompiled);
|
||||
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(3, jsfunc, 11, 0);
|
||||
@ -137,10 +138,10 @@ TEST(Run_CallJS_Add_jswrapped) {
|
||||
WasmRunner<int, int> r(kExecuteCompiled);
|
||||
TestSignatures sigs;
|
||||
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)));
|
||||
|
||||
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(199, jsfunc, 100, -1);
|
||||
@ -158,7 +159,7 @@ void RunJSSelectTest(int which) {
|
||||
FunctionSig sig(1, num_params, types);
|
||||
|
||||
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);
|
||||
|
||||
{
|
||||
@ -175,7 +176,7 @@ void RunJSSelectTest(int which) {
|
||||
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);
|
||||
EXPECT_CALL(expected, jsfunc, 0.0, 0.0);
|
||||
}
|
||||
@ -234,7 +235,7 @@ void RunWASMSelectTest(int which) {
|
||||
WasmRunner<void> r(kExecuteCompiled);
|
||||
WasmFunctionCompiler& t = r.NewFunction(&sig);
|
||||
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)),
|
||||
@ -306,7 +307,7 @@ void RunWASMSelectAlignTest(int num_args, int num_params) {
|
||||
WasmRunner<void> r(kExecuteCompiled);
|
||||
WasmFunctionCompiler& t = r.NewFunction(&sig);
|
||||
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)),
|
||||
isolate->factory()->NewNumber(inputs.arg_d(1)),
|
||||
@ -416,12 +417,12 @@ void RunJSSelectAlignTest(int num_args, int num_params) {
|
||||
// Call different select JS functions.
|
||||
for (int which = 0; which < num_params; which++) {
|
||||
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);
|
||||
WasmFunctionCompiler& t = r.NewFunction(&sig);
|
||||
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[] = {
|
||||
factory->NewNumber(inputs.arg_d(0)),
|
||||
|
@ -26,19 +26,19 @@ using namespace v8::internal::compiler;
|
||||
WasmRunner<C_TYPE, C_TYPE> r(kExecuteCompiled); \
|
||||
Isolate* isolate = CcTest::i_isolate(); \
|
||||
\
|
||||
r.module().AddGlobal<C_TYPE>(); \
|
||||
r.module().AddGlobal<C_TYPE>(); \
|
||||
r.builder().AddGlobal<C_TYPE>(); \
|
||||
r.builder().AddGlobal<C_TYPE>(); \
|
||||
\
|
||||
/* global = global + p0 */ \
|
||||
BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \
|
||||
WASM_GET_GLOBAL(0)); \
|
||||
CHECK_EQ(1, r.module().CodeTableLength()); \
|
||||
CHECK_EQ(1, r.builder().CodeTableLength()); \
|
||||
\
|
||||
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 old_addresses[4]; \
|
||||
|
@ -1534,8 +1534,8 @@ void RunBinaryLaneOpTest(
|
||||
const std::array<T, kSimd128Size / sizeof(T)>& expected) {
|
||||
WasmRunner<int32_t> r(kExecuteCompiled);
|
||||
// Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7].
|
||||
T* src0 = r.module().AddGlobal<T>(kWasmS128);
|
||||
T* src1 = r.module().AddGlobal<T>(kWasmS128);
|
||||
T* src0 = r.builder().AddGlobal<T>(kWasmS128);
|
||||
T* src1 = r.builder().AddGlobal<T>(kWasmS128);
|
||||
static const int kElems = kSimd128Size / sizeof(T);
|
||||
for (int i = 0; i < kElems; i++) {
|
||||
src0[i] = i;
|
||||
@ -2096,7 +2096,7 @@ const T& GetScalar(T* v, int lane) {
|
||||
|
||||
WASM_SIMD_TEST(SimdI32x4GetGlobal) {
|
||||
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}});
|
||||
r.AllocateLocal(kWasmI32);
|
||||
BUILD(
|
||||
@ -2119,7 +2119,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) {
|
||||
|
||||
WASM_SIMD_TEST(SimdI32x4SetGlobal) {
|
||||
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))),
|
||||
WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
|
||||
WASM_I32V(34))),
|
||||
@ -2141,7 +2141,7 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) {
|
||||
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
|
||||
WASM_SIMD_TEST(SimdF32x4GetGlobal) {
|
||||
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}});
|
||||
r.AllocateLocal(kWasmI32);
|
||||
BUILD(
|
||||
@ -2164,7 +2164,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) {
|
||||
|
||||
WASM_SIMD_TEST(SimdF32x4SetGlobal) {
|
||||
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))),
|
||||
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
|
||||
WASM_F32(45.5))),
|
||||
@ -2186,14 +2186,14 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) {
|
||||
V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
|
||||
WASM_SIMD_TEST(SimdLoadStoreLoad) {
|
||||
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)),
|
||||
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_ZERO)));
|
||||
|
||||
FOR_INT32_INPUTS(i) {
|
||||
int32_t expected = *i;
|
||||
r.module().WriteMemory(&memory[0], expected);
|
||||
r.builder().WriteMemory(&memory[0], expected);
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ WASM_EXEC_TEST(Int32DivS_byzero_const) {
|
||||
WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) {
|
||||
for (int8_t denom = -2; denom < 8; ++denom) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_I32_ASMJS_DIVS(WASM_GET_LOCAL(0), WASM_I32V_1(denom)));
|
||||
FOR_INT32_INPUTS(i) {
|
||||
if (denom == 0) {
|
||||
@ -424,7 +424,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) {
|
||||
WASM_EXEC_TEST(Int32AsmjsRemS_byzero_const) {
|
||||
for (int8_t denom = -2; denom < 8; ++denom) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.module().ChangeOriginToAsmjs();
|
||||
r.builder().ChangeOriginToAsmjs();
|
||||
BUILD(r, WASM_I32_ASMJS_REMS(WASM_GET_LOCAL(0), WASM_I32V_1(denom)));
|
||||
FOR_INT32_INPUTS(i) {
|
||||
if (denom == 0) {
|
||||
@ -455,7 +455,7 @@ WASM_EXEC_TEST(Int32DivU_byzero_const) {
|
||||
|
||||
WASM_EXEC_TEST(Int32DivS_trap_effect) {
|
||||
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<int32_t>(8);
|
||||
r.builder().AddMemoryElems<int32_t>(8);
|
||||
|
||||
BUILD(r, WASM_IF_ELSE_I(
|
||||
WASM_GET_LOCAL(0),
|
||||
@ -849,7 +849,7 @@ WASM_EXEC_TEST(Br_height) {
|
||||
|
||||
WASM_EXEC_TEST(Regression_660262) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<int32_t>(8);
|
||||
r.builder().AddMemoryElems<int32_t>(8);
|
||||
BUILD(r, kExprI32Const, 0x00, kExprI32Const, 0x00, kExprI32LoadMem, 0x00,
|
||||
0x0f, kExprBrTable, 0x00, 0x80, 0x00); // entries=0
|
||||
r.Call();
|
||||
@ -1034,21 +1034,21 @@ WASM_EXEC_TEST(BrTable_loop_target) {
|
||||
|
||||
WASM_EXEC_TEST(F32ReinterpretI32) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
|
||||
BUILD(r, WASM_I32_REINTERPRET_F32(
|
||||
WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)));
|
||||
|
||||
FOR_INT32_INPUTS(i) {
|
||||
int32_t expected = *i;
|
||||
r.module().WriteMemory(&memory[0], expected);
|
||||
r.builder().WriteMemory(&memory[0], expected);
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(I32ReinterpretF32) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
|
||||
BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
|
||||
WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))),
|
||||
@ -1057,7 +1057,7 @@ WASM_EXEC_TEST(I32ReinterpretF32) {
|
||||
FOR_INT32_INPUTS(i) {
|
||||
int32_t expected = *i;
|
||||
CHECK_EQ(107, r.Call(expected));
|
||||
CHECK_EQ(expected, r.module().ReadMemory(&memory[0]));
|
||||
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1080,7 +1080,7 @@ WASM_EXEC_TEST(LoadMaxUint32Offset) {
|
||||
// TODO(eholk): Fix this test for the trap handler.
|
||||
if (trap_handler::UseTrapHandler()) return;
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<int32_t>(8);
|
||||
r.builder().AddMemoryElems<int32_t>(8);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), // type
|
||||
U32V_5(0xffffffff), // offset
|
||||
@ -1091,7 +1091,7 @@ WASM_EXEC_TEST(LoadMaxUint32Offset) {
|
||||
|
||||
WASM_EXEC_TEST(LoadStoreLoad) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
|
||||
BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
|
||||
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
|
||||
@ -1099,35 +1099,35 @@ WASM_EXEC_TEST(LoadStoreLoad) {
|
||||
|
||||
FOR_INT32_INPUTS(i) {
|
||||
int32_t expected = *i;
|
||||
r.module().WriteMemory(&memory[0], expected);
|
||||
r.builder().WriteMemory(&memory[0], expected);
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat32Load) {
|
||||
WasmRunner<float> r(execution_mode);
|
||||
r.module().AddMemoryElems<float>(8);
|
||||
r.builder().AddMemoryElems<float>(8);
|
||||
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE, 2));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat64Load) {
|
||||
WasmRunner<double> r(execution_mode);
|
||||
r.module().AddMemoryElems<double>(8);
|
||||
r.builder().AddMemoryElems<double>(8);
|
||||
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE, 3));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedInt32Load) {
|
||||
WasmRunner<uint32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<uint32_t>(8);
|
||||
r.builder().AddMemoryElems<uint32_t>(8);
|
||||
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedInt32Store) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<uint32_t>(8);
|
||||
r.builder().AddMemoryElems<uint32_t>(8);
|
||||
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2,
|
||||
WASM_I32V_1(1)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1136,7 +1136,7 @@ WASM_EXEC_TEST(UnalignedInt32Store) {
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat32Store) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<float>(8);
|
||||
r.builder().AddMemoryElems<float>(8);
|
||||
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE,
|
||||
2, WASM_F32(1.0)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1145,7 +1145,7 @@ WASM_EXEC_TEST(UnalignedFloat32Store) {
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat64Store) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<double>(8);
|
||||
r.builder().AddMemoryElems<double>(8);
|
||||
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE,
|
||||
3, WASM_F64(1.0)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1482,37 +1482,37 @@ WASM_EXEC_TEST(IfBreak2) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemI32) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
r.module().RandomizeMemory(1111);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 99999999);
|
||||
r.builder().WriteMemory(&memory[0], 99999999);
|
||||
CHECK_EQ(99999999, r.Call(0));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 88888888);
|
||||
r.builder().WriteMemory(&memory[0], 88888888);
|
||||
CHECK_EQ(88888888, r.Call(0));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 77777777);
|
||||
r.builder().WriteMemory(&memory[0], 77777777);
|
||||
CHECK_EQ(77777777, r.Call(0));
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(LoadMemI32_alignment) {
|
||||
for (byte alignment = 0; alignment <= 2; ++alignment) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
r.module().RandomizeMemory(1111);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r,
|
||||
WASM_LOAD_MEM_ALIGNMENT(MachineType::Int32(), WASM_ZERO, alignment));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 0x1a2b3c4d);
|
||||
r.builder().WriteMemory(&memory[0], 0x1a2b3c4d);
|
||||
CHECK_EQ(0x1a2b3c4d, r.Call(0));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 0x5e6f7a8b);
|
||||
r.builder().WriteMemory(&memory[0], 0x5e6f7a8b);
|
||||
CHECK_EQ(0x5e6f7a8b, r.Call(0));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 0x7ca0b1c2);
|
||||
r.builder().WriteMemory(&memory[0], 0x7ca0b1c2);
|
||||
CHECK_EQ(0x7ca0b1c2, r.Call(0));
|
||||
}
|
||||
}
|
||||
@ -1521,12 +1521,12 @@ WASM_EXEC_TEST(LoadMemI32_oob) {
|
||||
// TODO(eholk): Fix this test for the trap handler.
|
||||
if (trap_handler::UseTrapHandler()) return;
|
||||
WasmRunner<int32_t, uint32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
|
||||
r.module().RandomizeMemory(1111);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 88888888);
|
||||
r.builder().WriteMemory(&memory[0], 88888888);
|
||||
CHECK_EQ(88888888, r.Call(0u));
|
||||
for (uint32_t offset = 29; offset < 40; ++offset) {
|
||||
CHECK_TRAP(r.Call(offset));
|
||||
@ -1548,8 +1548,8 @@ WASM_EXEC_TEST(LoadMem_offset_oob) {
|
||||
|
||||
for (size_t m = 0; m < arraysize(machineTypes); ++m) {
|
||||
WasmRunner<int32_t, uint32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<int32_t>(8);
|
||||
r.module().RandomizeMemory(1116 + static_cast<int>(m));
|
||||
r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().RandomizeMemory(1116 + static_cast<int>(m));
|
||||
|
||||
uint32_t boundary = 24 - WasmOpcodes::MemSize(machineTypes[m]);
|
||||
|
||||
@ -1566,23 +1566,23 @@ WASM_EXEC_TEST(LoadMem_offset_oob) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemI32_offset) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(4);
|
||||
r.module().RandomizeMemory(1111);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0)));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 66666666);
|
||||
r.module().WriteMemory(&memory[1], 77777777);
|
||||
r.module().WriteMemory(&memory[2], 88888888);
|
||||
r.module().WriteMemory(&memory[3], 99999999);
|
||||
r.builder().WriteMemory(&memory[0], 66666666);
|
||||
r.builder().WriteMemory(&memory[1], 77777777);
|
||||
r.builder().WriteMemory(&memory[2], 88888888);
|
||||
r.builder().WriteMemory(&memory[3], 99999999);
|
||||
CHECK_EQ(77777777, r.Call(0));
|
||||
CHECK_EQ(88888888, r.Call(4));
|
||||
CHECK_EQ(99999999, r.Call(8));
|
||||
|
||||
r.module().WriteMemory(&memory[0], 11111111);
|
||||
r.module().WriteMemory(&memory[1], 22222222);
|
||||
r.module().WriteMemory(&memory[2], 33333333);
|
||||
r.module().WriteMemory(&memory[3], 44444444);
|
||||
r.builder().WriteMemory(&memory[0], 11111111);
|
||||
r.builder().WriteMemory(&memory[1], 22222222);
|
||||
r.builder().WriteMemory(&memory[2], 33333333);
|
||||
r.builder().WriteMemory(&memory[3], 44444444);
|
||||
CHECK_EQ(22222222, r.Call(0));
|
||||
CHECK_EQ(33333333, r.Call(4));
|
||||
CHECK_EQ(44444444, r.Call(8));
|
||||
@ -1596,14 +1596,14 @@ WASM_EXEC_TEST(LoadMemI32_const_oob_misaligned) {
|
||||
for (byte offset = 0; offset < kMemSize + 5; ++offset) {
|
||||
for (byte index = 0; index < kMemSize + 5; ++index) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<byte>(kMemSize);
|
||||
r.module().RandomizeMemory();
|
||||
r.builder().AddMemoryElems<byte>(kMemSize);
|
||||
r.builder().RandomizeMemory();
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset,
|
||||
WASM_I32V_2(index)));
|
||||
|
||||
if (offset + index <= (kMemSize - sizeof(int32_t))) {
|
||||
CHECK_EQ(r.module().raw_val_at<int32_t>(offset + index), r.Call());
|
||||
CHECK_EQ(r.builder().raw_val_at<int32_t>(offset + index), r.Call());
|
||||
} else {
|
||||
CHECK_TRAP(r.Call());
|
||||
}
|
||||
@ -1618,14 +1618,14 @@ WASM_EXEC_TEST(LoadMemI32_const_oob) {
|
||||
for (byte offset = 0; offset < kMemSize + 5; offset += 4) {
|
||||
for (byte index = 0; index < kMemSize + 5; index += 4) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<byte>(kMemSize);
|
||||
r.module().RandomizeMemory();
|
||||
r.builder().AddMemoryElems<byte>(kMemSize);
|
||||
r.builder().RandomizeMemory();
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset,
|
||||
WASM_I32V_2(index)));
|
||||
|
||||
if (offset + index <= (kMemSize - sizeof(int32_t))) {
|
||||
CHECK_EQ(r.module().raw_val_at<int32_t>(offset + index), r.Call());
|
||||
CHECK_EQ(r.builder().raw_val_at<int32_t>(offset + index), r.Call());
|
||||
} else {
|
||||
CHECK_TRAP(r.Call());
|
||||
}
|
||||
@ -1638,21 +1638,21 @@ WASM_EXEC_TEST(StoreMemI32_alignment) {
|
||||
|
||||
for (byte i = 0; i <= 2; ++i) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(4);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
|
||||
BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ZERO, i,
|
||||
WASM_GET_LOCAL(0)),
|
||||
WASM_GET_LOCAL(0));
|
||||
r.module().RandomizeMemory(1111);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
memory[0] = 0;
|
||||
|
||||
CHECK_EQ(kWritten, r.Call(kWritten));
|
||||
CHECK_EQ(kWritten, r.module().ReadMemory(&memory[0]));
|
||||
CHECK_EQ(kWritten, r.builder().ReadMemory(&memory[0]));
|
||||
}
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(StoreMemI32_offset) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(4);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
|
||||
const int32_t kWritten = 0xaabbccdd;
|
||||
|
||||
BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0),
|
||||
@ -1660,16 +1660,16 @@ WASM_EXEC_TEST(StoreMemI32_offset) {
|
||||
WASM_I32V_5(kWritten));
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
r.module().RandomizeMemory(1111);
|
||||
r.module().WriteMemory(&memory[0], 66666666);
|
||||
r.module().WriteMemory(&memory[1], 77777777);
|
||||
r.module().WriteMemory(&memory[2], 88888888);
|
||||
r.module().WriteMemory(&memory[3], 99999999);
|
||||
r.builder().RandomizeMemory(1111);
|
||||
r.builder().WriteMemory(&memory[0], 66666666);
|
||||
r.builder().WriteMemory(&memory[1], 77777777);
|
||||
r.builder().WriteMemory(&memory[2], 88888888);
|
||||
r.builder().WriteMemory(&memory[3], 99999999);
|
||||
CHECK_EQ(kWritten, r.Call(i * 4));
|
||||
CHECK_EQ(66666666, r.module().ReadMemory(&memory[0]));
|
||||
CHECK_EQ(i == 0 ? kWritten : 77777777, r.module().ReadMemory(&memory[1]));
|
||||
CHECK_EQ(i == 1 ? kWritten : 88888888, r.module().ReadMemory(&memory[2]));
|
||||
CHECK_EQ(i == 2 ? kWritten : 99999999, r.module().ReadMemory(&memory[3]));
|
||||
CHECK_EQ(66666666, r.builder().ReadMemory(&memory[0]));
|
||||
CHECK_EQ(i == 0 ? kWritten : 77777777, r.builder().ReadMemory(&memory[1]));
|
||||
CHECK_EQ(i == 1 ? kWritten : 88888888, r.builder().ReadMemory(&memory[2]));
|
||||
CHECK_EQ(i == 2 ? kWritten : 99999999, r.builder().ReadMemory(&memory[3]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1684,9 +1684,9 @@ WASM_EXEC_TEST(StoreMem_offset_oob) {
|
||||
|
||||
for (size_t m = 0; m < arraysize(machineTypes); ++m) {
|
||||
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),
|
||||
WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)),
|
||||
@ -1706,20 +1706,20 @@ WASM_EXEC_TEST(StoreMem_offset_oob) {
|
||||
WASM_EXEC_TEST(LoadMemI32_P) {
|
||||
const int kNumElems = 8;
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(kNumElems);
|
||||
r.module().RandomizeMemory(2222);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(kNumElems);
|
||||
r.builder().RandomizeMemory(2222);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
|
||||
|
||||
for (int i = 0; i < kNumElems; ++i) {
|
||||
CHECK_EQ(r.module().ReadMemory(&memory[i]), r.Call(i * 4));
|
||||
CHECK_EQ(r.builder().ReadMemory(&memory[i]), r.Call(i * 4));
|
||||
}
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(MemI32_Sum) {
|
||||
const int kNumElems = 20;
|
||||
WasmRunner<uint32_t, int32_t> r(execution_mode);
|
||||
uint32_t* memory = r.module().AddMemoryElems<uint32_t>(kNumElems);
|
||||
uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kNumElems);
|
||||
const byte kSum = r.AllocateLocal(kWasmI32);
|
||||
|
||||
BUILD(r, WASM_WHILE(
|
||||
@ -1735,10 +1735,10 @@ WASM_EXEC_TEST(MemI32_Sum) {
|
||||
|
||||
// Run 4 trials.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
r.module().RandomizeMemory(i * 33);
|
||||
r.builder().RandomizeMemory(i * 33);
|
||||
uint32_t expected = 0;
|
||||
for (size_t j = kNumElems - 1; j > 0; --j) {
|
||||
expected += r.module().ReadMemory(&memory[j]);
|
||||
expected += r.builder().ReadMemory(&memory[j]);
|
||||
}
|
||||
uint32_t result = r.Call(4 * (kNumElems - 1));
|
||||
CHECK_EQ(expected, result);
|
||||
@ -1748,7 +1748,7 @@ WASM_EXEC_TEST(MemI32_Sum) {
|
||||
WASM_EXEC_TEST(CheckMachIntsZero) {
|
||||
const int kNumElems = 55;
|
||||
WasmRunner<uint32_t, int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<uint32_t>(kNumElems);
|
||||
r.builder().AddMemoryElems<uint32_t>(kNumElems);
|
||||
|
||||
BUILD(r, // --
|
||||
/**/ kExprLoop, kLocalVoid, // --
|
||||
@ -1769,20 +1769,20 @@ WASM_EXEC_TEST(CheckMachIntsZero) {
|
||||
/**/ kExprEnd, // --
|
||||
/**/ kExprI32Const, 0); // --
|
||||
|
||||
r.module().BlankMemory();
|
||||
r.builder().BlankMemory();
|
||||
CHECK_EQ(0, r.Call((kNumElems - 1) * 4));
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(MemF32_Sum) {
|
||||
const int kSize = 5;
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<float>(kSize);
|
||||
float* buffer = r.module().raw_mem_start<float>();
|
||||
r.module().WriteMemory(&buffer[0], -99.25f);
|
||||
r.module().WriteMemory(&buffer[1], -888.25f);
|
||||
r.module().WriteMemory(&buffer[2], -77.25f);
|
||||
r.module().WriteMemory(&buffer[3], 66666.25f);
|
||||
r.module().WriteMemory(&buffer[4], 5555.25f);
|
||||
r.builder().AddMemoryElems<float>(kSize);
|
||||
float* buffer = r.builder().raw_mem_start<float>();
|
||||
r.builder().WriteMemory(&buffer[0], -99.25f);
|
||||
r.builder().WriteMemory(&buffer[1], -888.25f);
|
||||
r.builder().WriteMemory(&buffer[2], -77.25f);
|
||||
r.builder().WriteMemory(&buffer[3], 66666.25f);
|
||||
r.builder().WriteMemory(&buffer[4], 5555.25f);
|
||||
const byte kSum = r.AllocateLocal(kWasmF32);
|
||||
|
||||
BUILD(r, WASM_WHILE(
|
||||
@ -1798,8 +1798,8 @@ WASM_EXEC_TEST(MemF32_Sum) {
|
||||
WASM_GET_LOCAL(0));
|
||||
|
||||
CHECK_EQ(0, r.Call(4 * (kSize - 1)));
|
||||
CHECK_NE(-99.25f, r.module().ReadMemory(&buffer[0]));
|
||||
CHECK_EQ(71256.0f, r.module().ReadMemory(&buffer[0]));
|
||||
CHECK_NE(-99.25f, r.builder().ReadMemory(&buffer[0]));
|
||||
CHECK_EQ(71256.0f, r.builder().ReadMemory(&buffer[0]));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -1807,9 +1807,9 @@ T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop,
|
||||
T* buffer, uint32_t size, ValueType astType,
|
||||
MachineType memType) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
T* memory = r.module().AddMemoryElems<T>(size);
|
||||
T* memory = r.builder().AddMemoryElems<T>(size);
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
r.module().WriteMemory(&memory[i], buffer[i]);
|
||||
r.builder().WriteMemory(&memory[i], buffer[i]);
|
||||
}
|
||||
const byte kAccum = r.AllocateLocal(astType);
|
||||
|
||||
@ -1826,7 +1826,7 @@ T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop,
|
||||
WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)),
|
||||
WASM_GET_LOCAL(0));
|
||||
r.Call(static_cast<int>(sizeof(T) * (size - 1)));
|
||||
return r.module().ReadMemory(&memory[0]);
|
||||
return r.builder().ReadMemory(&memory[0]);
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(MemF64_Mul) {
|
||||
@ -1846,7 +1846,7 @@ WASM_EXEC_TEST(Build_Wasm_Infinite_Loop) {
|
||||
|
||||
WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.module().AddMemoryElems<int8_t>(16);
|
||||
r.builder().AddMemoryElems<int8_t>(16);
|
||||
|
||||
// Only build the graph and compile, don't run.
|
||||
BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO), WASM_DROP),
|
||||
@ -1897,7 +1897,7 @@ TEST(Build_Wasm_UnreachableIf2) {
|
||||
|
||||
WASM_EXEC_TEST(Unreachable_Load) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.module().AddMemory(8);
|
||||
r.builder().AddMemory(8);
|
||||
BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)),
|
||||
WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0))));
|
||||
CHECK_EQ(11, r.Call(11));
|
||||
@ -1980,8 +1980,8 @@ TEST(Build_Wasm_SimpleExprs) {
|
||||
WASM_EXEC_TEST(Int32LoadInt8_signext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumElems = 16;
|
||||
int8_t* memory = r.module().AddMemoryElems<int8_t>(kNumElems);
|
||||
r.module().RandomizeMemory();
|
||||
int8_t* memory = r.builder().AddMemoryElems<int8_t>(kNumElems);
|
||||
r.builder().RandomizeMemory();
|
||||
memory[0] = -1;
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -1993,8 +1993,8 @@ WASM_EXEC_TEST(Int32LoadInt8_signext) {
|
||||
WASM_EXEC_TEST(Int32LoadInt8_zeroext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumElems = 16;
|
||||
byte* memory = r.module().AddMemory(kNumElems);
|
||||
r.module().RandomizeMemory(77);
|
||||
byte* memory = r.builder().AddMemory(kNumElems);
|
||||
r.builder().RandomizeMemory(77);
|
||||
memory[0] = 255;
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Uint8(), WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -2006,8 +2006,8 @@ WASM_EXEC_TEST(Int32LoadInt8_zeroext) {
|
||||
WASM_EXEC_TEST(Int32LoadInt16_signext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumBytes = 16;
|
||||
byte* memory = r.module().AddMemory(kNumBytes);
|
||||
r.module().RandomizeMemory(888);
|
||||
byte* memory = r.builder().AddMemory(kNumBytes);
|
||||
r.builder().RandomizeMemory(888);
|
||||
memory[1] = 200;
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int16(), WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -2020,8 +2020,8 @@ WASM_EXEC_TEST(Int32LoadInt16_signext) {
|
||||
WASM_EXEC_TEST(Int32LoadInt16_zeroext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumBytes = 16;
|
||||
byte* memory = r.module().AddMemory(kNumBytes);
|
||||
r.module().RandomizeMemory(9999);
|
||||
byte* memory = r.builder().AddMemory(kNumBytes);
|
||||
r.builder().RandomizeMemory(9999);
|
||||
memory[1] = 204;
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Uint16(), WASM_GET_LOCAL(0)));
|
||||
|
||||
@ -2033,7 +2033,7 @@ WASM_EXEC_TEST(Int32LoadInt16_zeroext) {
|
||||
|
||||
WASM_EXEC_TEST(Int32Global) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* global = r.module().AddGlobal<int32_t>();
|
||||
int32_t* global = r.builder().AddGlobal<int32_t>();
|
||||
// global = global + p0
|
||||
BUILD(r,
|
||||
WASM_SET_GLOBAL(0, WASM_I32_ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))),
|
||||
@ -2052,9 +2052,9 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) {
|
||||
for (int g = 0; g < kNumGlobals; ++g) {
|
||||
// global = global + p0
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* globals[] = {r.module().AddGlobal<int32_t>(),
|
||||
r.module().AddGlobal<int32_t>(),
|
||||
r.module().AddGlobal<int32_t>()};
|
||||
int32_t* globals[] = {r.builder().AddGlobal<int32_t>(),
|
||||
r.builder().AddGlobal<int32_t>(),
|
||||
r.builder().AddGlobal<int32_t>()};
|
||||
|
||||
BUILD(r, WASM_SET_GLOBAL(
|
||||
g, WASM_I32_ADD(WASM_GET_GLOBAL(g), WASM_GET_LOCAL(0))),
|
||||
@ -2078,7 +2078,7 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) {
|
||||
|
||||
WASM_EXEC_TEST(Float32Global) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
float* global = r.module().AddGlobal<float>();
|
||||
float* global = r.builder().AddGlobal<float>();
|
||||
// global = global + p0
|
||||
BUILD(r, WASM_SET_GLOBAL(
|
||||
0, WASM_F32_ADD(WASM_GET_GLOBAL(0),
|
||||
@ -2095,7 +2095,7 @@ WASM_EXEC_TEST(Float32Global) {
|
||||
|
||||
WASM_EXEC_TEST(Float64Global) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
double* global = r.module().AddGlobal<double>();
|
||||
double* global = r.builder().AddGlobal<double>();
|
||||
// global = global + p0
|
||||
BUILD(r, WASM_SET_GLOBAL(
|
||||
0, WASM_F64_ADD(WASM_GET_GLOBAL(0),
|
||||
@ -2113,13 +2113,13 @@ WASM_EXEC_TEST(Float64Global) {
|
||||
WASM_EXEC_TEST(MixedGlobals) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
|
||||
int32_t* unused = r.module().AddGlobal<int32_t>();
|
||||
byte* memory = r.module().AddMemory(32);
|
||||
int32_t* unused = r.builder().AddGlobal<int32_t>();
|
||||
byte* memory = r.builder().AddMemory(32);
|
||||
|
||||
int32_t* var_int32 = r.module().AddGlobal<int32_t>();
|
||||
uint32_t* var_uint32 = r.module().AddGlobal<uint32_t>();
|
||||
float* var_float = r.module().AddGlobal<float>();
|
||||
double* var_double = r.module().AddGlobal<double>();
|
||||
int32_t* var_int32 = r.builder().AddGlobal<int32_t>();
|
||||
uint32_t* var_uint32 = r.builder().AddGlobal<uint32_t>();
|
||||
float* var_float = r.builder().AddGlobal<float>();
|
||||
double* var_double = r.builder().AddGlobal<double>();
|
||||
|
||||
BUILD(r, WASM_SET_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
|
||||
WASM_SET_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
|
||||
@ -2214,8 +2214,8 @@ WASM_EXEC_TEST(CallVoid) {
|
||||
const int32_t kExpected = 414444;
|
||||
// Build the target function.
|
||||
TestSignatures sigs;
|
||||
int32_t* memory = r.module().AddMemoryElems<int32_t>(16 / sizeof(int32_t));
|
||||
r.module().RandomizeMemory();
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(16 / sizeof(int32_t));
|
||||
r.builder().RandomizeMemory();
|
||||
WasmFunctionCompiler& t = r.NewFunction(sigs.v_v());
|
||||
BUILD(t, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V_1(kMemOffset),
|
||||
WASM_I32V_3(kExpected)));
|
||||
@ -2227,7 +2227,7 @@ WASM_EXEC_TEST(CallVoid) {
|
||||
int32_t result = r.Call();
|
||||
CHECK_EQ(kExpected, result);
|
||||
CHECK_EQ(static_cast<int64_t>(kExpected),
|
||||
static_cast<int64_t>(r.module().ReadMemory(&memory[kElemNum])));
|
||||
static_cast<int64_t>(r.builder().ReadMemory(&memory[kElemNum])));
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(Call_Int32Add) {
|
||||
@ -2268,7 +2268,7 @@ WASM_EXEC_TEST(Call_Float32Sub) {
|
||||
|
||||
WASM_EXEC_TEST(Call_Float64Sub) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
double* memory = r.module().AddMemoryElems<double>(16);
|
||||
double* memory = r.builder().AddMemoryElems<double>(16);
|
||||
|
||||
BUILD(r, WASM_STORE_MEM(
|
||||
MachineType::Float64(), WASM_ZERO,
|
||||
@ -2279,16 +2279,16 @@ WASM_EXEC_TEST(Call_Float64Sub) {
|
||||
|
||||
FOR_FLOAT64_INPUTS(i) {
|
||||
FOR_FLOAT64_INPUTS(j) {
|
||||
r.module().WriteMemory(&memory[0], *i);
|
||||
r.module().WriteMemory(&memory[1], *j);
|
||||
r.builder().WriteMemory(&memory[0], *i);
|
||||
r.builder().WriteMemory(&memory[1], *j);
|
||||
double expected = *i - *j;
|
||||
CHECK_EQ(107, r.Call());
|
||||
|
||||
if (expected != expected) {
|
||||
CHECK(r.module().ReadMemory(&memory[0]) !=
|
||||
r.module().ReadMemory(&memory[0]));
|
||||
CHECK(r.builder().ReadMemory(&memory[0]) !=
|
||||
r.builder().ReadMemory(&memory[0]));
|
||||
} else {
|
||||
CHECK_EQ(expected, r.module().ReadMemory(&memory[0]));
|
||||
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2317,7 +2317,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
|
||||
v8::internal::AccountingAllocator allocator;
|
||||
Zone zone(&allocator, ZONE_NAME);
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.module().AddMemory(1024);
|
||||
r.builder().AddMemory(1024);
|
||||
MachineType* memtypes = &mixed[start];
|
||||
MachineType result = memtypes[which];
|
||||
|
||||
@ -2361,14 +2361,14 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
|
||||
|
||||
// Run the code.
|
||||
for (int t = 0; t < 10; ++t) {
|
||||
r.module().RandomizeMemory();
|
||||
r.builder().RandomizeMemory();
|
||||
CHECK_EQ(kExpected, r.Call());
|
||||
|
||||
int size = WasmOpcodes::MemSize(result);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
int base = (which + 1) * kElemSize;
|
||||
byte expected = r.module().raw_mem_at<byte>(base + i);
|
||||
byte result = r.module().raw_mem_at<byte>(i);
|
||||
byte expected = r.builder().raw_mem_at<byte>(base + i);
|
||||
byte result = r.builder().raw_mem_at<byte>(i);
|
||||
CHECK_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
@ -2611,17 +2611,17 @@ WASM_EXEC_TEST(SimpleCallIndirect) {
|
||||
t2.SetSigIndex(1);
|
||||
|
||||
// Signature table.
|
||||
r.module().AddSignature(sigs.f_ff());
|
||||
r.module().AddSignature(sigs.i_ii());
|
||||
r.module().AddSignature(sigs.d_dd());
|
||||
r.builder().AddSignature(sigs.f_ff());
|
||||
r.builder().AddSignature(sigs.i_ii());
|
||||
r.builder().AddSignature(sigs.d_dd());
|
||||
|
||||
// Function table.
|
||||
uint16_t indirect_function_table[] = {
|
||||
static_cast<uint16_t>(t1.function_index()),
|
||||
static_cast<uint16_t>(t2.function_index())};
|
||||
r.module().AddIndirectFunctionTable(indirect_function_table,
|
||||
r.builder().AddIndirectFunctionTable(indirect_function_table,
|
||||
arraysize(indirect_function_table));
|
||||
r.module().PopulateIndirectFunctionTable();
|
||||
r.builder().PopulateIndirectFunctionTable();
|
||||
|
||||
// Build the caller function.
|
||||
BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I32V_2(66),
|
||||
@ -2645,17 +2645,17 @@ WASM_EXEC_TEST(MultipleCallIndirect) {
|
||||
t2.SetSigIndex(1);
|
||||
|
||||
// Signature table.
|
||||
r.module().AddSignature(sigs.f_ff());
|
||||
r.module().AddSignature(sigs.i_ii());
|
||||
r.module().AddSignature(sigs.d_dd());
|
||||
r.builder().AddSignature(sigs.f_ff());
|
||||
r.builder().AddSignature(sigs.i_ii());
|
||||
r.builder().AddSignature(sigs.d_dd());
|
||||
|
||||
// Function table.
|
||||
uint16_t indirect_function_table[] = {
|
||||
static_cast<uint16_t>(t1.function_index()),
|
||||
static_cast<uint16_t>(t2.function_index())};
|
||||
r.module().AddIndirectFunctionTable(indirect_function_table,
|
||||
r.builder().AddIndirectFunctionTable(indirect_function_table,
|
||||
arraysize(indirect_function_table));
|
||||
r.module().PopulateIndirectFunctionTable();
|
||||
r.builder().PopulateIndirectFunctionTable();
|
||||
|
||||
// Build the caller function.
|
||||
BUILD(r, WASM_I32_ADD(
|
||||
@ -2685,9 +2685,9 @@ WASM_EXEC_TEST(CallIndirect_EmptyTable) {
|
||||
t1.SetSigIndex(1);
|
||||
|
||||
// Signature table.
|
||||
r.module().AddSignature(sigs.f_ff());
|
||||
r.module().AddSignature(sigs.i_ii());
|
||||
r.module().AddIndirectFunctionTable(nullptr, 0);
|
||||
r.builder().AddSignature(sigs.f_ff());
|
||||
r.builder().AddSignature(sigs.i_ii());
|
||||
r.builder().AddIndirectFunctionTable(nullptr, 0);
|
||||
|
||||
// Build the caller function.
|
||||
BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I32V_2(66),
|
||||
@ -2715,9 +2715,9 @@ WASM_EXEC_TEST(CallIndirect_canonical) {
|
||||
t3.SetSigIndex(2);
|
||||
|
||||
// Signature table.
|
||||
r.module().AddSignature(sigs.i_ii());
|
||||
r.module().AddSignature(sigs.i_ii());
|
||||
r.module().AddSignature(sigs.f_ff());
|
||||
r.builder().AddSignature(sigs.i_ii());
|
||||
r.builder().AddSignature(sigs.i_ii());
|
||||
r.builder().AddSignature(sigs.f_ff());
|
||||
|
||||
// Function table.
|
||||
uint16_t i1 = static_cast<uint16_t>(t1.function_index());
|
||||
@ -2725,9 +2725,9 @@ WASM_EXEC_TEST(CallIndirect_canonical) {
|
||||
uint16_t i3 = static_cast<uint16_t>(t3.function_index());
|
||||
uint16_t indirect_function_table[] = {i1, i2, i3, i1, i2};
|
||||
|
||||
r.module().AddIndirectFunctionTable(indirect_function_table,
|
||||
r.builder().AddIndirectFunctionTable(indirect_function_table,
|
||||
arraysize(indirect_function_table));
|
||||
r.module().PopulateIndirectFunctionTable();
|
||||
r.builder().PopulateIndirectFunctionTable();
|
||||
|
||||
// Build the caller function.
|
||||
BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I32V_2(77),
|
||||
@ -2935,9 +2935,9 @@ static void CompileCallIndirectMany(ValueType param) {
|
||||
WasmRunner<void> r(kExecuteCompiled);
|
||||
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
|
||||
|
||||
r.module().AddSignature(sig);
|
||||
r.module().AddSignature(sig);
|
||||
r.module().AddIndirectFunctionTable(nullptr, 0);
|
||||
r.builder().AddSignature(sig);
|
||||
r.builder().AddSignature(sig);
|
||||
r.builder().AddIndirectFunctionTable(nullptr, 0);
|
||||
|
||||
WasmFunctionCompiler& t = r.NewFunction(sig);
|
||||
|
||||
|
@ -141,10 +141,10 @@ Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) {
|
||||
void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset,
|
||||
int expected_set_byte_offset = -1) {
|
||||
int func_offset =
|
||||
runner.module().GetFunctionAt(function_index)->code.offset();
|
||||
runner.builder().GetFunctionAt(function_index)->code.offset();
|
||||
int code_offset = func_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<JSObject> fake_breakpoint_object =
|
||||
MakeFakeBreakpoint(runner.main_isolate(), code_offset);
|
||||
@ -270,7 +270,7 @@ TEST(WasmCollectPossibleBreakpoints) {
|
||||
|
||||
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;
|
||||
// Check all locations for function 0.
|
||||
CheckLocations(instance->compiled_module(), {0, 0}, {1, 0},
|
||||
@ -297,7 +297,7 @@ TEST(WasmSimpleBreak) {
|
||||
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
|
||||
|
||||
Handle<JSFunction> main_fun_wrapper =
|
||||
runner.module().WrapCode(runner.function_index());
|
||||
runner.builder().WrapCode(runner.function_index());
|
||||
SetBreakpoint(runner, runner.function_index(), 4, 4);
|
||||
|
||||
BreakHandler count_breaks(isolate, {{4, BreakHandler::Continue}});
|
||||
@ -317,7 +317,7 @@ TEST(WasmSimpleStepping) {
|
||||
|
||||
Isolate* isolate = runner.main_isolate();
|
||||
Handle<JSFunction> main_fun_wrapper =
|
||||
runner.module().WrapCode(runner.function_index());
|
||||
runner.builder().WrapCode(runner.function_index());
|
||||
|
||||
// Set breakpoint at the first I32Const.
|
||||
SetBreakpoint(runner, runner.function_index(), 1, 1);
|
||||
@ -360,7 +360,7 @@ TEST(WasmStepInAndOut) {
|
||||
|
||||
Isolate* isolate = runner.main_isolate();
|
||||
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.
|
||||
SetBreakpoint(runner, f2.function_index(), 19, 19);
|
||||
@ -395,7 +395,7 @@ TEST(WasmGetLocalsAndStack) {
|
||||
|
||||
Isolate* isolate = runner.main_isolate();
|
||||
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
|
||||
// entries + 3x<count, type>).
|
||||
|
@ -38,7 +38,7 @@ class ArgPassingHelper {
|
||||
: isolate_(runner.main_isolate()),
|
||||
expected_lambda_(expected_lambda),
|
||||
debug_info_(WasmInstanceObject::GetOrCreateDebugInfo(
|
||||
runner.module().instance_object())) {
|
||||
runner.builder().instance_object())) {
|
||||
std::vector<uint8_t> inner_code{bytes_inner_function};
|
||||
inner_compiler.Build(inner_code.data(),
|
||||
inner_code.data() + inner_code.size());
|
||||
@ -49,7 +49,7 @@ class ArgPassingHelper {
|
||||
int funcs_to_redict[] = {static_cast<int>(inner_compiler.function_index())};
|
||||
WasmDebugInfo::RedirectToInterpreter(debug_info_,
|
||||
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>
|
||||
|
@ -79,7 +79,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
|
||||
WasmRunner<void> r(kExecuteCompiled);
|
||||
TestSignatures sigs;
|
||||
|
||||
uint32_t js_throwing_index = r.module().AddJsFunction(
|
||||
uint32_t js_throwing_index = r.builder().AddJsFunction(
|
||||
sigs.v_v(),
|
||||
"(function js() {\n function a() {\n throw new Error(); };\n a(); })");
|
||||
|
||||
@ -91,7 +91,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
|
||||
BUILD(f2, WASM_CALL_FUNCTION0(wasm_index_1));
|
||||
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(
|
||||
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
|
||||
@ -132,7 +132,7 @@ TEST(CollectDetailedWasmStack_WasmError) {
|
||||
BUILD(f2, WASM_CALL_FUNCTION0(0));
|
||||
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(
|
||||
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
|
||||
|
@ -71,7 +71,7 @@ TEST(Unreachable) {
|
||||
BUILD(r, WASM_UNREACHABLE);
|
||||
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(
|
||||
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
|
||||
@ -101,7 +101,7 @@ TEST(IllegalLoad) {
|
||||
WasmRunner<void> r(kExecuteCompiled, "main", true);
|
||||
TestSignatures sigs;
|
||||
|
||||
r.module().AddMemory(0L);
|
||||
r.builder().AddMemory(0L);
|
||||
|
||||
BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(),
|
||||
WASM_I32V_1(-3)),
|
||||
@ -113,7 +113,7 @@ TEST(IllegalLoad) {
|
||||
BUILD(f2, WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1));
|
||||
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(
|
||||
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
|
||||
|
@ -73,9 +73,10 @@ const uint32_t kMaxGlobalsSize = 128;
|
||||
// progressively added by a test. In turn, we piecemeal update the runtime
|
||||
// objects, i.e. {WasmInstanceObject}, {WasmCompiledModule} and, if necessary,
|
||||
// the interpreter.
|
||||
class TestingModule {
|
||||
class TestingModuleBuilder {
|
||||
public:
|
||||
explicit TestingModule(Zone* zone, WasmExecutionMode mode = kExecuteCompiled)
|
||||
explicit TestingModuleBuilder(Zone* zone,
|
||||
WasmExecutionMode mode = kExecuteCompiled)
|
||||
: test_module_ptr_(&test_module_),
|
||||
isolate_(CcTest::InitIsolateOnce()),
|
||||
global_offset(0),
|
||||
@ -561,7 +562,7 @@ class WasmFunctionWrapper : private GraphAndBuilders {
|
||||
// interpretation (by adding to the interpreter manually).
|
||||
class WasmFunctionCompiler : private GraphAndBuilders {
|
||||
public:
|
||||
Isolate* isolate() { return testing_module_->isolate(); }
|
||||
Isolate* isolate() { return builder_->isolate(); }
|
||||
Graph* graph() const { return main_graph_; }
|
||||
Zone* zone() const { return graph()->zone(); }
|
||||
CommonOperatorBuilder* common() { return &main_common_; }
|
||||
@ -590,8 +591,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
|
||||
|
||||
CHECK_GE(kMaxInt, end - start);
|
||||
int len = static_cast<int>(end - start);
|
||||
function_->code = {
|
||||
testing_module_->AddBytes(Vector<const byte>(start, len)),
|
||||
function_->code = {builder_->AddBytes(Vector<const byte>(start, len)),
|
||||
static_cast<uint32_t>(len)};
|
||||
|
||||
if (interpreter_) {
|
||||
@ -600,16 +600,16 @@ class WasmFunctionCompiler : private GraphAndBuilders {
|
||||
}
|
||||
|
||||
// Build the TurboFan graph.
|
||||
compiler::ModuleEnv module_env = testing_module_->CreateModuleEnv();
|
||||
compiler::ModuleEnv module_env = builder_->CreateModuleEnv();
|
||||
TestBuildingGraph(zone(), &jsgraph, &module_env, sig,
|
||||
&source_position_table_, start, end,
|
||||
runtime_exception_support_);
|
||||
Handle<Code> code = Compile();
|
||||
testing_module_->SetFunctionCode(function_index(), code);
|
||||
builder_->SetFunctionCode(function_index(), code);
|
||||
|
||||
// Add to code table.
|
||||
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();
|
||||
if (static_cast<int>(function_index()) >= code_table->length()) {
|
||||
Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray(
|
||||
@ -639,21 +639,21 @@ class WasmFunctionCompiler : private GraphAndBuilders {
|
||||
friend class WasmRunnerBase;
|
||||
|
||||
explicit WasmFunctionCompiler(Zone* zone, FunctionSig* sig,
|
||||
TestingModule* module, const char* name,
|
||||
TestingModuleBuilder* builder, const char* name,
|
||||
bool runtime_exception_support)
|
||||
: GraphAndBuilders(zone),
|
||||
jsgraph(module->isolate(), this->graph(), this->common(), nullptr,
|
||||
jsgraph(builder->isolate(), this->graph(), this->common(), nullptr,
|
||||
nullptr, this->machine()),
|
||||
sig(sig),
|
||||
descriptor_(nullptr),
|
||||
testing_module_(module),
|
||||
builder_(builder),
|
||||
local_decls(zone, sig),
|
||||
source_position_table_(this->graph()),
|
||||
interpreter_(module->interpreter()),
|
||||
interpreter_(builder->interpreter()),
|
||||
runtime_exception_support_(runtime_exception_support) {
|
||||
// Get a new function from the testing module.
|
||||
int index = module->AddFunction(sig, Handle<Code>::null(), name);
|
||||
function_ = testing_module_->GetFunctionAt(index);
|
||||
int index = builder->AddFunction(sig, Handle<Code>::null(), name);
|
||||
function_ = builder_->GetFunctionAt(index);
|
||||
}
|
||||
|
||||
Handle<Code> Compile() {
|
||||
@ -681,7 +681,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
|
||||
Handle<FixedArray> deopt_data =
|
||||
isolate()->factory()->NewFixedArray(2, TENURED);
|
||||
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(1, Smi::FromInt(static_cast<int>(function_index())));
|
||||
code->set_deoptimization_data(*deopt_data);
|
||||
@ -700,7 +700,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
|
||||
FunctionSig* sig;
|
||||
// The call descriptor is initialized when the function is compiled.
|
||||
CallDescriptor* descriptor_;
|
||||
TestingModule* testing_module_;
|
||||
TestingModuleBuilder* builder_;
|
||||
Vector<const char> debug_name_;
|
||||
WasmFunction* function_;
|
||||
LocalDeclEncoder local_decls;
|
||||
@ -716,7 +716,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
|
||||
explicit WasmRunnerBase(WasmExecutionMode execution_mode, int num_params,
|
||||
bool runtime_exception_support)
|
||||
: zone_(&allocator_, ZONE_NAME),
|
||||
module_(&zone_, execution_mode),
|
||||
builder_(&zone_, execution_mode),
|
||||
wrapper_(&zone_, num_params),
|
||||
runtime_exception_support_(runtime_exception_support) {}
|
||||
|
||||
@ -742,7 +742,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
|
||||
WasmFunctionCompiler& NewFunction(FunctionSig* sig,
|
||||
const char* name = nullptr) {
|
||||
functions_.emplace_back(new WasmFunctionCompiler(
|
||||
&zone_, sig, &module_, name, runtime_exception_support_));
|
||||
&zone_, sig, &builder_, name, runtime_exception_support_));
|
||||
return *functions_.back();
|
||||
}
|
||||
|
||||
@ -757,10 +757,10 @@ class WasmRunnerBase : public HandleAndZoneScope {
|
||||
return functions_[0]->interpreter_;
|
||||
}
|
||||
bool possible_nondeterminism() { return possible_nondeterminism_; }
|
||||
TestingModule& module() { return module_; }
|
||||
TestingModuleBuilder& builder() { return builder_; }
|
||||
Zone* zone() { return &zone_; }
|
||||
|
||||
bool interpret() { return module_.interpret(); }
|
||||
bool interpret() { return builder_.interpret(); }
|
||||
|
||||
template <typename ReturnType, typename... ParamTypes>
|
||||
FunctionSig* CreateSig() {
|
||||
@ -795,7 +795,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
|
||||
protected:
|
||||
v8::internal::AccountingAllocator allocator_;
|
||||
Zone zone_;
|
||||
TestingModule module_;
|
||||
TestingModuleBuilder builder_;
|
||||
std::vector<std::unique_ptr<WasmFunctionCompiler>> functions_;
|
||||
WasmFunctionWrapper wrapper_;
|
||||
bool compiled_ = false;
|
||||
@ -834,7 +834,7 @@ class WasmRunner : public WasmRunnerBase {
|
||||
};
|
||||
set_trap_callback_for_testing(trap_callback);
|
||||
|
||||
wrapper_.SetInnerCode(module_.GetFunctionCode(0));
|
||||
wrapper_.SetInnerCode(builder_.GetFunctionCode(0));
|
||||
CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(),
|
||||
wrapper_.GetWrapperCode(), wrapper_.signature());
|
||||
int32_t result = runner.Call(static_cast<void*>(&p)...,
|
||||
@ -851,7 +851,7 @@ class WasmRunner : public WasmRunnerBase {
|
||||
std::array<WasmValue, sizeof...(p)> args{{WasmValue(p)...}};
|
||||
thread->InitFrame(function(), args.data());
|
||||
WasmInterpreter::HeapObjectsScope heap_objects_scope(
|
||||
interpreter(), module().instance_object());
|
||||
interpreter(), builder().instance_object());
|
||||
if (thread->Run() == WasmInterpreter::FINISHED) {
|
||||
WasmValue val = thread->GetReturnValue();
|
||||
possible_nondeterminism_ |= thread->PossibleNondeterminism();
|
||||
|
Loading…
Reference in New Issue
Block a user