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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/disassembler_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/disassembler_x64.cc
diff --git a/runtime/vm/disassembler_x64.cc b/runtime/vm/disassembler_x64.cc
index cb301272158ac3a1d635c3240500779f30ce1453..53460f55990934dc95a591d3d7927a586139a046 100644
--- a/runtime/vm/disassembler_x64.cc
+++ b/runtime/vm/disassembler_x64.cc
@@ -770,6 +770,30 @@ int DisassemblerX64::PrintOperands(const char* mnem,
}
+static const char* ObjectToCStringNoGC(const Object& obj) {
+ if (obj.IsSmi() ||
+ obj.IsMint() ||
+ obj.IsDouble() ||
+ obj.IsString() ||
+ obj.IsNull() ||
+ obj.IsBool() ||
+ obj.IsClass() ||
+ obj.IsFunction() ||
+ obj.IsICData() ||
+ obj.IsField()) {
+ return obj.ToCString();
+ }
+
+ const Class& clazz = Class::CheckedHandle(obj.clazz());
+ const char* full_class_name = clazz.ToCString();
+ const char* format = "instance of %s";
+ intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1;
+ char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
+ OS::SNPrint(chars, len, format, full_class_name);
+ return chars;
+}
+
+
void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) {
NoGCScope no_gc;
uword addr = reinterpret_cast<uword>(addr_byte_ptr);
@@ -787,14 +811,14 @@ void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) {
while (i < len) {
obj = arr.At(i);
if (i > 0) AppendToBuffer(", ");
- AppendToBuffer(obj.ToCString());
+ AppendToBuffer(ObjectToCStringNoGC(obj));
i++;
}
if (i < arr.Length()) AppendToBuffer(", ...");
AppendToBuffer("]");
return;
}
- AppendToBuffer(" '%s'", obj.ToCString());
+ AppendToBuffer(" '%s'", ObjectToCStringNoGC(obj));
} else {
// 'addr' is not an object, but probably a code address.
const char* name_of_stub = StubCode::NameOfStub(addr);
« 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