OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <assert.h> | 5 #include <assert.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdarg.h> | 7 #include <stdarg.h> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 AppendToBuffer("'Unimplemented Instruction'"); | 423 AppendToBuffer("'Unimplemented Instruction'"); |
424 } | 424 } |
425 } | 425 } |
426 }; | 426 }; |
427 | 427 |
428 | 428 |
429 void DisassemblerX64::AppendToBuffer(const char* format, ...) { | 429 void DisassemblerX64::AppendToBuffer(const char* format, ...) { |
430 v8::internal::Vector<char> buf = tmp_buffer_ + tmp_buffer_pos_; | 430 v8::internal::Vector<char> buf = tmp_buffer_ + tmp_buffer_pos_; |
431 va_list args; | 431 va_list args; |
432 va_start(args, format); | 432 va_start(args, format); |
433 int result = v8::internal::OS::VSNPrintF(buf, format, args); | 433 int result = v8::internal::VSNPrintF(buf, format, args); |
434 va_end(args); | 434 va_end(args); |
435 tmp_buffer_pos_ += result; | 435 tmp_buffer_pos_ += result; |
436 } | 436 } |
437 | 437 |
438 | 438 |
439 int DisassemblerX64::PrintRightOperandHelper( | 439 int DisassemblerX64::PrintRightOperandHelper( |
440 byte* modrmp, | 440 byte* modrmp, |
441 RegisterNameMapping direct_register_name) { | 441 RegisterNameMapping direct_register_name) { |
442 int mod, regop, rm; | 442 int mod, regop, rm; |
443 get_modrm(*modrmp, &mod, ®op, &rm); | 443 get_modrm(*modrmp, &mod, ®op, &rm); |
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 if (tmp_buffer_pos_ < sizeof tmp_buffer_) { | 1786 if (tmp_buffer_pos_ < sizeof tmp_buffer_) { |
1787 tmp_buffer_[tmp_buffer_pos_] = '\0'; | 1787 tmp_buffer_[tmp_buffer_pos_] = '\0'; |
1788 } | 1788 } |
1789 | 1789 |
1790 int instr_len = static_cast<int>(data - instr); | 1790 int instr_len = static_cast<int>(data - instr); |
1791 ASSERT(instr_len > 0); // Ensure progress. | 1791 ASSERT(instr_len > 0); // Ensure progress. |
1792 | 1792 |
1793 int outp = 0; | 1793 int outp = 0; |
1794 // Instruction bytes. | 1794 // Instruction bytes. |
1795 for (byte* bp = instr; bp < data; bp++) { | 1795 for (byte* bp = instr; bp < data; bp++) { |
1796 outp += v8::internal::OS::SNPrintF(out_buffer + outp, "%02x", *bp); | 1796 outp += v8::internal::SNPrintF(out_buffer + outp, "%02x", *bp); |
1797 } | 1797 } |
1798 for (int i = 6 - instr_len; i >= 0; i--) { | 1798 for (int i = 6 - instr_len; i >= 0; i--) { |
1799 outp += v8::internal::OS::SNPrintF(out_buffer + outp, " "); | 1799 outp += v8::internal::SNPrintF(out_buffer + outp, " "); |
1800 } | 1800 } |
1801 | 1801 |
1802 outp += v8::internal::OS::SNPrintF(out_buffer + outp, " %s", | 1802 outp += v8::internal::SNPrintF(out_buffer + outp, " %s", |
1803 tmp_buffer_.start()); | 1803 tmp_buffer_.start()); |
1804 return instr_len; | 1804 return instr_len; |
1805 } | 1805 } |
1806 | 1806 |
1807 | 1807 |
1808 //------------------------------------------------------------------------------ | 1808 //------------------------------------------------------------------------------ |
1809 | 1809 |
1810 | 1810 |
1811 static const char* cpu_regs[16] = { | 1811 static const char* cpu_regs[16] = { |
1812 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", | 1812 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", |
1813 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" | 1813 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
1814 }; | 1814 }; |
1815 | 1815 |
1816 | 1816 |
1817 static const char* byte_cpu_regs[16] = { | 1817 static const char* byte_cpu_regs[16] = { |
1818 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", | 1818 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", |
1819 "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l" | 1819 "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l" |
1820 }; | 1820 }; |
1821 | 1821 |
1822 | 1822 |
1823 static const char* xmm_regs[16] = { | 1823 static const char* xmm_regs[16] = { |
1824 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", | 1824 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", |
1825 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" | 1825 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" |
1826 }; | 1826 }; |
1827 | 1827 |
1828 | 1828 |
1829 const char* NameConverter::NameOfAddress(byte* addr) const { | 1829 const char* NameConverter::NameOfAddress(byte* addr) const { |
1830 v8::internal::OS::SNPrintF(tmp_buffer_, "%p", addr); | 1830 v8::internal::SNPrintF(tmp_buffer_, "%p", addr); |
1831 return tmp_buffer_.start(); | 1831 return tmp_buffer_.start(); |
1832 } | 1832 } |
1833 | 1833 |
1834 | 1834 |
1835 const char* NameConverter::NameOfConstant(byte* addr) const { | 1835 const char* NameConverter::NameOfConstant(byte* addr) const { |
1836 return NameOfAddress(addr); | 1836 return NameOfAddress(addr); |
1837 } | 1837 } |
1838 | 1838 |
1839 | 1839 |
1840 const char* NameConverter::NameOfCPURegister(int reg) const { | 1840 const char* NameConverter::NameOfCPURegister(int reg) const { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { | 1903 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { |
1904 fprintf(f, " "); | 1904 fprintf(f, " "); |
1905 } | 1905 } |
1906 fprintf(f, " %s\n", buffer.start()); | 1906 fprintf(f, " %s\n", buffer.start()); |
1907 } | 1907 } |
1908 } | 1908 } |
1909 | 1909 |
1910 } // namespace disasm | 1910 } // namespace disasm |
1911 | 1911 |
1912 #endif // V8_TARGET_ARCH_X64 | 1912 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |