[wasm][cleanup] Make cctests in test-run-wasm.cc use page-sized memory
Bug: v8:7704, v8:7570 Change-Id: I671f1355b9a95b0fcba56ac5fb3669b4563652dc Reviewed-on: https://chromium-review.googlesource.com/1033543 Commit-Queue: Eric Holk <eholk@chromium.org> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org> Cr-Commit-Position: refs/heads/master@{#52868}
This commit is contained in:
parent
9186e770c6
commit
284ad30d2a
@ -435,7 +435,7 @@ WASM_EXEC_TEST(Int32DivU_byzero_const) {
|
||||
|
||||
WASM_EXEC_TEST(Int32DivS_trap_effect) {
|
||||
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
|
||||
BUILD(r, WASM_IF_ELSE_I(
|
||||
WASM_GET_LOCAL(0),
|
||||
@ -828,7 +828,7 @@ WASM_EXEC_TEST(Br_height) {
|
||||
|
||||
WASM_EXEC_TEST(Regression_660262) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<int32_t>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, kExprI32Const, 0x00, kExprI32Const, 0x00, kExprI32LoadMem, 0x00,
|
||||
0x0F, kExprBrTable, 0x00, 0x80, 0x00); // entries=0
|
||||
r.Call();
|
||||
@ -1013,7 +1013,8 @@ WASM_EXEC_TEST(BrTable_loop_target) {
|
||||
|
||||
WASM_EXEC_TEST(F32ReinterpretI32) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
|
||||
BUILD(r, WASM_I32_REINTERPRET_F32(
|
||||
WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)));
|
||||
@ -1027,7 +1028,8 @@ WASM_EXEC_TEST(F32ReinterpretI32) {
|
||||
|
||||
WASM_EXEC_TEST(I32ReinterpretF32) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
|
||||
BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
|
||||
WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))),
|
||||
@ -1057,7 +1059,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMaxUint32Offset) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), // type
|
||||
U32V_5(0xFFFFFFFF), // offset
|
||||
@ -1068,7 +1070,8 @@ WASM_EXEC_TEST(LoadMaxUint32Offset) {
|
||||
|
||||
WASM_EXEC_TEST(LoadStoreLoad) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
|
||||
BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
|
||||
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
|
||||
@ -1083,28 +1086,28 @@ WASM_EXEC_TEST(LoadStoreLoad) {
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat32Load) {
|
||||
WasmRunner<float> r(execution_mode);
|
||||
r.builder().AddMemoryElems<float>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE, 2));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat64Load) {
|
||||
WasmRunner<double> r(execution_mode);
|
||||
r.builder().AddMemoryElems<double>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE, 3));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedInt32Load) {
|
||||
WasmRunner<uint32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<uint32_t>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2));
|
||||
r.Call();
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(UnalignedInt32Store) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<uint32_t>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2,
|
||||
WASM_I32V_1(1)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1113,7 +1116,7 @@ WASM_EXEC_TEST(UnalignedInt32Store) {
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat32Store) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<float>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE,
|
||||
2, WASM_F32(1.0)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1122,7 +1125,7 @@ WASM_EXEC_TEST(UnalignedFloat32Store) {
|
||||
|
||||
WASM_EXEC_TEST(UnalignedFloat64Store) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<double>(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE,
|
||||
3, WASM_F64(1.0)),
|
||||
WASM_I32V_1(12)));
|
||||
@ -1459,7 +1462,8 @@ WASM_EXEC_TEST(IfBreak2) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemI32) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
|
||||
@ -1477,7 +1481,8 @@ WASM_EXEC_TEST(LoadMemI32) {
|
||||
WASM_EXEC_TEST(LoadMemI32_alignment) {
|
||||
for (byte alignment = 0; alignment <= 2; ++alignment) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r,
|
||||
@ -1545,7 +1550,8 @@ WASM_EXEC_TEST(LoadMem_offset_oob) {
|
||||
|
||||
WASM_EXEC_TEST(LoadMemI32_offset) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
r.builder().RandomizeMemory(1111);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0)));
|
||||
@ -1619,7 +1625,8 @@ WASM_EXEC_TEST(StoreMemI32_alignment) {
|
||||
|
||||
for (byte i = 0; i <= 2; ++i) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ZERO, i,
|
||||
WASM_GET_LOCAL(0)),
|
||||
WASM_GET_LOCAL(0));
|
||||
@ -1633,7 +1640,8 @@ WASM_EXEC_TEST(StoreMemI32_alignment) {
|
||||
|
||||
WASM_EXEC_TEST(StoreMemI32_offset) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
const int32_t kWritten = 0xAABBCCDD;
|
||||
|
||||
BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0),
|
||||
@ -1693,7 +1701,7 @@ WASM_EXEC_TEST(Store_i32_narrowed) {
|
||||
constexpr int kBytes = 24;
|
||||
uint8_t expected_memory[kBytes] = {0};
|
||||
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
|
||||
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kBytes);
|
||||
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
|
||||
constexpr uint32_t kPattern = 0x12345678;
|
||||
|
||||
BUILD(r, WASM_GET_LOCAL(0), // index
|
||||
@ -1717,7 +1725,8 @@ WASM_EXEC_TEST(Store_i32_narrowed) {
|
||||
WASM_EXEC_TEST(LoadMemI32_P) {
|
||||
const int kNumElems = 8;
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(kNumElems);
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
r.builder().RandomizeMemory(2222);
|
||||
|
||||
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
|
||||
@ -1730,7 +1739,8 @@ WASM_EXEC_TEST(LoadMemI32_P) {
|
||||
WASM_EXEC_TEST(MemI32_Sum) {
|
||||
const int kNumElems = 20;
|
||||
WasmRunner<uint32_t, int32_t> r(execution_mode);
|
||||
uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kNumElems);
|
||||
uint32_t* memory =
|
||||
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
const byte kSum = r.AllocateLocal(kWasmI32);
|
||||
|
||||
BUILD(r, WASM_WHILE(
|
||||
@ -1759,7 +1769,7 @@ WASM_EXEC_TEST(MemI32_Sum) {
|
||||
WASM_EXEC_TEST(CheckMachIntsZero) {
|
||||
const int kNumElems = 55;
|
||||
WasmRunner<uint32_t, int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<uint32_t>(kNumElems);
|
||||
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
|
||||
|
||||
BUILD(r, // --
|
||||
/**/ kExprLoop, kLocalVoid, // --
|
||||
@ -1787,7 +1797,7 @@ WASM_EXEC_TEST(CheckMachIntsZero) {
|
||||
WASM_EXEC_TEST(MemF32_Sum) {
|
||||
const int kSize = 5;
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.builder().AddMemoryElems<float>(kSize);
|
||||
r.builder().AddMemoryElems<float>(kWasmPageSize / sizeof(float));
|
||||
float* buffer = r.builder().raw_mem_start<float>();
|
||||
r.builder().WriteMemory(&buffer[0], -99.25f);
|
||||
r.builder().WriteMemory(&buffer[1], -888.25f);
|
||||
@ -1818,7 +1828,8 @@ 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.builder().AddMemoryElems<T>(size);
|
||||
T* memory = r.builder().AddMemoryElems<T>(static_cast<uint32_t>(
|
||||
RoundUp(size * sizeof(T), kWasmPageSize) / sizeof(sizeof(T))));
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
r.builder().WriteMemory(&memory[i], buffer[i]);
|
||||
}
|
||||
@ -1857,7 +1868,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.builder().AddMemoryElems<int8_t>(16);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
|
||||
// Only build the graph and compile, don't run.
|
||||
BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO), WASM_DROP),
|
||||
@ -1908,7 +1919,7 @@ WASM_COMPILED_EXEC_TEST(Build_Wasm_UnreachableIf2) {
|
||||
|
||||
WASM_EXEC_TEST(Unreachable_Load) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
r.builder().AddMemory(8);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
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));
|
||||
@ -1998,7 +2009,7 @@ TEST(Build_Wasm_SimpleExprs) {
|
||||
|
||||
WASM_EXEC_TEST(Int32LoadInt8_signext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumElems = 16;
|
||||
const int kNumElems = kWasmPageSize;
|
||||
int8_t* memory = r.builder().AddMemoryElems<int8_t>(kNumElems);
|
||||
r.builder().RandomizeMemory();
|
||||
memory[0] = -1;
|
||||
@ -2011,7 +2022,7 @@ WASM_EXEC_TEST(Int32LoadInt8_signext) {
|
||||
|
||||
WASM_EXEC_TEST(Int32LoadInt8_zeroext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumElems = 16;
|
||||
const int kNumElems = kWasmPageSize;
|
||||
byte* memory = r.builder().AddMemory(kNumElems);
|
||||
r.builder().RandomizeMemory(77);
|
||||
memory[0] = 255;
|
||||
@ -2024,7 +2035,7 @@ WASM_EXEC_TEST(Int32LoadInt8_zeroext) {
|
||||
|
||||
WASM_EXEC_TEST(Int32LoadInt16_signext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumBytes = 16;
|
||||
const int kNumBytes = kWasmPageSize;
|
||||
byte* memory = r.builder().AddMemory(kNumBytes);
|
||||
r.builder().RandomizeMemory(888);
|
||||
memory[1] = 200;
|
||||
@ -2038,7 +2049,7 @@ WASM_EXEC_TEST(Int32LoadInt16_signext) {
|
||||
|
||||
WASM_EXEC_TEST(Int32LoadInt16_zeroext) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
const int kNumBytes = 16;
|
||||
const int kNumBytes = kWasmPageSize;
|
||||
byte* memory = r.builder().AddMemory(kNumBytes);
|
||||
r.builder().RandomizeMemory(9999);
|
||||
memory[1] = 204;
|
||||
@ -2133,7 +2144,7 @@ WASM_EXEC_TEST(MixedGlobals) {
|
||||
WasmRunner<int32_t, int32_t> r(execution_mode);
|
||||
|
||||
int32_t* unused = r.builder().AddGlobal<int32_t>();
|
||||
byte* memory = r.builder().AddMemory(32);
|
||||
byte* memory = r.builder().AddMemory(kWasmPageSize);
|
||||
|
||||
int32_t* var_int32 = r.builder().AddGlobal<int32_t>();
|
||||
uint32_t* var_uint32 = r.builder().AddGlobal<uint32_t>();
|
||||
@ -2233,7 +2244,8 @@ WASM_EXEC_TEST(CallVoid) {
|
||||
const int32_t kExpected = 414444;
|
||||
// Build the target function.
|
||||
TestSignatures sigs;
|
||||
int32_t* memory = r.builder().AddMemoryElems<int32_t>(16 / sizeof(int32_t));
|
||||
int32_t* memory =
|
||||
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
|
||||
r.builder().RandomizeMemory();
|
||||
WasmFunctionCompiler& t = r.NewFunction(sigs.v_v());
|
||||
BUILD(t, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V_1(kMemOffset),
|
||||
@ -2287,7 +2299,8 @@ WASM_EXEC_TEST(Call_Float32Sub) {
|
||||
|
||||
WASM_EXEC_TEST(Call_Float64Sub) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
double* memory = r.builder().AddMemoryElems<double>(16);
|
||||
double* memory =
|
||||
r.builder().AddMemoryElems<double>(kWasmPageSize / sizeof(double));
|
||||
|
||||
BUILD(r, WASM_STORE_MEM(
|
||||
MachineType::Float64(), WASM_ZERO,
|
||||
@ -2336,7 +2349,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.builder().AddMemory(1024);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
MachineType* memtypes = &mixed[start];
|
||||
MachineType result = memtypes[which];
|
||||
|
||||
@ -3181,7 +3194,8 @@ void BinOpOnDifferentRegisters(WasmExecutionMode execution_mode, ValueType type,
|
||||
for (int lhs = 0; lhs < num_locals; ++lhs) {
|
||||
for (int rhs = 0; rhs < num_locals; ++rhs) {
|
||||
WasmRunner<int32_t> r(execution_mode);
|
||||
ctype* memory = r.builder().AddMemoryElems<ctype>(num_locals);
|
||||
ctype* memory =
|
||||
r.builder().AddMemoryElems<ctype>(kWasmPageSize / sizeof(ctype));
|
||||
for (int i = 0; i < num_locals; ++i) {
|
||||
r.AllocateLocal(type);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user