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

Unified Diff: runtime/vm/disassembler.cc

Issue 2363413004: VM: Avoid allocating strings when disassembling code. (Closed)
Patch Set: addressed comments Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/disassembler.cc
diff --git a/runtime/vm/disassembler.cc b/runtime/vm/disassembler.cc
index abf9c849878565f65752d0e021618e306fbcfbce..dbd7eaa3cca0d7b945f3f4a5e72f2be53df49645 100644
--- a/runtime/vm/disassembler.cc
+++ b/runtime/vm/disassembler.cc
@@ -105,6 +105,7 @@ void Disassembler::Disassemble(uword start,
uword end,
DisassemblyFormatter* formatter,
const Code& code) {
+ NoSafepointScope no_safepoint;
const Code::Comments& comments =
code.IsNull() ? Code::Comments::New(0) : code.comments();
ASSERT(formatter != NULL);
@@ -165,6 +166,13 @@ void Disassembler::Disassemble(uword start,
void Disassembler::DisassembleCodeHelper(
const char* function_fullname, const Code& code, bool optimized) {
+ LocalVarDescriptors& var_descriptors = LocalVarDescriptors::Handle();
+ if (FLAG_print_variable_descriptors) {
+ // This flag is not on by default, and for debugging purposes only.
+ // Since this may allocate, do it outside the NoSafepointScope.
+ var_descriptors = code.GetLocalVarDescriptors();
+ }
+ NoSafepointScope no_safepoint;
THR_Print("Code for %sfunction '%s' {\n",
optimized ? "optimized " : "",
function_fullname);
@@ -232,8 +240,6 @@ void Disassembler::DisassembleCodeHelper(
if (FLAG_print_variable_descriptors) {
THR_Print("Variable Descriptors for function '%s' {\n",
function_fullname);
- const LocalVarDescriptors& var_descriptors =
- LocalVarDescriptors::Handle(code.GetLocalVarDescriptors());
intptr_t var_desc_length =
var_descriptors.IsNull() ? 0 : var_descriptors.Length();
String& var_name = String::Handle();
@@ -283,10 +289,9 @@ void Disassembler::DisassembleCodeHelper(
Class& cls = Class::Handle();
cls ^= code.owner();
if (cls.IsNull()) {
- const String& code_name = String::Handle(code.Name());
THR_Print(" 0x%" Px ": %s, %p\n",
start + offset.Value(),
- code_name.ToCString(),
+ code.Name(),
code.raw());
} else {
THR_Print(" 0x%" Px ": allocation stub for %s, %p\n",
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698