Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: runtime/vm/disassembler_x64.cc

Issue 10918008: Restrict objects printing in disassembler to avoid GC. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/disassembler_ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 break; 763 break;
764 } 764 }
765 default: 765 default:
766 UNREACHABLE(); 766 UNREACHABLE();
767 break; 767 break;
768 } 768 }
769 return advance; 769 return advance;
770 } 770 }
771 771
772 772
773 static const char* ObjectToCStringNoGC(const Object& obj) {
774 if (obj.IsSmi() ||
775 obj.IsMint() ||
776 obj.IsDouble() ||
777 obj.IsString() ||
778 obj.IsNull() ||
779 obj.IsBool() ||
780 obj.IsClass() ||
781 obj.IsFunction() ||
782 obj.IsICData() ||
783 obj.IsField()) {
784 return obj.ToCString();
785 }
786
787 const Class& clazz = Class::CheckedHandle(obj.clazz());
788 const char* full_class_name = clazz.ToCString();
789 const char* format = "instance of %s";
790 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1;
791 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
792 OS::SNPrint(chars, len, format, full_class_name);
793 return chars;
794 }
795
796
773 void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) { 797 void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) {
774 NoGCScope no_gc; 798 NoGCScope no_gc;
775 uword addr = reinterpret_cast<uword>(addr_byte_ptr); 799 uword addr = reinterpret_cast<uword>(addr_byte_ptr);
776 AppendToBuffer("0x%0"PRIxPTR, addr); 800 AppendToBuffer("0x%0"PRIxPTR, addr);
777 // Try to print as heap object or stub name 801 // Try to print as heap object or stub name
778 if (!Isolate::Current()->heap()->CodeContains(addr) && 802 if (!Isolate::Current()->heap()->CodeContains(addr) &&
779 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { 803 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) {
780 Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); 804 Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr));
781 if (obj.IsArray()) { 805 if (obj.IsArray()) {
782 const Array& arr = Array::CheckedHandle(obj.raw()); 806 const Array& arr = Array::CheckedHandle(obj.raw());
783 intptr_t len = arr.Length(); 807 intptr_t len = arr.Length();
784 if (len > 5) len = 5; // Print a max of 5 elements. 808 if (len > 5) len = 5; // Print a max of 5 elements.
785 AppendToBuffer(" Array["); 809 AppendToBuffer(" Array[");
786 int i = 0; 810 int i = 0;
787 while (i < len) { 811 while (i < len) {
788 obj = arr.At(i); 812 obj = arr.At(i);
789 if (i > 0) AppendToBuffer(", "); 813 if (i > 0) AppendToBuffer(", ");
790 AppendToBuffer(obj.ToCString()); 814 AppendToBuffer(ObjectToCStringNoGC(obj));
791 i++; 815 i++;
792 } 816 }
793 if (i < arr.Length()) AppendToBuffer(", ..."); 817 if (i < arr.Length()) AppendToBuffer(", ...");
794 AppendToBuffer("]"); 818 AppendToBuffer("]");
795 return; 819 return;
796 } 820 }
797 AppendToBuffer(" '%s'", obj.ToCString()); 821 AppendToBuffer(" '%s'", ObjectToCStringNoGC(obj));
798 } else { 822 } else {
799 // 'addr' is not an object, but probably a code address. 823 // 'addr' is not an object, but probably a code address.
800 const char* name_of_stub = StubCode::NameOfStub(addr); 824 const char* name_of_stub = StubCode::NameOfStub(addr);
801 if (name_of_stub != NULL) { 825 if (name_of_stub != NULL) {
802 AppendToBuffer(" [stub: %s]", name_of_stub); 826 AppendToBuffer(" [stub: %s]", name_of_stub);
803 } else { 827 } else {
804 // Print only if jumping to entry point. 828 // Print only if jumping to entry point.
805 const Code& code = Code::Handle(Code::LookupCode(addr)); 829 const Code& code = Code::Handle(Code::LookupCode(addr));
806 if (!code.IsNull() && (code.EntryPoint() == addr)) { 830 if (!code.IsNull() && (code.EntryPoint() == addr)) {
807 const Function& function = Function::Handle(code.function()); 831 const Function& function = Function::Handle(code.function());
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 human_buffer, 1856 human_buffer,
1833 sizeof(human_buffer), 1857 sizeof(human_buffer),
1834 pc); 1858 pc);
1835 pc += instruction_length; 1859 pc += instruction_length;
1836 } 1860 }
1837 } 1861 }
1838 1862
1839 } // namespace dart 1863 } // namespace dart
1840 1864
1841 #endif // defined TARGET_ARCH_X64 1865 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/disassembler_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698