OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IA32. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
8 #if defined(TARGET_ARCH_X64) | 8 #if defined(TARGET_ARCH_X64) |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 break; | 559 break; |
560 case QUADWORD_SIZE: | 560 case QUADWORD_SIZE: |
561 value = *reinterpret_cast<int32_t*>(data); | 561 value = *reinterpret_cast<int32_t*>(data); |
562 count = 4; | 562 count = 4; |
563 break; | 563 break; |
564 default: | 564 default: |
565 UNREACHABLE(); | 565 UNREACHABLE(); |
566 value = 0; // Initialize variables on all paths to satisfy the compiler. | 566 value = 0; // Initialize variables on all paths to satisfy the compiler. |
567 count = 0; | 567 count = 0; |
568 } | 568 } |
569 AppendToBuffer("%#"Px64"", value); | 569 AppendToBuffer("%#" Px64 "", value); |
570 return count; | 570 return count; |
571 } | 571 } |
572 | 572 |
573 | 573 |
574 // Returns number of bytes used by machine instruction, including *data byte. | 574 // Returns number of bytes used by machine instruction, including *data byte. |
575 // Writes immediate instructions to 'tmp_buffer_'. | 575 // Writes immediate instructions to 'tmp_buffer_'. |
576 int DisassemblerX64::PrintImmediateOp(uint8_t* data) { | 576 int DisassemblerX64::PrintImmediateOp(uint8_t* data) { |
577 bool byte_size_immediate = (*data & 0x02) != 0; | 577 bool byte_size_immediate = (*data & 0x02) != 0; |
578 uint8_t modrm = *(data + 1); | 578 uint8_t modrm = *(data + 1); |
579 int mod, regop, rm; | 579 int mod, regop, rm; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; | 797 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; |
798 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 798 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
799 OS::SNPrint(chars, len, format, full_class_name); | 799 OS::SNPrint(chars, len, format, full_class_name); |
800 return chars; | 800 return chars; |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) { | 804 void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) { |
805 NoGCScope no_gc; | 805 NoGCScope no_gc; |
806 uword addr = reinterpret_cast<uword>(addr_byte_ptr); | 806 uword addr = reinterpret_cast<uword>(addr_byte_ptr); |
807 AppendToBuffer("%#"Px"", addr); | 807 AppendToBuffer("%#" Px "", addr); |
808 // Try to print as heap object or stub name | 808 // Try to print as heap object or stub name |
809 if (((addr & kSmiTagMask) == kHeapObjectTag) && | 809 if (((addr & kSmiTagMask) == kHeapObjectTag) && |
810 !Isolate::Current()->heap()->CodeContains(addr) && | 810 !Isolate::Current()->heap()->CodeContains(addr) && |
811 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { | 811 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { |
812 const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); | 812 const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); |
813 if (obj.IsArray()) { | 813 if (obj.IsArray()) { |
814 const Array& arr = Array::Cast(obj); | 814 const Array& arr = Array::Cast(obj); |
815 intptr_t len = arr.Length(); | 815 intptr_t len = arr.Length(); |
816 if (len > 5) len = 5; // Print a max of 5 elements. | 816 if (len > 5) len = 5; // Print a max of 5 elements. |
817 AppendToBuffer(" Array["); | 817 AppendToBuffer(" Array["); |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 value = *reinterpret_cast<uint32_t*>(data + 1); | 1820 value = *reinterpret_cast<uint32_t*>(data + 1); |
1821 data += 5; | 1821 data += 5; |
1822 break; | 1822 break; |
1823 case QUADWORD_SIZE: | 1823 case QUADWORD_SIZE: |
1824 value = *reinterpret_cast<int32_t*>(data + 1); | 1824 value = *reinterpret_cast<int32_t*>(data + 1); |
1825 data += 5; | 1825 data += 5; |
1826 break; | 1826 break; |
1827 default: | 1827 default: |
1828 UNREACHABLE(); | 1828 UNREACHABLE(); |
1829 } | 1829 } |
1830 AppendToBuffer("test%c rax,%#"Px64"", | 1830 AppendToBuffer("test%c rax,%#" Px64 "", |
1831 operand_size_code(), | 1831 operand_size_code(), |
1832 value); | 1832 value); |
1833 break; | 1833 break; |
1834 } | 1834 } |
1835 case 0xD1: // fall through | 1835 case 0xD1: // fall through |
1836 case 0xD3: // fall through | 1836 case 0xD3: // fall through |
1837 case 0xC1: | 1837 case 0xC1: |
1838 data += ShiftInstruction(data); | 1838 data += ShiftInstruction(data); |
1839 break; | 1839 break; |
1840 case 0xD0: // fall through | 1840 case 0xD0: // fall through |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 pc); | 1932 pc); |
1933 pc += instruction_length; | 1933 pc += instruction_length; |
1934 } | 1934 } |
1935 | 1935 |
1936 return; | 1936 return; |
1937 } | 1937 } |
1938 | 1938 |
1939 } // namespace dart | 1939 } // namespace dart |
1940 | 1940 |
1941 #endif // defined TARGET_ARCH_X64 | 1941 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |