| 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 "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/disasm.h" | 10 #include "src/disasm.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 byte* begin = code->instruction_start(); | 54 byte* begin = code->instruction_start(); |
| 55 byte* end = begin + code->instruction_size(); | 55 byte* end = begin + code->instruction_size(); |
| 56 disasm::Disassembler::Disassemble(stdout, begin, end); | 56 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 int offset = 1234; | 59 int offset = 1234; |
| 60 | 60 |
| 61 // Relocating references by offset | 61 // Relocating references by offset |
| 62 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); | 62 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); |
| 63 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | 63 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
| 64 RelocInfo::Mode mode = it.rinfo()->rmode(); | 64 DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); |
| 65 if (RelocInfo::IsWasmMemoryReference(mode)) { | 65 it.rinfo()->update_wasm_memory_reference( |
| 66 // Dummy values of size used here as the objective of the test is to | 66 it.rinfo()->wasm_memory_reference(), |
| 67 // verify that the immediate is patched correctly | 67 it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); |
| 68 it.rinfo()->update_wasm_memory_reference( | |
| 69 it.rinfo()->wasm_memory_reference(), | |
| 70 it.rinfo()->wasm_memory_reference() + offset, 1, 2, | |
| 71 SKIP_ICACHE_FLUSH); | |
| 72 } | |
| 73 } | 68 } |
| 74 | 69 |
| 75 // Check if immediate is updated correctly | 70 // Check if immediate is updated correctly |
| 76 ret_value = runnable.Call(); | 71 ret_value = runnable.Call(); |
| 77 CHECK_EQ(ret_value, imm + offset); | 72 CHECK_EQ(ret_value, imm + offset); |
| 78 | 73 |
| 79 #ifdef OBJECT_PRINT | 74 #ifdef OBJECT_PRINT |
| 80 code->Print(os); | 75 code->Print(os); |
| 81 begin = code->instruction_start(); | 76 begin = code->instruction_start(); |
| 82 end = begin + code->instruction_size(); | 77 end = begin + code->instruction_size(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 byte* begin = code->instruction_start(); | 117 byte* begin = code->instruction_start(); |
| 123 byte* end = begin + code->instruction_size(); | 118 byte* end = begin + code->instruction_size(); |
| 124 disasm::Disassembler::Disassemble(stdout, begin, end); | 119 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 125 #endif | 120 #endif |
| 126 | 121 |
| 127 size_t offset = 10; | 122 size_t offset = 10; |
| 128 | 123 |
| 129 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | 124 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
| 130 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | 125 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
| 131 RelocInfo::Mode mode = it.rinfo()->rmode(); | 126 RelocInfo::Mode mode = it.rinfo()->rmode(); |
| 132 if (RelocInfo::IsWasmMemorySizeReference(mode)) { | 127 DCHECK(RelocInfo::IsWasmMemorySizeReference(mode)); |
| 133 it.rinfo()->update_wasm_memory_reference( | 128 it.rinfo()->update_wasm_memory_size( |
| 134 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), | 129 it.rinfo()->wasm_memory_size_reference(), |
| 135 it.rinfo()->wasm_memory_size_reference(), | 130 it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); |
| 136 it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); | |
| 137 } | |
| 138 } | 131 } |
| 139 | 132 |
| 140 ret_value = runnable.Call(); | 133 ret_value = runnable.Call(); |
| 141 CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); | 134 CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); |
| 142 | 135 |
| 143 #ifdef OBJECT_PRINT | 136 #ifdef OBJECT_PRINT |
| 144 code->Print(os); | 137 code->Print(os); |
| 145 begin = code->instruction_start(); | 138 begin = code->instruction_start(); |
| 146 end = begin + code->instruction_size(); | 139 end = begin + code->instruction_size(); |
| 147 disasm::Disassembler::Disassemble(stdout, begin, end); | 140 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 148 #endif | 141 #endif |
| 149 } | 142 } |
| 150 #undef __ | 143 #undef __ |
| OLD | NEW |