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

Side by Side Diff: runtime/vm/report.cc

Issue 1870343002: - Refactor Symbol allocation to expect a thread parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review feedback. Created 4 years, 8 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/regexp_test.cc ('k') | runtime/vm/resolver.h » ('j') | 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 25 matching lines...) Expand all
36 const String& script_url = String::Handle(script.url()); 36 const String& script_url = String::Handle(script.url());
37 if (token_pos.IsReal()) { 37 if (token_pos.IsReal()) {
38 intptr_t line, column, token_len; 38 intptr_t line, column, token_len;
39 script.GetTokenLocation(token_pos, &line, &column, &token_len); 39 script.GetTokenLocation(token_pos, &line, &column, &token_len);
40 if (report_after_token) { 40 if (report_after_token) {
41 column += token_len; 41 column += token_len;
42 } 42 }
43 // Only report the line position if we have the original source. We still 43 // Only report the line position if we have the original source. We still
44 // need to get a valid column so that we can report the ^ mark below the 44 // need to get a valid column so that we can report the ^ mark below the
45 // snippet. 45 // snippet.
46 // Allocate formatted strings in old sapce as they may be created during 46 // Allocate formatted strings in old space as they may be created during
47 // optimizing compilation. Those strings are created rarely and should not 47 // optimizing compilation. Those strings are created rarely and should not
48 // polute old space. 48 // polute old space.
49 if (script.HasSource()) { 49 if (script.HasSource()) {
50 result = String::NewFormatted(Heap::kOld, 50 result = String::NewFormatted(Heap::kOld,
51 "'%s': %s: line %" Pd " pos %" Pd ": ", 51 "'%s': %s: line %" Pd " pos %" Pd ": ",
52 script_url.ToCString(), 52 script_url.ToCString(),
53 message_header, 53 message_header,
54 line, 54 line,
55 column); 55 column);
56 } else { 56 } else {
57 result = String::NewFormatted(Heap::kOld, 57 result = String::NewFormatted(Heap::kOld,
58 "'%s': %s: line %" Pd ": ", 58 "'%s': %s: line %" Pd ": ",
59 script_url.ToCString(), 59 script_url.ToCString(),
60 message_header, 60 message_header,
61 line); 61 line);
62 } 62 }
63 // Append the formatted error or warning message. 63 // Append the formatted error or warning message.
64 GrowableHandlePtrArray<const String> strs(Thread::Current()->zone(), 5); 64 const Array& strs = Array::Handle(
65 strs.Add(result); 65 Array::New(6, Heap::kOld));
66 strs.Add(message); 66 strs.SetAt(0, result);
67 strs.SetAt(1, message);
67 // Append the source line. 68 // Append the source line.
68 const String& script_line = String::Handle( 69 const String& script_line = String::Handle(
69 script.GetLine(line, Heap::kOld)); 70 script.GetLine(line, Heap::kOld));
70 ASSERT(!script_line.IsNull()); 71 ASSERT(!script_line.IsNull());
71 strs.Add(Symbols::NewLine()); 72 strs.SetAt(2, Symbols::NewLine());
72 strs.Add(script_line); 73 strs.SetAt(3, script_line);
73 strs.Add(Symbols::NewLine()); 74 strs.SetAt(4, Symbols::NewLine());
74 // Append the column marker. 75 // Append the column marker.
75 const String& column_line = String::Handle( 76 const String& column_line = String::Handle(
76 String::NewFormatted(Heap::kOld, 77 String::NewFormatted(Heap::kOld,
77 "%*s\n", static_cast<int>(column), "^")); 78 "%*s\n", static_cast<int>(column), "^"));
78 strs.Add(column_line); 79 strs.SetAt(5, column_line);
79 // TODO(srdjan): Use Strings::FromConcatAll in old space, once 80 result = String::ConcatAll(strs, Heap::kOld);
80 // implemented.
81 result = Symbols::FromConcatAll(strs);
82 } else { 81 } else {
83 // Token position is unknown. 82 // Token position is unknown.
84 result = String::NewFormatted(Heap::kOld, "'%s': %s: ", 83 result = String::NewFormatted(Heap::kOld, "'%s': %s: ",
85 script_url.ToCString(), 84 script_url.ToCString(),
86 message_header); 85 message_header);
87 result = String::Concat(result, message, Heap::kOld); 86 result = String::Concat(result, message, Heap::kOld);
88 } 87 }
89 } else { 88 } else {
90 // Script is unknown. 89 // Script is unknown.
91 // Append the formatted error or warning message. 90 // Append the formatted error or warning message.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 LanguageError::NewFormattedV(Error::Handle(), // No previous error. 159 LanguageError::NewFormattedV(Error::Handle(), // No previous error.
161 script, token_pos, report_after_token, 160 script, token_pos, report_after_token,
162 kind, Heap::kOld, 161 kind, Heap::kOld,
163 format, args)); 162 format, args));
164 LongJump(error); 163 LongJump(error);
165 UNREACHABLE(); 164 UNREACHABLE();
166 } 165 }
167 166
168 } // namespace dart 167 } // namespace dart
169 168
OLDNEW
« no previous file with comments | « runtime/vm/regexp_test.cc ('k') | runtime/vm/resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698