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

Unified Diff: runtime/vm/report.cc

Issue 1368173002: Do not eagerly finalize when optimizing. Remove allocation of temporary strings in new space. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Improve comments Created 5 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/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/report.cc
diff --git a/runtime/vm/report.cc b/runtime/vm/report.cc
index 5637adce8be48654cec843bf41c316bed98b9e09..f1cf49508a1c40c470a1a9de33a5cb8beef74354 100644
--- a/runtime/vm/report.cc
+++ b/runtime/vm/report.cc
@@ -46,42 +46,54 @@ RawString* Report::PrependSnippet(Kind kind,
// Only report the line position if we have the original source. We still
// need to get a valid column so that we can report the ^ mark below the
// snippet.
+ // Allocate formatted strings in old sapce as they may be created during
+ // optimizing compilation. Those strings are created rarely and should not
+ // polute old space.
if (script.HasSource()) {
- result = String::NewFormatted("'%s': %s: line %" Pd " pos %" Pd ": ",
+ result = String::NewFormatted(Heap::kOld,
+ "'%s': %s: line %" Pd " pos %" Pd ": ",
script_url.ToCString(),
message_header,
line,
column);
} else {
- result = String::NewFormatted("'%s': %s: line %" Pd ": ",
+ result = String::NewFormatted(Heap::kOld,
+ "'%s': %s: line %" Pd ": ",
script_url.ToCString(),
message_header,
line);
}
// Append the formatted error or warning message.
- result = String::Concat(result, message);
+ GrowableHandlePtrArray<const String> strs(Thread::Current()->zone(), 5);
+ strs.Add(result);
+ strs.Add(message);
// Append the source line.
- const String& script_line = String::Handle(script.GetLine(line));
+ const String& script_line = String::Handle(
+ script.GetLine(line, Heap::kOld));
ASSERT(!script_line.IsNull());
- result = String::Concat(result, Symbols::NewLine());
- result = String::Concat(result, script_line);
- result = String::Concat(result, Symbols::NewLine());
+ strs.Add(Symbols::NewLine());
+ strs.Add(script_line);
+ strs.Add(Symbols::NewLine());
// Append the column marker.
const String& column_line = String::Handle(
- String::NewFormatted("%*s\n", static_cast<int>(column), "^"));
- result = String::Concat(result, column_line);
+ String::NewFormatted(Heap::kOld,
+ "%*s\n", static_cast<int>(column), "^"));
+ strs.Add(column_line);
+ // TODO(srdjan): Use Strings::FromConcatAll in old space, once
+ // implemented.
+ result = Symbols::FromConcatAll(strs);
} else {
// Token position is unknown.
- result = String::NewFormatted("'%s': %s: ",
+ result = String::NewFormatted(Heap::kOld, "'%s': %s: ",
script_url.ToCString(),
message_header);
- result = String::Concat(result, message);
+ result = String::Concat(result, message, Heap::kOld);
}
} else {
// Script is unknown.
// Append the formatted error or warning message.
- result = String::NewFormatted("%s: ", message_header);
- result = String::Concat(result, message);
+ result = String::NewFormatted(Heap::kOld, "%s: ", message_header);
+ result = String::Concat(result, message, Heap::kOld);
}
return result.raw();
}
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698