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

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

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) 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 #ifndef VM_ASSEMBLER_X64_H_ 5 #ifndef VM_ASSEMBLER_X64_H_
6 #define VM_ASSEMBLER_X64_H_ 6 #define VM_ASSEMBLER_X64_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_x64.h directly; use assembler.h instead. 9 #error Do not include assembler_x64.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 int unresolved_; 289 int unresolved_;
290 int unresolved_near_positions_[kMaxUnresolvedBranches]; 290 int unresolved_near_positions_[kMaxUnresolvedBranches];
291 291
292 friend class Assembler; 292 friend class Assembler;
293 DISALLOW_COPY_AND_ASSIGN(Label); 293 DISALLOW_COPY_AND_ASSIGN(Label);
294 }; 294 };
295 295
296 296
297 class Assembler : public ValueObject { 297 class Assembler : public ValueObject {
298 public: 298 public:
299 Assembler() : buffer_(), prolog_offset_(-1) { } 299 Assembler() : buffer_(), prolog_offset_(-1), comments_() { }
300 ~Assembler() { } 300 ~Assembler() { }
301 301
302 static const bool kNearJump = true; 302 static const bool kNearJump = true;
303 static const bool kFarJump = false; 303 static const bool kFarJump = false;
304 304
305 /* 305 /*
306 * Emit Machine Instructions. 306 * Emit Machine Instructions.
307 */ 307 */
308 void call(Register reg); 308 void call(Register reg);
309 void call(const Address& address); 309 void call(const Address& address);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 523 }
524 524
525 void SmiUntag(Register reg) { 525 void SmiUntag(Register reg) {
526 sarq(reg, Immediate(kSmiTagSize)); 526 sarq(reg, Immediate(kSmiTagSize));
527 } 527 }
528 528
529 int PreferredLoopAlignment() { return 16; } 529 int PreferredLoopAlignment() { return 16; }
530 void Align(int alignment, int offset); 530 void Align(int alignment, int offset);
531 void Bind(Label* label); 531 void Bind(Label* label);
532 532
533 void Comment(const char* format, ...);
534 const Code::Comments& GetCodeComments() const;
535
533 int CodeSize() const { return buffer_.Size(); } 536 int CodeSize() const { return buffer_.Size(); }
534 int prolog_offset() const { return prolog_offset_; } 537 int prolog_offset() const { return prolog_offset_; }
535 const ZoneGrowableArray<int>& GetPointerOffsets() const { 538 const ZoneGrowableArray<int>& GetPointerOffsets() const {
536 return buffer_.pointer_offsets(); 539 return buffer_.pointer_offsets();
537 } 540 }
538 541
539 void FinalizeInstructions(const MemoryRegion& region) { 542 void FinalizeInstructions(const MemoryRegion& region) {
540 buffer_.FinalizeInstructions(region); 543 buffer_.FinalizeInstructions(region);
541 } 544 }
542 545
543 // Debugging and bringup support. 546 // Debugging and bringup support.
544 void Stop(const char* message); 547 void Stop(const char* message);
545 void Unimplemented(const char* message); 548 void Unimplemented(const char* message);
546 void Untested(const char* message); 549 void Untested(const char* message);
547 void Unreachable(const char* message); 550 void Unreachable(const char* message);
548 551
549 static void InitializeMemoryWithBreakpoints(uword data, int length); 552 static void InitializeMemoryWithBreakpoints(uword data, int length);
550 553
551 private: 554 private:
552 AssemblerBuffer buffer_; 555 AssemblerBuffer buffer_;
553 int prolog_offset_; 556 int prolog_offset_;
554 557
558 class CodeComment : public ZoneAllocated {
559 public:
560 CodeComment(intptr_t pc_offset, const String& comment)
561 : pc_offset_(pc_offset), comment_(comment) { }
562
563 intptr_t pc_offset() const { return pc_offset_; }
564 const String& comment() const { return comment_; }
565
566 private:
567 intptr_t pc_offset_;
568 const String& comment_;
569
570 DISALLOW_COPY_AND_ASSIGN(CodeComment);
571 };
572
573 GrowableArray<CodeComment*> comments_;
574
555 inline void EmitUint8(uint8_t value); 575 inline void EmitUint8(uint8_t value);
556 inline void EmitInt32(int32_t value); 576 inline void EmitInt32(int32_t value);
557 inline void EmitInt64(int64_t value); 577 inline void EmitInt64(int64_t value);
558 578
559 inline void EmitRegisterREX(Register reg, uint8_t rex); 579 inline void EmitRegisterREX(Register reg, uint8_t rex);
560 inline void EmitRegisterOperand(int rm, int reg); 580 inline void EmitRegisterOperand(int rm, int reg);
561 inline void EmitOperandREX(int rm, const Operand& operand, uint8_t rex); 581 inline void EmitOperandREX(int rm, const Operand& operand, uint8_t rex);
562 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg); 582 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg);
563 inline void EmitFixup(AssemblerFixup* fixup); 583 inline void EmitFixup(AssemblerFixup* fixup);
564 inline void EmitOperandSizeOverride(); 584 inline void EmitOperandSizeOverride();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 633 }
614 634
615 635
616 inline void Assembler::EmitOperandSizeOverride() { 636 inline void Assembler::EmitOperandSizeOverride() {
617 EmitUint8(0x66); 637 EmitUint8(0x66);
618 } 638 }
619 639
620 } // namespace dart 640 } // namespace dart
621 641
622 #endif // VM_ASSEMBLER_X64_H_ 642 #endif // VM_ASSEMBLER_X64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698