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