Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: test/cctest/wasm/test-run-wasm-relocation.cc

Issue 2551043002: [wasm] Make WasmRunner the central test structure (Closed)
Patch Set: Make DoCall return void - quickfix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
10 #include "test/cctest/compiler/c-signature.h" 10 #include "test/cctest/compiler/c-signature.h"
11 #include "test/cctest/wasm/wasm-run-utils.h" 11 #include "test/cctest/wasm/wasm-run-utils.h"
12 12
13 using namespace v8::internal; 13 using namespace v8::internal;
14 using namespace v8::internal::compiler; 14 using namespace v8::internal::compiler;
15 15
16 #define FOREACH_TYPE(TEST_BODY) \ 16 #define FOREACH_TYPE(TEST_BODY) \
17 TEST_BODY(int32_t, I32, WASM_I32_ADD) \ 17 TEST_BODY(int32_t, WASM_I32_ADD) \
18 TEST_BODY(int64_t, I64, WASM_I64_ADD) \ 18 TEST_BODY(int64_t, WASM_I64_ADD) \
19 TEST_BODY(float, F32, WASM_F32_ADD) \ 19 TEST_BODY(float, WASM_F32_ADD) \
20 TEST_BODY(double, F64, WASM_F64_ADD) 20 TEST_BODY(double, WASM_F64_ADD)
21 21
22 #define LOAD_SET_GLOBAL_TEST_BODY(C_TYPE, MACHINE_TYPE, ADD) \ 22 #define LOAD_SET_GLOBAL_TEST_BODY(C_TYPE, ADD) \
23 TEST(WasmRelocateGlobal##MACHINE_TYPE) { \ 23 TEST(WasmRelocateGlobal_##C_TYPE) { \
24 TestingModule module(kExecuteCompiled); \ 24 WasmRunner<C_TYPE, C_TYPE> r(kExecuteCompiled); \
25 module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \
26 module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \
27 \ 25 \
28 WasmRunner<C_TYPE> r(&module, \ 26 r.module().AddGlobal<C_TYPE>(); \
29 WasmOpcodes::MachineTypeFor(kAst##MACHINE_TYPE)); \ 27 r.module().AddGlobal<C_TYPE>(); \
30 \ 28 \
31 /* global = global + p0 */ \ 29 /* global = global + p0 */ \
32 BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \ 30 BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \
33 WASM_GET_GLOBAL(0)); \ 31 WASM_GET_GLOBAL(0)); \
34 CHECK_EQ(1u, module.instance->function_code.size()); \ 32 CHECK_EQ(1, r.module().instance->function_code.size()); \
35 \ 33 \
36 int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \ 34 int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \
37 \ 35 \
38 Handle<Code> code = module.instance->function_code[0]; \ 36 Handle<Code> code = r.module().instance->function_code[0]; \
39 \ 37 \
40 Address old_start = module.instance->globals_start; \ 38 Address old_start = r.module().instance->globals_start; \
41 Address new_start = old_start + 1; \ 39 Address new_start = old_start + 1; \
42 \ 40 \
43 Address old_addresses[4]; \ 41 Address old_addresses[4]; \
44 uint32_t address_index = 0U; \ 42 uint32_t address_index = 0U; \
45 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \ 43 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \
46 old_addresses[address_index] = it.rinfo()->wasm_global_reference(); \ 44 old_addresses[address_index] = it.rinfo()->wasm_global_reference(); \
47 it.rinfo()->update_wasm_global_reference(old_start, new_start); \ 45 it.rinfo()->update_wasm_global_reference(old_start, new_start); \
48 ++address_index; \ 46 ++address_index; \
49 } \ 47 } \
50 CHECK_LE(address_index, 4U); \ 48 CHECK_LE(address_index, 4U); \
51 \ 49 \
52 address_index = 0U; \ 50 address_index = 0U; \
53 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \ 51 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \
54 CHECK_EQ(old_addresses[address_index] + 1, \ 52 CHECK_EQ(old_addresses[address_index] + 1, \
55 it.rinfo()->wasm_global_reference()); \ 53 it.rinfo()->wasm_global_reference()); \
56 ++address_index; \ 54 ++address_index; \
57 } \ 55 } \
58 CHECK_LE(address_index, 4U); \ 56 CHECK_LE(address_index, 4U); \
59 } 57 }
60 58
61 FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY) 59 FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY)
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698