OLD | NEW |
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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 TestingModule module(kExecuteCompiled); \ | 24 TestingModule module(kExecuteCompiled); \ |
25 module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \ | 25 module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \ |
26 module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \ | 26 module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \ |
27 \ | 27 \ |
28 WasmRunner<C_TYPE> r(&module, \ | 28 WasmRunner<C_TYPE> r(&module, \ |
29 WasmOpcodes::MachineTypeFor(kAst##MACHINE_TYPE)); \ | 29 WasmOpcodes::MachineTypeFor(kAst##MACHINE_TYPE)); \ |
30 \ | 30 \ |
31 /* global = global + p0 */ \ | 31 /* global = global + p0 */ \ |
32 BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \ | 32 BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \ |
33 WASM_GET_GLOBAL(0)); \ | 33 WASM_GET_GLOBAL(0)); \ |
34 CHECK_EQ(1, module.instance->function_code.size()); \ | 34 CHECK_EQ(1u, module.instance->function_code.size()); \ |
35 \ | 35 \ |
36 int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \ | 36 int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \ |
37 \ | 37 \ |
38 Handle<Code> code = module.instance->function_code[0]; \ | 38 Handle<Code> code = module.instance->function_code[0]; \ |
39 \ | 39 \ |
40 Address old_start = module.instance->globals_start; \ | 40 Address old_start = module.instance->globals_start; \ |
41 Address new_start = old_start + 1; \ | 41 Address new_start = old_start + 1; \ |
42 \ | 42 \ |
43 Address old_addresses[4]; \ | 43 Address old_addresses[4]; \ |
44 uint32_t address_index = 0U; \ | 44 uint32_t address_index = 0U; \ |
45 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \ | 45 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \ |
46 old_addresses[address_index] = it.rinfo()->wasm_global_reference(); \ | 46 old_addresses[address_index] = it.rinfo()->wasm_global_reference(); \ |
47 it.rinfo()->update_wasm_global_reference(old_start, new_start); \ | 47 it.rinfo()->update_wasm_global_reference(old_start, new_start); \ |
48 ++address_index; \ | 48 ++address_index; \ |
49 } \ | 49 } \ |
50 CHECK_LE(address_index, 4U); \ | 50 CHECK_LE(address_index, 4U); \ |
51 \ | 51 \ |
52 address_index = 0U; \ | 52 address_index = 0U; \ |
53 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \ | 53 for (RelocIterator it(*code, filter); !it.done(); it.next()) { \ |
54 CHECK_EQ(old_addresses[address_index] + 1, \ | 54 CHECK_EQ(old_addresses[address_index] + 1, \ |
55 it.rinfo()->wasm_global_reference()); \ | 55 it.rinfo()->wasm_global_reference()); \ |
56 ++address_index; \ | 56 ++address_index; \ |
57 } \ | 57 } \ |
58 CHECK_LE(address_index, 4U); \ | 58 CHECK_LE(address_index, 4U); \ |
59 } | 59 } |
60 | 60 |
61 FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY) | 61 FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY) |
OLD | NEW |