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

Unified Diff: runtime/vm/disassembler_ia32.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 | « no previous file | runtime/vm/disassembler_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/disassembler_ia32.cc
diff --git a/runtime/vm/disassembler_ia32.cc b/runtime/vm/disassembler_ia32.cc
index 37691249dedb8340315936f7d5cb36fc5bec1b4b..144ae9bad822e547dcd1fbe0a509e48b3872deeb 100644
--- a/runtime/vm/disassembler_ia32.cc
+++ b/runtime/vm/disassembler_ia32.cc
@@ -390,6 +390,30 @@ void X86Decoder::PrintXmmRegister(int reg) {
}
+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 X86Decoder::PrintAddress(uword addr) {
NoGCScope no_gc;
char addr_buffer[32];
@@ -408,7 +432,7 @@ void X86Decoder::PrintAddress(uword addr) {
while (i < len) {
obj = arr.At(i);
if (i > 0) Print(", ");
- Print(obj.ToCString());
+ Print(ObjectToCStringNoGC(obj));
i++;
}
if (i < arr.Length()) Print(", ...");
@@ -416,7 +440,7 @@ void X86Decoder::PrintAddress(uword addr) {
return;
}
Print(" '");
- Print(obj.ToCString());
+ Print(ObjectToCStringNoGC(obj));
Print("'");
} else {
// 'addr' is not an object, but probably a code address.
« no previous file with comments | « no previous file | runtime/vm/disassembler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698