| OLD | NEW |
| 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, |
| 18 "Include comments into code and disassembly"); |
| 17 | 19 |
| 18 | 20 |
| 19 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { | 21 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { |
| 20 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); | 22 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); |
| 21 } | 23 } |
| 22 | 24 |
| 23 | 25 |
| 24 void Assembler::call(Register reg) { | 26 void Assembler::call(Register reg) { |
| 25 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 27 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 26 Operand operand(reg); | 28 Operand operand(reg); |
| (...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 ASSERT(shifter == RCX); | 1511 ASSERT(shifter == RCX); |
| 1510 if (wide) { | 1512 if (wide) { |
| 1511 EmitRegisterREX(operand, REX_W); | 1513 EmitRegisterREX(operand, REX_W); |
| 1512 } else { | 1514 } else { |
| 1513 EmitRegisterREX(operand, REX_NONE); | 1515 EmitRegisterREX(operand, REX_NONE); |
| 1514 } | 1516 } |
| 1515 EmitUint8(0xD3); | 1517 EmitUint8(0xD3); |
| 1516 EmitOperand(rm, Operand(operand)); | 1518 EmitOperand(rm, Operand(operand)); |
| 1517 } | 1519 } |
| 1518 | 1520 |
| 1521 |
| 1522 void Assembler::Comment(const char* format, ...) { |
| 1523 if (FLAG_code_comments) { |
| 1524 char buffer[1024]; |
| 1525 |
| 1526 va_list args; |
| 1527 va_start(args, format); |
| 1528 OS::VSNPrint(buffer, sizeof(buffer), format, args); |
| 1529 va_end(args); |
| 1530 |
| 1531 comments_.Add(new CodeComment(buffer_.GetPosition(), |
| 1532 String::Handle(String::New(buffer)))); |
| 1533 } |
| 1534 } |
| 1535 |
| 1536 |
| 1537 const Code::Comments& Assembler::GetCodeComments() const { |
| 1538 Code::Comments& comments = Code::Comments::New(comments_.length()); |
| 1539 |
| 1540 for (intptr_t i = 0; i < comments_.length(); i++) { |
| 1541 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); |
| 1542 comments.SetCommentAt(i, comments_[i]->comment()); |
| 1543 } |
| 1544 |
| 1545 return comments; |
| 1546 } |
| 1547 |
| 1548 |
| 1519 } // namespace dart | 1549 } // namespace dart |
| 1520 | 1550 |
| 1521 #endif // defined TARGET_ARCH_X64 | 1551 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |