| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 CHECK_EQ(ret_value, imm); | 49 CHECK_EQ(ret_value, imm); |
| 50 | 50 |
| 51 #ifdef OBJECT_PRINT | 51 #ifdef OBJECT_PRINT |
| 52 OFStream os(stdout); | 52 OFStream os(stdout); |
| 53 code->Print(os); | 53 code->Print(os); |
| 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 size_t 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 RelocInfo::Mode mode = it.rinfo()->rmode(); |
| 65 if (RelocInfo::IsWasmMemoryReference(mode)) { | 65 if (RelocInfo::IsWasmMemoryReference(mode)) { |
| 66 // Dummy values of size used here as the objective of the test is to | 66 // Dummy values of size used here as the objective of the test is to |
| 67 // verify that the immediate is patched correctly | 67 // verify that the immediate is patched correctly |
| 68 it.rinfo()->update_wasm_memory_reference( | 68 it.rinfo()->update_wasm_memory_reference( |
| 69 it.rinfo()->wasm_memory_reference(), | 69 it.rinfo()->wasm_memory_reference(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 CSignature0<int32_t> csig; | 108 CSignature0<int32_t> csig; |
| 109 CodeDesc desc; | 109 CodeDesc desc; |
| 110 assm.GetCode(&desc); | 110 assm.GetCode(&desc); |
| 111 Handle<Code> code = isolate->factory()->NewCode( | 111 Handle<Code> code = isolate->factory()->NewCode( |
| 112 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 112 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 113 USE(code); | 113 USE(code); |
| 114 | 114 |
| 115 CodeRunner<int32_t> runnable(isolate, code, &csig); | 115 CodeRunner<int32_t> runnable(isolate, code, &csig); |
| 116 int32_t ret_value = runnable.Call(); | 116 int32_t ret_value = runnable.Call(); |
| 117 CHECK_NE(ret_value, 0xdeadbeef); | 117 CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); |
| 118 | 118 |
| 119 #ifdef OBJECT_PRINT | 119 #ifdef OBJECT_PRINT |
| 120 OFStream os(stdout); | 120 OFStream os(stdout); |
| 121 code->Print(os); | 121 code->Print(os); |
| 122 byte* begin = code->instruction_start(); | 122 byte* begin = code->instruction_start(); |
| 123 byte* end = begin + code->instruction_size(); | 123 byte* end = begin + code->instruction_size(); |
| 124 disasm::Disassembler::Disassemble(stdout, begin, end); | 124 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 size_t offset = 10; | 127 size_t offset = 10; |
| 128 | 128 |
| 129 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | 129 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
| 130 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | 130 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
| 131 RelocInfo::Mode mode = it.rinfo()->rmode(); | 131 RelocInfo::Mode mode = it.rinfo()->rmode(); |
| 132 if (RelocInfo::IsWasmMemorySizeReference(mode)) { | 132 if (RelocInfo::IsWasmMemorySizeReference(mode)) { |
| 133 it.rinfo()->update_wasm_memory_reference( | 133 it.rinfo()->update_wasm_memory_reference( |
| 134 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), | 134 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), |
| 135 it.rinfo()->wasm_memory_size_reference(), | 135 it.rinfo()->wasm_memory_size_reference(), |
| 136 it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); | 136 it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 ret_value = runnable.Call(); | 140 ret_value = runnable.Call(); |
| 141 CHECK_NE(ret_value, 0xdeadbeef); | 141 CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); |
| 142 | 142 |
| 143 #ifdef OBJECT_PRINT | 143 #ifdef OBJECT_PRINT |
| 144 code->Print(os); | 144 code->Print(os); |
| 145 begin = code->instruction_start(); | 145 begin = code->instruction_start(); |
| 146 end = begin + code->instruction_size(); | 146 end = begin + code->instruction_size(); |
| 147 disasm::Disassembler::Disassemble(stdout, begin, end); | 147 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 148 #endif | 148 #endif |
| 149 } | 149 } |
| 150 #undef __ | 150 #undef __ |
| OLD | NEW |