| 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 <iostream> // NOLINT(readability/streams) | 5 #include <iostream> // NOLINT(readability/streams) |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
| 9 | 9 |
| 10 #include "src/arm/assembler-arm-inl.h" | 10 #include "src/arm/assembler-arm-inl.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #ifdef DEBUG | 48 #ifdef DEBUG |
| 49 OFStream os(stdout); | 49 OFStream os(stdout); |
| 50 code->Print(os); | 50 code->Print(os); |
| 51 ::printf("f() = %d\n\n", ret_value); | 51 ::printf("f() = %d\n\n", ret_value); |
| 52 #endif | 52 #endif |
| 53 int offset = 1234; | 53 int offset = 1234; |
| 54 | 54 |
| 55 // Relocating references by offset | 55 // Relocating references by offset |
| 56 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); | 56 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); |
| 57 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | 57 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
| 58 RelocInfo::Mode mode = it.rinfo()->rmode(); | 58 DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); |
| 59 if (RelocInfo::IsWasmMemoryReference(mode)) { | 59 it.rinfo()->update_wasm_memory_reference( |
| 60 // Dummy values of size used here as the objective of the test is to | 60 it.rinfo()->wasm_memory_reference(), |
| 61 // verify that the immediate is patched correctly | 61 it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); |
| 62 it.rinfo()->update_wasm_memory_reference( | |
| 63 it.rinfo()->wasm_memory_reference(), | |
| 64 it.rinfo()->wasm_memory_reference() + offset, 1, 2, | |
| 65 SKIP_ICACHE_FLUSH); | |
| 66 } | |
| 67 } | 62 } |
| 68 | 63 |
| 69 // Call into relocated code object | 64 // Call into relocated code object |
| 70 ret_value = runnable.Call(); | 65 ret_value = runnable.Call(); |
| 71 CHECK_EQ((imm + offset), ret_value); | 66 CHECK_EQ((imm + offset), ret_value); |
| 72 | 67 |
| 73 #ifdef DEBUG | 68 #ifdef DEBUG |
| 74 code->Print(os); | 69 code->Print(os); |
| 75 ::printf("f() = %d\n\n", ret_value); | 70 ::printf("f() = %d\n\n", ret_value); |
| 76 #endif | 71 #endif |
| (...skipping 30 matching lines...) Expand all Loading... |
| 107 | 102 |
| 108 #ifdef DEBUG | 103 #ifdef DEBUG |
| 109 OFStream os(stdout); | 104 OFStream os(stdout); |
| 110 code->Print(os); | 105 code->Print(os); |
| 111 ::printf("f() = %d\n\n", ret_value); | 106 ::printf("f() = %d\n\n", ret_value); |
| 112 #endif | 107 #endif |
| 113 size_t diff = 512; | 108 size_t diff = 512; |
| 114 | 109 |
| 115 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | 110 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
| 116 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | 111 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
| 117 RelocInfo::Mode mode = it.rinfo()->rmode(); | 112 DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); |
| 118 if (RelocInfo::IsWasmMemorySizeReference(mode)) { | 113 it.rinfo()->update_wasm_memory_size( |
| 119 it.rinfo()->update_wasm_memory_reference( | 114 it.rinfo()->wasm_memory_size_reference(), |
| 120 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), | 115 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); |
| 121 it.rinfo()->wasm_memory_size_reference(), | |
| 122 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); | |
| 123 } | |
| 124 } | 116 } |
| 125 | 117 |
| 126 ret_value = runnable.Call(); | 118 ret_value = runnable.Call(); |
| 127 CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); | 119 CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); |
| 128 | 120 |
| 129 #ifdef DEBUG | 121 #ifdef DEBUG |
| 130 code->Print(os); | 122 code->Print(os); |
| 131 ::printf("f() = %d\n\n", ret_value); | 123 ::printf("f() = %d\n\n", ret_value); |
| 132 #endif | 124 #endif |
| 133 } | 125 } |
| 134 #undef __ | 126 #undef __ |
| OLD | NEW |