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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 obj.IsString() || | 784 obj.IsString() || |
785 obj.IsNull() || | 785 obj.IsNull() || |
786 obj.IsBool() || | 786 obj.IsBool() || |
787 obj.IsClass() || | 787 obj.IsClass() || |
788 obj.IsFunction() || | 788 obj.IsFunction() || |
789 obj.IsICData() || | 789 obj.IsICData() || |
790 obj.IsField()) { | 790 obj.IsField()) { |
791 return obj.ToCString(); | 791 return obj.ToCString(); |
792 } | 792 } |
793 | 793 |
794 const Class& clazz = Class::CheckedHandle(obj.clazz()); | 794 const Class& clazz = Class::Handle(obj.clazz()); |
795 const char* full_class_name = clazz.ToCString(); | 795 const char* full_class_name = clazz.ToCString(); |
796 const char* format = "instance of %s"; | 796 const char* format = "instance of %s"; |
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 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::CheckedHandle(obj.raw()); | 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["); |
818 int i = 0; | 818 int i = 0; |
| 819 Object& element = Object::Handle(); |
819 while (i < len) { | 820 while (i < len) { |
820 obj = arr.At(i); | 821 element = arr.At(i); |
821 if (i > 0) AppendToBuffer(", "); | 822 if (i > 0) AppendToBuffer(", "); |
822 AppendToBuffer("%s", ObjectToCStringNoGC(obj)); | 823 AppendToBuffer("%s", ObjectToCStringNoGC(element)); |
823 i++; | 824 i++; |
824 } | 825 } |
825 if (i < arr.Length()) AppendToBuffer(", ..."); | 826 if (i < arr.Length()) AppendToBuffer(", ..."); |
826 AppendToBuffer("]"); | 827 AppendToBuffer("]"); |
827 return; | 828 return; |
828 } | 829 } |
829 AppendToBuffer(" '%s'", ObjectToCStringNoGC(obj)); | 830 AppendToBuffer(" '%s'", ObjectToCStringNoGC(obj)); |
830 } else { | 831 } else { |
831 // 'addr' is not an object, but probably a code address. | 832 // 'addr' is not an object, but probably a code address. |
832 const char* name_of_stub = StubCode::NameOfStub(addr); | 833 const char* name_of_stub = StubCode::NameOfStub(addr); |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 const Code::Comments& comments) { | 1844 const Code::Comments& comments) { |
1844 ASSERT(formatter != NULL); | 1845 ASSERT(formatter != NULL); |
1845 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | 1846 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. |
1846 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | 1847 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. |
1847 uword pc = start; | 1848 uword pc = start; |
1848 intptr_t comment_finger = 0; | 1849 intptr_t comment_finger = 0; |
1849 while (pc < end) { | 1850 while (pc < end) { |
1850 const intptr_t offset = pc - start; | 1851 const intptr_t offset = pc - start; |
1851 while (comment_finger < comments.Length() && | 1852 while (comment_finger < comments.Length() && |
1852 comments.PCOffsetAt(comment_finger) <= offset) { | 1853 comments.PCOffsetAt(comment_finger) <= offset) { |
1853 formatter->Print(" ;; %s\n", | 1854 formatter->Print( |
1854 comments.CommentAt(comment_finger).ToCString()); | 1855 " ;; %s\n", |
| 1856 String::Handle(comments.CommentAt(comment_finger)).ToCString()); |
1855 comment_finger++; | 1857 comment_finger++; |
1856 } | 1858 } |
1857 int instruction_length = DecodeInstruction(hex_buffer, | 1859 int instruction_length = DecodeInstruction(hex_buffer, |
1858 sizeof(hex_buffer), | 1860 sizeof(hex_buffer), |
1859 human_buffer, | 1861 human_buffer, |
1860 sizeof(human_buffer), | 1862 sizeof(human_buffer), |
1861 pc); | 1863 pc); |
1862 formatter->ConsumeInstruction(hex_buffer, | 1864 formatter->ConsumeInstruction(hex_buffer, |
1863 sizeof(hex_buffer), | 1865 sizeof(hex_buffer), |
1864 human_buffer, | 1866 human_buffer, |
1865 sizeof(human_buffer), | 1867 sizeof(human_buffer), |
1866 pc); | 1868 pc); |
1867 pc += instruction_length; | 1869 pc += instruction_length; |
1868 } | 1870 } |
1869 } | 1871 } |
1870 | 1872 |
1871 } // namespace dart | 1873 } // namespace dart |
1872 | 1874 |
1873 #endif // defined TARGET_ARCH_X64 | 1875 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |