Index: test/cctest/wasm/test-run-wasm-asmjs.cc |
diff --git a/test/cctest/wasm/test-run-wasm-asmjs.cc b/test/cctest/wasm/test-run-wasm-asmjs.cc |
index 38430f292c59059aae750d17b91b5314a436323b..41871a1ab244ad7078bf0050de66040312aeeda0 100644 |
--- a/test/cctest/wasm/test-run-wasm-asmjs.cc |
+++ b/test/cctest/wasm/test-run-wasm-asmjs.cc |
@@ -38,8 +38,9 @@ |
} |
WASM_EXEC_TEST(Int32AsmjsDivS) { |
- WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
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)); |
@@ -50,8 +51,9 @@ |
} |
WASM_EXEC_TEST(Int32AsmjsRemS) { |
- WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
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)); |
@@ -62,8 +64,9 @@ |
} |
WASM_EXEC_TEST(Int32AsmjsDivU) { |
- WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
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)); |
@@ -74,8 +77,9 @@ |
} |
WASM_EXEC_TEST(Int32AsmjsRemU) { |
- WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
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)); |
@@ -86,8 +90,9 @@ |
} |
WASM_EXEC_TEST(I32AsmjsSConvertF32) { |
- WasmRunner<int32_t, float> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<int32_t> r(&module, MachineType::Float32()); |
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); |
FOR_FLOAT32_INPUTS(i) { |
@@ -97,8 +102,9 @@ |
} |
WASM_EXEC_TEST(I32AsmjsSConvertF64) { |
- WasmRunner<int32_t, double> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<int32_t> r(&module, MachineType::Float64()); |
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); |
FOR_FLOAT64_INPUTS(i) { |
@@ -108,8 +114,9 @@ |
} |
WASM_EXEC_TEST(I32AsmjsUConvertF32) { |
- WasmRunner<uint32_t, float> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<uint32_t> r(&module, MachineType::Float32()); |
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); |
FOR_FLOAT32_INPUTS(i) { |
@@ -119,8 +126,9 @@ |
} |
WASM_EXEC_TEST(I32AsmjsUConvertF64) { |
- WasmRunner<uint32_t, double> r(execution_mode); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<uint32_t> r(&module, MachineType::Float64()); |
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); |
FOR_FLOAT64_INPUTS(i) { |
@@ -130,10 +138,11 @@ |
} |
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); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ int32_t* memory = module.AddMemoryElems<int32_t>(8); |
+ WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
+ module.RandomizeMemory(1112); |
BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
@@ -150,10 +159,11 @@ |
} |
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); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ float* memory = module.AddMemoryElems<float>(8); |
+ WasmRunner<float> r(&module, MachineType::Uint32()); |
+ module.RandomizeMemory(1112); |
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
@@ -170,10 +180,11 @@ |
} |
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); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ double* memory = module.AddMemoryElems<double>(8); |
+ WasmRunner<double> r(&module, MachineType::Uint32()); |
+ module.RandomizeMemory(1112); |
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); |
@@ -192,10 +203,11 @@ |
} |
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); |
+ TestingModule module(execution_mode); |
+ module.ChangeOriginToAsmjs(); |
+ int32_t* memory = module.AddMemoryElems<int32_t>(8); |
+ WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32()); |
+ module.RandomizeMemory(1112); |
BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), |
WASM_GET_LOCAL(1))); |
@@ -225,78 +237,87 @@ |
TEST_BODY(kExprI32AsmjsStoreMem16) \ |
TEST_BODY(kExprI32AsmjsStoreMem) |
-#define INT_LOAD_TEST(OP_TYPE) \ |
- TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
- WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \ |
- r.module().ChangeOriginToAsmjs(); \ |
- BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ |
- CHECK_EQ(1, \ |
- GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ |
- RelocInfo::WASM_MEMORY_REFERENCE)); \ |
- CHECK_NE( \ |
- 0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ |
- RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
+#define INT_LOAD_TEST(OP_TYPE) \ |
+ TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
+ TestingModule module(kExecuteCompiled); \ |
+ module.ChangeOriginToAsmjs(); \ |
+ WasmRunner<int32_t> r(&module, MachineType::Uint32()); \ |
+ BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ |
+ CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
+ RelocInfo::WASM_MEMORY_REFERENCE)); \ |
+ CHECK_NE( \ |
+ 0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
+ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
} |
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(); \ |
- BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ |
- CHECK_EQ(1, \ |
- GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ |
- RelocInfo::WASM_MEMORY_REFERENCE)); \ |
- CHECK_NE( \ |
- 0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ |
- RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
+#define INT_STORE_TEST(OP_TYPE) \ |
+ TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
+ TestingModule module(kExecuteCompiled); \ |
+ module.ChangeOriginToAsmjs(); \ |
+ WasmRunner<int32_t> r(&module, MachineType::Uint32(), \ |
+ MachineType::Uint32()); \ |
+ BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ |
+ CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
+ RelocInfo::WASM_MEMORY_REFERENCE)); \ |
+ CHECK_NE( \ |
+ 0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
+ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
} |
FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) |
TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { |
- WasmRunner<float, uint32_t> r(kExecuteCompiled); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(kExecuteCompiled); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<float> r(&module, MachineType::Uint32()); |
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
- CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_REFERENCE)); |
- CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
+ CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_REFERENCE)); |
+ CHECK_NE(0u, |
+ GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
} |
TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { |
- WasmRunner<float, uint32_t, float> r(kExecuteCompiled); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(kExecuteCompiled); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<float> r(&module, MachineType::Uint32(), MachineType::Float32()); |
BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), |
WASM_GET_LOCAL(1))); |
- CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_REFERENCE)); |
- CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
+ CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_REFERENCE)); |
+ CHECK_NE(0u, |
+ GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
} |
TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { |
- WasmRunner<double, uint32_t> r(kExecuteCompiled); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(kExecuteCompiled); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<double> r(&module, MachineType::Uint32()); |
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); |
- CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_REFERENCE)); |
- CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
+ CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_REFERENCE)); |
+ CHECK_NE(0u, |
+ GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
} |
TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { |
- WasmRunner<double, uint32_t, double> r(kExecuteCompiled); |
- r.module().ChangeOriginToAsmjs(); |
+ TestingModule module(kExecuteCompiled); |
+ module.ChangeOriginToAsmjs(); |
+ WasmRunner<double> r(&module, MachineType::Uint32(), MachineType::Float64()); |
BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), |
WASM_GET_LOCAL(1))); |
- CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_REFERENCE)); |
- CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], |
- RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
-} |
+ CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_REFERENCE)); |
+ CHECK_NE(0u, |
+ GetMatchingRelocInfoCount(module.instance->function_code[0], |
+ RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
+} |