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

Side by Side Diff: runtime/vm/assembler_ia32.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: address Srdjan comments 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_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 class DirectCallRelocation : public AssemblerFixup { 21 class DirectCallRelocation : public AssemblerFixup {
20 public: 22 public:
21 void Process(const MemoryRegion& region, int position) { 23 void Process(const MemoryRegion& region, int position) {
22 // Direct calls are relative to the following instruction on x86. 24 // Direct calls are relative to the following instruction on x86.
23 int32_t pointer = region.Load<int32_t>(position); 25 int32_t pointer = region.Load<int32_t>(position);
24 int32_t delta = region.start() + position + sizeof(int32_t); 26 int32_t delta = region.start() + position + sizeof(int32_t);
25 region.Store<int32_t>(position, pointer - delta); 27 region.Store<int32_t>(position, pointer - delta);
26 } 28 }
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 1554
1553 void Assembler::EmitGenericShift(int rm, 1555 void Assembler::EmitGenericShift(int rm,
1554 Register operand, 1556 Register operand,
1555 Register shifter) { 1557 Register shifter) {
1556 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1558 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1557 ASSERT(shifter == ECX); 1559 ASSERT(shifter == ECX);
1558 EmitUint8(0xD3); 1560 EmitUint8(0xD3);
1559 EmitOperand(rm, Operand(operand)); 1561 EmitOperand(rm, Operand(operand));
1560 } 1562 }
1561 1563
1564
1565 void Assembler::Comment(const char* comment) {
1566 if (FLAG_code_comments) {
1567 comments_.Add(new CodeComment(buffer_.GetPosition(),
1568 String::Handle(String::New(comment))));
1569 }
1570 }
1571
1572
1573 const Code::Comments& Assembler::GetCodeComments() const {
1574 Code::Comments& comments = Code::Comments::New(comments_.length());
1575
1576 for (intptr_t i = 0; i < comments_.length(); i++) {
1577 comments.SetPCOffsetAt(i, comments_[i]->pc_offset());
1578 comments.SetCommentAt(i, comments_[i]->comment());
1579 }
1580
1581 return comments;
1582 }
1583
1584
1562 } // namespace dart 1585 } // namespace dart
1563 1586
1564 #endif // defined TARGET_ARCH_IA32 1587 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698