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

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

Issue 188963003: Change --code-comments default to true. Code comments activated only if disassembly is activated. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/assembler.h" 5 #include "vm/assembler.h"
6 6
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/memory_region.h" 10 #include "vm/memory_region.h"
11 #include "vm/os.h" 11 #include "vm/os.h"
12 #include "vm/zone.h" 12 #include "vm/zone.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DEFINE_FLAG(bool, code_comments, false, 16 DEFINE_FLAG(bool, code_comments, true,
17 "Include comments into code and disassembly"); 17 "Include comments into code and disassembly");
18 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) 18 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS)
19 DEFINE_FLAG(bool, use_far_branches, false, 19 DEFINE_FLAG(bool, use_far_branches, false,
20 "Enable far branches for ARM and MIPS"); 20 "Enable far branches for ARM and MIPS");
21 #endif 21 #endif
22 22
23 DECLARE_FLAG(bool, disassemble);
24 DECLARE_FLAG(bool, disassemble_optimized);
25
23 static uword NewContents(intptr_t capacity) { 26 static uword NewContents(intptr_t capacity) {
24 Zone* zone = Isolate::Current()->current_zone(); 27 Zone* zone = Isolate::Current()->current_zone();
25 uword result = zone->AllocUnsafe(capacity); 28 uword result = zone->AllocUnsafe(capacity);
26 #if defined(DEBUG) 29 #if defined(DEBUG)
27 // Initialize the buffer with kBreakPointInstruction to force a break 30 // Initialize the buffer with kBreakPointInstruction to force a break
28 // point if we ever execute an uninitialized part of the code buffer. 31 // point if we ever execute an uninitialized part of the code buffer.
29 Assembler::InitializeMemoryWithBreakpoints(result, capacity); 32 Assembler::InitializeMemoryWithBreakpoints(result, capacity);
30 #endif 33 #endif
31 return result; 34 return result;
32 } 35 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void Assembler::Unreachable(const char* message) { 203 void Assembler::Unreachable(const char* message) {
201 const char* format = "Unreachable: %s"; 204 const char* format = "Unreachable: %s";
202 const intptr_t len = OS::SNPrint(NULL, 0, format, message); 205 const intptr_t len = OS::SNPrint(NULL, 0, format, message);
203 char* buffer = reinterpret_cast<char*>(malloc(len + 1)); 206 char* buffer = reinterpret_cast<char*>(malloc(len + 1));
204 OS::SNPrint(buffer, len + 1, format, message); 207 OS::SNPrint(buffer, len + 1, format, message);
205 Stop(buffer); 208 Stop(buffer);
206 } 209 }
207 210
208 211
209 void Assembler::Comment(const char* format, ...) { 212 void Assembler::Comment(const char* format, ...) {
210 if (FLAG_code_comments) { 213 if (FLAG_code_comments && (FLAG_disassemble || FLAG_disassemble_optimized)) {
211 char buffer[1024]; 214 char buffer[1024];
212 215
213 va_list args; 216 va_list args;
214 va_start(args, format); 217 va_start(args, format);
215 OS::VSNPrint(buffer, sizeof(buffer), format, args); 218 OS::VSNPrint(buffer, sizeof(buffer), format, args);
216 va_end(args); 219 va_end(args);
217 220
218 comments_.Add(new CodeComment(buffer_.GetPosition(), 221 comments_.Add(new CodeComment(buffer_.GetPosition(),
219 String::Handle(String::New(buffer)))); 222 String::Handle(String::New(buffer))));
220 } 223 }
221 } 224 }
222 225
223 226
224 const Code::Comments& Assembler::GetCodeComments() const { 227 const Code::Comments& Assembler::GetCodeComments() const {
225 Code::Comments& comments = Code::Comments::New(comments_.length()); 228 Code::Comments& comments = Code::Comments::New(comments_.length());
226 229
227 for (intptr_t i = 0; i < comments_.length(); i++) { 230 for (intptr_t i = 0; i < comments_.length(); i++) {
228 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); 231 comments.SetPCOffsetAt(i, comments_[i]->pc_offset());
229 comments.SetCommentAt(i, comments_[i]->comment()); 232 comments.SetCommentAt(i, comments_[i]->comment());
230 } 233 }
231 234
232 return comments; 235 return comments;
233 } 236 }
234 237
235 } // namespace dart 238 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698