diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc index ed26586384..90c339dec3 100644 --- a/test/cctest/wasm/test-run-wasm.cc +++ b/test/cctest/wasm/test-run-wasm.cc @@ -435,7 +435,7 @@ WASM_EXEC_TEST(Int32DivU_byzero_const) { WASM_EXEC_TEST(Int32DivS_trap_effect) { WasmRunner r(execution_mode); - r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(8); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(8); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(8); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(8); + r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE, 2)); r.Call(); } WASM_EXEC_TEST(UnalignedFloat64Load) { WasmRunner r(execution_mode); - r.builder().AddMemoryElems(8); + r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE, 3)); r.Call(); } WASM_EXEC_TEST(UnalignedInt32Load) { WasmRunner r(execution_mode); - r.builder().AddMemoryElems(8); + r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2)); r.Call(); } WASM_EXEC_TEST(UnalignedInt32Store) { WasmRunner r(execution_mode); - r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(8); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(8); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(4); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(4); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(4); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - uint8_t* memory = r.builder().AddMemoryElems(kBytes); + uint8_t* memory = r.builder().AddMemoryElems(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 r(execution_mode); - int32_t* memory = r.builder().AddMemoryElems(kNumElems); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - uint32_t* memory = r.builder().AddMemoryElems(kNumElems); + uint32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(kNumElems); + r.builder().AddMemoryElems(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 r(execution_mode); - r.builder().AddMemoryElems(kSize); + r.builder().AddMemoryElems(kWasmPageSize / sizeof(float)); float* buffer = r.builder().raw_mem_start(); 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 r(execution_mode); - T* memory = r.builder().AddMemoryElems(size); + T* memory = r.builder().AddMemoryElems(static_cast( + 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 r(execution_mode); - r.builder().AddMemoryElems(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 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 r(execution_mode); - const int kNumElems = 16; + const int kNumElems = kWasmPageSize; int8_t* memory = r.builder().AddMemoryElems(kNumElems); r.builder().RandomizeMemory(); memory[0] = -1; @@ -2011,7 +2022,7 @@ WASM_EXEC_TEST(Int32LoadInt8_signext) { WASM_EXEC_TEST(Int32LoadInt8_zeroext) { WasmRunner 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 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 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 r(execution_mode); int32_t* unused = r.builder().AddGlobal(); - byte* memory = r.builder().AddMemory(32); + byte* memory = r.builder().AddMemory(kWasmPageSize); int32_t* var_int32 = r.builder().AddGlobal(); uint32_t* var_uint32 = r.builder().AddGlobal(); @@ -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(16 / sizeof(int32_t)); + int32_t* memory = + r.builder().AddMemoryElems(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 r(execution_mode); - double* memory = r.builder().AddMemoryElems(16); + double* memory = + r.builder().AddMemoryElems(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 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 r(execution_mode); - ctype* memory = r.builder().AddMemoryElems(num_locals); + ctype* memory = + r.builder().AddMemoryElems(kWasmPageSize / sizeof(ctype)); for (int i = 0; i < num_locals; ++i) { r.AllocateLocal(type); }