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

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

Issue 10407019: Extend assembler with ability to produce comments for the generated code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.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/runtime_entry.h" 11 #include "vm/runtime_entry.h"
12 #include "vm/stub_code.h" 12 #include "vm/stub_code.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); 16 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message.");
17 DEFINE_FLAG(bool, code_comments, false, "Include comments into disassembly");
17 18
18 19
19 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { 20 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) {
20 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); 21 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length);
21 } 22 }
22 23
23 24
24 void Assembler::call(Register reg) { 25 void Assembler::call(Register reg) {
25 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 26 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
26 Operand operand(reg); 27 Operand operand(reg);
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 ASSERT(shifter == RCX); 1510 ASSERT(shifter == RCX);
1510 if (wide) { 1511 if (wide) {
1511 EmitRegisterREX(operand, REX_W); 1512 EmitRegisterREX(operand, REX_W);
1512 } else { 1513 } else {
1513 EmitRegisterREX(operand, REX_NONE); 1514 EmitRegisterREX(operand, REX_NONE);
1514 } 1515 }
1515 EmitUint8(0xD3); 1516 EmitUint8(0xD3);
1516 EmitOperand(rm, Operand(operand)); 1517 EmitOperand(rm, Operand(operand));
1517 } 1518 }
1518 1519
1520
1521 void Assembler::Comment(const char* format, ...) {
1522 if (FLAG_code_comments) {
1523 char buffer[1024];
1524
1525 va_list args;
1526 va_start(args, format);
1527 OS::VSNPrint(buffer, sizeof(buffer), format, args);
1528 va_end(args);
1529
1530 comments_.Add(new CodeComment(buffer_.GetPosition(),
1531 String::Handle(String::New(buffer))));
1532 }
1533 }
1534
1535
1536 CodeComments Assembler::GetComments() {
1537 CodeComments comments = CodeComments::New(comments_.length());
1538
1539 for (int i = 0; i < comments_.length(); i++) {
1540 comments.SetPCAt(i, comments_[i]->pc());
1541 comments.SetCommentAt(i, comments_[i]->comment());
1542 }
1543
1544 return comments;
1545 }
1546
1547
1519 } // namespace dart 1548 } // namespace dart
1520 1549
1521 #endif // defined TARGET_ARCH_X64 1550 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698