OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 UNSET_OP_ORDER = 0, | 42 UNSET_OP_ORDER = 0, |
43 // Operand size decides between 16, 32 and 64 bit operands. | 43 // Operand size decides between 16, 32 and 64 bit operands. |
44 REG_OPER_OP_ORDER = 1, // Register destination, operand source. | 44 REG_OPER_OP_ORDER = 1, // Register destination, operand source. |
45 OPER_REG_OP_ORDER = 2, // Operand destination, register source. | 45 OPER_REG_OP_ORDER = 2, // Operand destination, register source. |
46 // Fixed 8-bit operands. | 46 // Fixed 8-bit operands. |
47 BYTE_SIZE_OPERAND_FLAG = 4, | 47 BYTE_SIZE_OPERAND_FLAG = 4, |
48 BYTE_REG_OPER_OP_ORDER = REG_OPER_OP_ORDER | BYTE_SIZE_OPERAND_FLAG, | 48 BYTE_REG_OPER_OP_ORDER = REG_OPER_OP_ORDER | BYTE_SIZE_OPERAND_FLAG, |
49 BYTE_OPER_REG_OP_ORDER = OPER_REG_OP_ORDER | BYTE_SIZE_OPERAND_FLAG | 49 BYTE_OPER_REG_OP_ORDER = OPER_REG_OP_ORDER | BYTE_SIZE_OPERAND_FLAG |
50 }; | 50 }; |
51 | 51 |
| 52 |
52 //------------------------------------------------------------------ | 53 //------------------------------------------------------------------ |
53 // Tables | 54 // Tables |
54 //------------------------------------------------------------------ | 55 //------------------------------------------------------------------ |
55 struct ByteMnemonic { | 56 struct ByteMnemonic { |
56 int b; // -1 terminates, otherwise must be in range (0..255) | 57 int b; // -1 terminates, otherwise must be in range (0..255) |
57 OperandType op_order_; | 58 OperandType op_order_; |
58 const char* mnem; | 59 const char* mnem; |
59 }; | 60 }; |
60 | 61 |
61 | 62 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 {"cmovs", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 287 {"cmovs", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
287 {"cmovns", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 288 {"cmovns", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
288 {"cmovpe", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 289 {"cmovpe", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
289 {"cmovpo", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 290 {"cmovpo", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
290 {"cmovl", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 291 {"cmovl", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
291 {"cmovge", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 292 {"cmovge", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
292 {"cmovle", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, | 293 {"cmovle", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false}, |
293 {"cmovg", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false} | 294 {"cmovg", TWO_OPERANDS_INSTR, REG_OPER_OP_ORDER, false} |
294 }; | 295 }; |
295 | 296 |
| 297 |
296 //------------------------------------------------------------------------------ | 298 //------------------------------------------------------------------------------ |
297 // DisassemblerX64 implementation. | 299 // DisassemblerX64 implementation. |
298 | 300 |
299 enum UnimplementedOpcodeAction { | 301 enum UnimplementedOpcodeAction { |
300 CONTINUE_ON_UNIMPLEMENTED_OPCODE, | 302 CONTINUE_ON_UNIMPLEMENTED_OPCODE, |
301 ABORT_ON_UNIMPLEMENTED_OPCODE | 303 ABORT_ON_UNIMPLEMENTED_OPCODE |
302 }; | 304 }; |
303 | 305 |
| 306 |
304 // A new DisassemblerX64 object is created to disassemble each instruction. | 307 // A new DisassemblerX64 object is created to disassemble each instruction. |
305 // The object can only disassemble a single instruction. | 308 // The object can only disassemble a single instruction. |
306 class DisassemblerX64 { | 309 class DisassemblerX64 { |
307 public: | 310 public: |
308 DisassemblerX64(const NameConverter& converter, | 311 DisassemblerX64(const NameConverter& converter, |
309 UnimplementedOpcodeAction unimplemented_action = | 312 UnimplementedOpcodeAction unimplemented_action = |
310 ABORT_ON_UNIMPLEMENTED_OPCODE) | 313 ABORT_ON_UNIMPLEMENTED_OPCODE) |
311 : converter_(converter), | 314 : converter_(converter), |
312 tmp_buffer_pos_(0), | 315 tmp_buffer_pos_(0), |
313 abort_on_unimplemented_( | 316 abort_on_unimplemented_( |
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 } | 1759 } |
1757 for (int i = 6 - instr_len; i >= 0; i--) { | 1760 for (int i = 6 - instr_len; i >= 0; i--) { |
1758 outp += v8::internal::OS::SNPrintF(out_buffer + outp, " "); | 1761 outp += v8::internal::OS::SNPrintF(out_buffer + outp, " "); |
1759 } | 1762 } |
1760 | 1763 |
1761 outp += v8::internal::OS::SNPrintF(out_buffer + outp, " %s", | 1764 outp += v8::internal::OS::SNPrintF(out_buffer + outp, " %s", |
1762 tmp_buffer_.start()); | 1765 tmp_buffer_.start()); |
1763 return instr_len; | 1766 return instr_len; |
1764 } | 1767 } |
1765 | 1768 |
| 1769 |
1766 //------------------------------------------------------------------------------ | 1770 //------------------------------------------------------------------------------ |
1767 | 1771 |
1768 | 1772 |
1769 static const char* cpu_regs[16] = { | 1773 static const char* cpu_regs[16] = { |
1770 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", | 1774 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", |
1771 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" | 1775 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
1772 }; | 1776 }; |
1773 | 1777 |
1774 | 1778 |
1775 static const char* byte_cpu_regs[16] = { | 1779 static const char* byte_cpu_regs[16] = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 return "noxmmreg"; | 1819 return "noxmmreg"; |
1816 } | 1820 } |
1817 | 1821 |
1818 | 1822 |
1819 const char* NameConverter::NameInCode(byte* addr) const { | 1823 const char* NameConverter::NameInCode(byte* addr) const { |
1820 // X64 does not embed debug strings at the moment. | 1824 // X64 does not embed debug strings at the moment. |
1821 UNREACHABLE(); | 1825 UNREACHABLE(); |
1822 return ""; | 1826 return ""; |
1823 } | 1827 } |
1824 | 1828 |
| 1829 |
1825 //------------------------------------------------------------------------------ | 1830 //------------------------------------------------------------------------------ |
1826 | 1831 |
1827 Disassembler::Disassembler(const NameConverter& converter) | 1832 Disassembler::Disassembler(const NameConverter& converter) |
1828 : converter_(converter) { } | 1833 : converter_(converter) { } |
1829 | 1834 |
1830 Disassembler::~Disassembler() { } | 1835 Disassembler::~Disassembler() { } |
1831 | 1836 |
1832 | 1837 |
1833 int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer, | 1838 int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer, |
1834 byte* instruction) { | 1839 byte* instruction) { |
(...skipping 25 matching lines...) Expand all Loading... |
1860 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { | 1865 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { |
1861 fprintf(f, " "); | 1866 fprintf(f, " "); |
1862 } | 1867 } |
1863 fprintf(f, " %s\n", buffer.start()); | 1868 fprintf(f, " %s\n", buffer.start()); |
1864 } | 1869 } |
1865 } | 1870 } |
1866 | 1871 |
1867 } // namespace disasm | 1872 } // namespace disasm |
1868 | 1873 |
1869 #endif // V8_TARGET_ARCH_X64 | 1874 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |