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

Side by Side 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, 2 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
« no previous file with comments | « runtime/vm/object.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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/report.h" 5 #include "vm/report.h"
6 6
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 String& result = String::Handle(); 40 String& result = String::Handle();
41 if (!script.IsNull()) { 41 if (!script.IsNull()) {
42 const String& script_url = String::Handle(script.url()); 42 const String& script_url = String::Handle(script.url());
43 if (token_pos >= 0) { 43 if (token_pos >= 0) {
44 intptr_t line, column; 44 intptr_t line, column;
45 script.GetTokenLocation(token_pos, &line, &column); 45 script.GetTokenLocation(token_pos, &line, &column);
46 // Only report the line position if we have the original source. We still 46 // Only report the line position if we have the original source. We still
47 // need to get a valid column so that we can report the ^ mark below the 47 // need to get a valid column so that we can report the ^ mark below the
48 // snippet. 48 // snippet.
49 // Allocate formatted strings in old sapce as they may be created during
50 // optimizing compilation. Those strings are created rarely and should not
51 // polute old space.
49 if (script.HasSource()) { 52 if (script.HasSource()) {
50 result = String::NewFormatted("'%s': %s: line %" Pd " pos %" Pd ": ", 53 result = String::NewFormatted(Heap::kOld,
54 "'%s': %s: line %" Pd " pos %" Pd ": ",
51 script_url.ToCString(), 55 script_url.ToCString(),
52 message_header, 56 message_header,
53 line, 57 line,
54 column); 58 column);
55 } else { 59 } else {
56 result = String::NewFormatted("'%s': %s: line %" Pd ": ", 60 result = String::NewFormatted(Heap::kOld,
61 "'%s': %s: line %" Pd ": ",
57 script_url.ToCString(), 62 script_url.ToCString(),
58 message_header, 63 message_header,
59 line); 64 line);
60 } 65 }
61 // Append the formatted error or warning message. 66 // Append the formatted error or warning message.
62 result = String::Concat(result, message); 67 GrowableHandlePtrArray<const String> strs(Thread::Current()->zone(), 5);
68 strs.Add(result);
69 strs.Add(message);
63 // Append the source line. 70 // Append the source line.
64 const String& script_line = String::Handle(script.GetLine(line)); 71 const String& script_line = String::Handle(
72 script.GetLine(line, Heap::kOld));
65 ASSERT(!script_line.IsNull()); 73 ASSERT(!script_line.IsNull());
66 result = String::Concat(result, Symbols::NewLine()); 74 strs.Add(Symbols::NewLine());
67 result = String::Concat(result, script_line); 75 strs.Add(script_line);
68 result = String::Concat(result, Symbols::NewLine()); 76 strs.Add(Symbols::NewLine());
69 // Append the column marker. 77 // Append the column marker.
70 const String& column_line = String::Handle( 78 const String& column_line = String::Handle(
71 String::NewFormatted("%*s\n", static_cast<int>(column), "^")); 79 String::NewFormatted(Heap::kOld,
72 result = String::Concat(result, column_line); 80 "%*s\n", static_cast<int>(column), "^"));
81 strs.Add(column_line);
82 // TODO(srdjan): Use Strings::FromConcatAll in old space, once
83 // implemented.
84 result = Symbols::FromConcatAll(strs);
73 } else { 85 } else {
74 // Token position is unknown. 86 // Token position is unknown.
75 result = String::NewFormatted("'%s': %s: ", 87 result = String::NewFormatted(Heap::kOld, "'%s': %s: ",
76 script_url.ToCString(), 88 script_url.ToCString(),
77 message_header); 89 message_header);
78 result = String::Concat(result, message); 90 result = String::Concat(result, message, Heap::kOld);
79 } 91 }
80 } else { 92 } else {
81 // Script is unknown. 93 // Script is unknown.
82 // Append the formatted error or warning message. 94 // Append the formatted error or warning message.
83 result = String::NewFormatted("%s: ", message_header); 95 result = String::NewFormatted(Heap::kOld, "%s: ", message_header);
84 result = String::Concat(result, message); 96 result = String::Concat(result, message, Heap::kOld);
85 } 97 }
86 return result.raw(); 98 return result.raw();
87 } 99 }
88 100
89 101
90 void Report::LongJump(const Error& error) { 102 void Report::LongJump(const Error& error) {
91 Thread::Current()->long_jump_base()->Jump(1, error); 103 Thread::Current()->long_jump_base()->Jump(1, error);
92 UNREACHABLE(); 104 UNREACHABLE();
93 } 105 }
94 106
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 trace_warning.AddProperty("type", "JSCompatibilityWarning"); 252 trace_warning.AddProperty("type", "JSCompatibilityWarning");
241 trace_warning.AddProperty("script", script); 253 trace_warning.AddProperty("script", script);
242 trace_warning.AddProperty("tokenPos", token_pos); 254 trace_warning.AddProperty("tokenPos", token_pos);
243 trace_warning.AddProperty("message", message); 255 trace_warning.AddProperty("message", message);
244 } 256 }
245 trace_buffer->Trace(micros, js.ToCString(), true); // Already escaped. 257 trace_buffer->Trace(micros, js.ToCString(), true); // Already escaped.
246 } 258 }
247 259
248 } // namespace dart 260 } // namespace dart
249 261
OLDNEW
« 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