diff options
Diffstat (limited to 'deps/v8/test/cctest/wasm/test-run-wasm-bulk-memory.cc')
-rw-r--r-- | deps/v8/test/cctest/wasm/test-run-wasm-bulk-memory.cc | 104 |
1 files changed, 50 insertions, 54 deletions
diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-bulk-memory.cc b/deps/v8/test/cctest/wasm/test-run-wasm-bulk-memory.cc index e794c00ece..d2ac3434df 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-bulk-memory.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-bulk-memory.cc @@ -13,11 +13,10 @@ namespace wasm { namespace test_run_wasm_bulk_memory { namespace { -void CheckMemoryEquals( - TestingModuleBuilder& builder, // NOLINT(runtime/references) - size_t index, const std::vector<byte>& expected) { - const byte* mem_start = builder.raw_mem_start<byte>(); - const byte* mem_end = builder.raw_mem_end<byte>(); +void CheckMemoryEquals(TestingModuleBuilder* builder, size_t index, + const std::vector<byte>& expected) { + const byte* mem_start = builder->raw_mem_start<byte>(); + const byte* mem_end = builder->raw_mem_end<byte>(); size_t mem_size = mem_end - mem_start; CHECK_LE(index, mem_size); CHECK_LE(index + expected.size(), mem_size); @@ -26,11 +25,10 @@ void CheckMemoryEquals( } } -void CheckMemoryEqualsZero( - TestingModuleBuilder& builder, // NOLINT(runtime/references) - size_t index, size_t length) { - const byte* mem_start = builder.raw_mem_start<byte>(); - const byte* mem_end = builder.raw_mem_end<byte>(); +void CheckMemoryEqualsZero(TestingModuleBuilder* builder, size_t index, + size_t length) { + const byte* mem_start = builder->raw_mem_start<byte>(); + const byte* mem_end = builder->raw_mem_end<byte>(); size_t mem_size = mem_end - mem_start; CHECK_LE(index, mem_size); CHECK_LE(index + length, mem_size); @@ -39,12 +37,11 @@ void CheckMemoryEqualsZero( } } -void CheckMemoryEqualsFollowedByZeroes( - TestingModuleBuilder& builder, // NOLINT(runtime/references) - const std::vector<byte>& expected) { +void CheckMemoryEqualsFollowedByZeroes(TestingModuleBuilder* builder, + const std::vector<byte>& expected) { CheckMemoryEquals(builder, 0, expected); CheckMemoryEqualsZero(builder, expected.size(), - builder.mem_size() - expected.size()); + builder->mem_size() - expected.size()); } } // namespace @@ -60,24 +57,24 @@ WASM_EXEC_TEST(MemoryInit) { kExprI32Const, 0); // All zeroes. - CheckMemoryEqualsZero(r.builder(), 0, kWasmPageSize); + CheckMemoryEqualsZero(&r.builder(), 0, kWasmPageSize); // Copy all bytes from data segment 0, to memory at [10, 20). CHECK_EQ(0, r.Call(10, 0, 10)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // Copy bytes in range [5, 10) from data segment 0, to memory at [0, 5). CHECK_EQ(0, r.Call(0, 5, 5)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // Copy 0 bytes does nothing. CHECK_EQ(0, r.Call(10, 1, 0)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // Copy 0 at end of memory region or data segment is OK. @@ -100,12 +97,12 @@ WASM_EXEC_TEST(MemoryInitOutOfBoundsData) { // Write all values up to the out-of-bounds write. CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, 0, 6)); - CheckMemoryEquals(r.builder(), last_5_bytes, {0, 1, 2, 3, 4}); + CheckMemoryEquals(&r.builder(), last_5_bytes, {0, 1, 2, 3, 4}); // Write all values up to the out-of-bounds read. r.builder().BlankMemory(); CHECK_EQ(0xDEADBEEF, r.Call(0, 5, 6)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {5, 6, 7, 8, 9}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {5, 6, 7, 8, 9}); } WASM_EXEC_TEST(MemoryInitOutOfBounds) { @@ -155,13 +152,13 @@ WASM_EXEC_TEST(MemoryCopy) { // Copy from [1, 8] to [10, 16]. CHECK_EQ(0, r.Call(10, 1, 8)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77}); // Copy 0 bytes does nothing. CHECK_EQ(0, r.Call(10, 2, 0)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77}); // Copy 0 at end of memory region is OK. @@ -184,12 +181,12 @@ WASM_EXEC_TEST(MemoryCopyOverlapping) { // Copy from [0, 3] -> [2, 5]. The copy must not overwrite 30 before copying // it (i.e. cannot copy forward in this case). CHECK_EQ(0, r.Call(2, 0, 3)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {10, 20, 10, 20, 30}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {10, 20, 10, 20, 30}); // Copy from [2, 5] -> [0, 3]. The copy must not write the first 10 (i.e. // cannot copy backward in this case). CHECK_EQ(0, r.Call(0, 2, 3)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {10, 20, 30, 20, 30}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {10, 20, 30, 20, 30}); } WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) { @@ -209,21 +206,21 @@ WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) { // Copy with source < destination. Copy would happen backwards, // but the first byte to copy is out-of-bounds, so no data should be written. CHECK_EQ(0xDEADBEEF, r.Call(last_5_bytes, 0, 6)); - CheckMemoryEquals(r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); + CheckMemoryEquals(&r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); // Copy overlapping with destination < source. Copy will happen forwards, up // to the out-of-bounds access. r.builder().BlankMemory(); memcpy(mem + last_5_bytes, data, 5); CHECK_EQ(0xDEADBEEF, r.Call(0, last_5_bytes, kWasmPageSize)); - CheckMemoryEquals(r.builder(), 0, {11, 22, 33, 44, 55}); + CheckMemoryEquals(&r.builder(), 0, {11, 22, 33, 44, 55}); // Copy overlapping with source < destination. Copy would happen backwards, // but the first byte to copy is out-of-bounds, so no data should be written. r.builder().BlankMemory(); memcpy(mem, data, 5); CHECK_EQ(0xDEADBEEF, r.Call(last_5_bytes, 0, kWasmPageSize)); - CheckMemoryEquals(r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); + CheckMemoryEquals(&r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); } WASM_EXEC_TEST(MemoryCopyOutOfBounds) { @@ -265,15 +262,15 @@ WASM_EXEC_TEST(MemoryFill) { WASM_MEMORY_FILL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_GET_LOCAL(2)), kExprI32Const, 0); CHECK_EQ(0, r.Call(1, 33, 5)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {0, 33, 33, 33, 33, 33}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 33, 33}); CHECK_EQ(0, r.Call(4, 66, 4)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 66, 66, 66, 66}); // Fill 0 bytes does nothing. CHECK_EQ(0, r.Call(4, 66, 0)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 66, 66, 66, 66}); // Fill 0 at end of memory region is OK. @@ -290,7 +287,7 @@ WASM_EXEC_TEST(MemoryFillValueWrapsToByte) { kExprI32Const, 0); CHECK_EQ(0, r.Call(0, 1000, 3)); const byte expected = 1000 & 255; - CheckMemoryEqualsFollowedByZeroes(r.builder(), + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {expected, expected, expected}); } @@ -304,7 +301,7 @@ WASM_EXEC_TEST(MemoryFillOutOfBoundsData) { kExprI32Const, 0); const byte v = 123; CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, v, 999)); - CheckMemoryEquals(r.builder(), kWasmPageSize - 6, {0, v, v, v, v, v}); + CheckMemoryEquals(&r.builder(), kWasmPageSize - 6, {0, v, v, v, v, v}); } WASM_EXEC_TEST(MemoryFillOutOfBounds) { @@ -408,14 +405,13 @@ void CheckTable(Isolate* isolate, Handle<WasmTableObject> table, Args... args) { template <typename WasmRunner, typename... Args> void CheckTableCall(Isolate* isolate, Handle<WasmTableObject> table, - WasmRunner& r, // NOLINT(runtime/references) - uint32_t function_index, Args... args) { + WasmRunner* r, uint32_t function_index, Args... args) { uint32_t args_length = static_cast<uint32_t>(sizeof...(args)); CHECK_EQ(table->current_length(), args_length); double expected[] = {args...}; for (uint32_t i = 0; i < args_length; ++i) { Handle<Object> buffer[] = {isolate->factory()->NewNumber(i)}; - r.CheckCallApplyViaJS(expected[i], function_index, buffer, 1); + r->CheckCallApplyViaJS(expected[i], function_index, buffer, 1); } } } // namespace @@ -462,7 +458,7 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) { isolate); const double null = 0xDEADBEEF; - CheckTableCall(isolate, table, r, call_index, null, null, null, null, null); + CheckTableCall(isolate, table, &r, call_index, null, null, null, null, null); // 0 count is ok in bounds, and at end of regions. r.CheckCallViaJS(0, 0, 0, 0); @@ -471,19 +467,19 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) { // Test actual writes. r.CheckCallViaJS(0, 0, 0, 1); - CheckTableCall(isolate, table, r, call_index, 0, null, null, null, null); + CheckTableCall(isolate, table, &r, call_index, 0, null, null, null, null); r.CheckCallViaJS(0, 0, 0, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, null, null, null); + CheckTableCall(isolate, table, &r, call_index, 0, 1, null, null, null); r.CheckCallViaJS(0, 0, 0, 3); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, null, null); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, null, null); r.CheckCallViaJS(0, 3, 0, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 0, 1); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 0, 1); r.CheckCallViaJS(0, 3, 1, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 1, 2); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 1, 2); r.CheckCallViaJS(0, 3, 2, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 2, 3); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 2, 3); r.CheckCallViaJS(0, 3, 3, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 3, 4); } WASM_EXEC_TEST(TableInitElems0) { TestTableInitElems(execution_tier, 0); } @@ -534,15 +530,15 @@ void TestTableInitOob(ExecutionTier execution_tier, int table_index) { isolate); const double null = 0xDEADBEEF; - CheckTableCall(isolate, table, r, call_index, null, null, null, null, null); + CheckTableCall(isolate, table, &r, call_index, null, null, null, null, null); // Write all values up to the out-of-bounds write. r.CheckCallViaJS(0xDEADBEEF, 3, 0, 3); - CheckTableCall(isolate, table, r, call_index, null, null, null, 0, 1); + CheckTableCall(isolate, table, &r, call_index, null, null, null, 0, 1); // Write all values up to the out-of-bounds read. r.CheckCallViaJS(0xDEADBEEF, 0, 3, 3); - CheckTableCall(isolate, table, r, call_index, 3, 4, null, 0, 1); + CheckTableCall(isolate, table, &r, call_index, 3, 4, null, 0, 1); // 0-count is never oob. r.CheckCallViaJS(0, kTableSize + 1, 0, 0); @@ -696,21 +692,21 @@ void TestTableCopyCalls(ExecutionTier execution_tier, int table_dst, isolate); if (table_dst == table_src) { - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 1); - CheckTableCall(isolate, table, r, call_index, 1, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 3, 4); r.CheckCallViaJS(0, 3, 0, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 1, 2); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 1, 2); } else { - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 1); - CheckTableCall(isolate, table, r, call_index, 1, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 3, 4); r.CheckCallViaJS(0, 3, 0, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 0, 1); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 0, 1); } } |