| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
| 6 | 6 |
| 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. |
| 8 #if defined(TARGET_ARCH_DBC) | 8 #if defined(TARGET_ARCH_DBC) |
| 9 | 9 |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| 11 #include "vm/constants_dbc.h" | 11 #include "vm/constants_dbc.h" |
| 12 #include "vm/cpu.h" | 12 #include "vm/cpu.h" |
| 13 #include "vm/instructions.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 static const char* kOpcodeNames[] = { | 17 static const char* kOpcodeNames[] = { |
| 17 #define BYTECODE_NAME(name, encoding, op1, op2, op3) #name, | 18 #define BYTECODE_NAME(name, encoding, op1, op2, op3) #name, |
| 18 BYTECODES_LIST(BYTECODE_NAME) | 19 BYTECODES_LIST(BYTECODE_NAME) |
| 19 #undef BYTECODE_NAME | 20 #undef BYTECODE_NAME |
| 20 }; | 21 }; |
| 21 | 22 |
| 22 static const size_t kOpcodeCount = | 23 static const size_t kOpcodeCount = |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 BYTECODES_LIST(BYTECODE_FORMATTER) | 208 BYTECODES_LIST(BYTECODE_FORMATTER) |
| 208 #undef BYTECODE_FORMATTER | 209 #undef BYTECODE_FORMATTER |
| 209 }; | 210 }; |
| 210 | 211 |
| 211 | 212 |
| 212 void Disassembler::DecodeInstruction(char* hex_buffer, | 213 void Disassembler::DecodeInstruction(char* hex_buffer, |
| 213 intptr_t hex_size, | 214 intptr_t hex_size, |
| 214 char* human_buffer, | 215 char* human_buffer, |
| 215 intptr_t human_size, | 216 intptr_t human_size, |
| 216 int* out_instr_size, | 217 int* out_instr_size, |
| 218 const Code& code, |
| 219 Object** object, |
| 217 uword pc) { | 220 uword pc) { |
| 218 const uint32_t instr = *reinterpret_cast<uint32_t*>(pc); | 221 const uint32_t instr = *reinterpret_cast<uint32_t*>(pc); |
| 219 const uint8_t opcode = instr & 0xFF; | 222 const uint8_t opcode = instr & 0xFF; |
| 220 ASSERT(opcode < kOpcodeCount); | 223 ASSERT(opcode < kOpcodeCount); |
| 221 size_t name_size = | 224 size_t name_size = |
| 222 OS::SNPrint(human_buffer, human_size, "%-10s\t", kOpcodeNames[opcode]); | 225 OS::SNPrint(human_buffer, human_size, "%-10s\t", kOpcodeNames[opcode]); |
| 223 | 226 |
| 224 human_buffer += name_size; | 227 human_buffer += name_size; |
| 225 human_size -= name_size; | 228 human_size -= name_size; |
| 226 kFormatters[opcode](human_buffer, human_size, pc, instr); | 229 kFormatters[opcode](human_buffer, human_size, pc, instr); |
| 227 | 230 |
| 228 OS::SNPrint(hex_buffer, hex_size, "%08x", instr); | 231 OS::SNPrint(hex_buffer, hex_size, "%08x", instr); |
| 229 if (out_instr_size) { | 232 if (out_instr_size) { |
| 230 *out_instr_size = sizeof(uint32_t); | 233 *out_instr_size = sizeof(uint32_t); |
| 231 } | 234 } |
| 235 |
| 236 *object = NULL; |
| 237 if (!code.IsNull()) { |
| 238 *object = &Object::Handle(); |
| 239 if (!DecodeLoadObjectFromPoolOrThread(pc, code, *object)) { |
| 240 *object = NULL; |
| 241 } |
| 242 } |
| 232 } | 243 } |
| 233 | 244 |
| 234 | 245 |
| 235 } // namespace dart | 246 } // namespace dart |
| 236 | 247 |
| 237 #endif // defined TARGET_ARCH_DBC | 248 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |