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

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

Issue 22825023: Uses an object pool on x64 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 static bool sse4_1_supported_; 315 static bool sse4_1_supported_;
316 #ifdef DEBUG 316 #ifdef DEBUG
317 static bool initialized_; 317 static bool initialized_;
318 #endif 318 #endif
319 }; 319 };
320 320
321 321
322 class Assembler : public ValueObject { 322 class Assembler : public ValueObject {
323 public: 323 public:
324 explicit Assembler(bool use_far_branches = false) 324 explicit Assembler(bool use_far_branches = false);
325 : buffer_(), 325
326 object_pool_(GrowableObjectArray::Handle()),
327 prologue_offset_(-1),
328 comments_() {
329 // This mode is only needed and implemented for MIPS and ARM.
330 ASSERT(!use_far_branches);
331 }
332 ~Assembler() { } 326 ~Assembler() { }
333 327
334 static const bool kNearJump = true; 328 static const bool kNearJump = true;
335 static const bool kFarJump = false; 329 static const bool kFarJump = false;
336 330
337 /* 331 /*
338 * Emit Machine Instructions. 332 * Emit Machine Instructions.
339 */ 333 */
340 void call(Register reg); 334 void call(Register reg);
341 void call(const Address& address); 335 void call(const Address& address);
342 void call(Label* label); 336 void call(Label* label);
343 void call(const ExternalLabel* label); 337 void call(const ExternalLabel* label);
344 338
345 static const intptr_t kCallExternalLabelSize = 13; 339 static const intptr_t kCallExternalLabelSize = 10;
346 340
347 void pushq(Register reg); 341 void pushq(Register reg);
348 void pushq(const Address& address); 342 void pushq(const Address& address);
349 void pushq(const Immediate& imm); 343 void pushq(const Immediate& imm);
350 344
351 void popq(Register reg); 345 void popq(Register reg);
352 void popq(const Address& address); 346 void popq(const Address& address);
353 347
354 void setcc(Condition condition, ByteRegister dst); 348 void setcc(Condition condition, ByteRegister dst);
355 349
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 void CompareRegisters(Register a, Register b); 639 void CompareRegisters(Register a, Register b);
646 640
647 // Issues a move instruction if 'to' is not the same as 'from'. 641 // Issues a move instruction if 'to' is not the same as 'from'.
648 void MoveRegister(Register to, Register from); 642 void MoveRegister(Register to, Register from);
649 void PopRegister(Register r); 643 void PopRegister(Register r);
650 644
651 void AddImmediate(Register reg, const Immediate& imm); 645 void AddImmediate(Register reg, const Immediate& imm);
652 646
653 void Drop(intptr_t stack_elements); 647 void Drop(intptr_t stack_elements);
654 648
655 void LoadObject(Register dst, const Object& object); 649 enum Patchability {
650 kPatchable,
651 kNotPatchable,
652 };
653
654 int32_t AddObject(const Object& obj);
655 int32_t AddExternalLabel(const ExternalLabel* label,
656 Patchability patchable = kPatchable);
657 bool CanLoadFromObjectPool(const Object& object);
Florian Schneider 2013/09/04 09:39:47 I don't see this function used anywhere outside th
zra 2013/09/04 21:00:41 Done.
658 void LoadWordFromPoolOffset(Register dst, Register pp, int32_t offset,
Florian Schneider 2013/09/04 09:39:47 I don't see this function used anywhere outside th
zra 2013/09/04 21:00:41 Done.
659 Patchability patchable);
660 void LoadExternalLabel(const ExternalLabel* label,
Florian Schneider 2013/09/04 09:39:47 I don't see this function used anywhere outside th
zra 2013/09/04 21:00:41 Done.
661 Patchability = kPatchable,
Florian Schneider 2013/09/04 09:39:47 Max one optional argument, and only if absolutely
zra 2013/09/04 21:00:41 Done.
662 Register pp = PP);
663
664 // Load object into register dst. The default patchability is kPatchable
665 // because LoadObject is used for a load of ic-data in arch independent code
666 // that must be patchable.
667 void LoadObject(Register dst, const Object& object,
668 Patchability patchable = kPatchable, Register pp = PP);
Florian Schneider 2013/09/04 09:39:47 Max one optional argument, and only if absolutely
zra 2013/09/04 21:00:41 Done.
669 void JumpPatchable(const ExternalLabel* label, Register pp = PP);
670 void JumpFromPool(const ExternalLabel* label, Register pp = PP);
671 void JumpFromPool(Condition condition, const ExternalLabel* label,
672 Register pp = PP);
673 void CallPatchable(const ExternalLabel* label);
674 void CallFromPool(const ExternalLabel* label);
656 void StoreObject(const Address& dst, const Object& obj); 675 void StoreObject(const Address& dst, const Object& obj);
657 void PushObject(const Object& object); 676 void PushObject(const Object& object);
658 void CompareObject(Register reg, const Object& object); 677 void CompareObject(Register reg, const Object& object);
659 void LoadDoubleConstant(XmmRegister dst, double value); 678 void LoadDoubleConstant(XmmRegister dst, double value);
660 679
661 // Destroys value. 680 // Destroys value.
662 void StoreIntoObject(Register object, // Object we are storing into. 681 void StoreIntoObject(Register object, // Object we are storing into.
663 const Address& dest, // Where we are storing into. 682 const Address& dest, // Where we are storing into.
664 Register value, // Value we are storing. 683 Register value, // Value we are storing.
665 bool can_value_be_smi = true); 684 bool can_value_be_smi = true);
666 685
667 void StoreIntoObjectNoBarrier(Register object, 686 void StoreIntoObjectNoBarrier(Register object,
668 const Address& dest, 687 const Address& dest,
669 Register value); 688 Register value);
670 689
671 void DoubleNegate(XmmRegister d); 690 void DoubleNegate(XmmRegister d);
672 void FloatNegate(XmmRegister f); 691 void FloatNegate(XmmRegister f);
673 692
674 void DoubleAbs(XmmRegister reg); 693 void DoubleAbs(XmmRegister reg);
675 694
676 void LockCmpxchgl(const Address& address, Register reg) { 695 void LockCmpxchgl(const Address& address, Register reg) {
677 lock(); 696 lock();
678 cmpxchgl(address, reg); 697 cmpxchgl(address, reg);
679 } 698 }
680 699
681 void EnterFrame(intptr_t frame_space); 700 void EnterFrame(intptr_t frame_space);
682 void LeaveFrame(); 701 void LeaveFrame(bool restore_pp = false);
Florian Schneider 2013/09/04 09:39:47 This optional argument seems dangerous, too. Try t
zra 2013/09/04 21:00:41 Done.
683 void ReserveAlignedFrameSpace(intptr_t frame_space); 702 void ReserveAlignedFrameSpace(intptr_t frame_space);
684 703
685 // Create a frame for calling into runtime that preserves all volatile 704 // Create a frame for calling into runtime that preserves all volatile
686 // registers. Frame's RSP is guaranteed to be correctly aligned and 705 // registers. Frame's RSP is guaranteed to be correctly aligned and
687 // frame_space bytes are reserved under it. 706 // frame_space bytes are reserved under it.
688 void EnterCallRuntimeFrame(intptr_t frame_space); 707 void EnterCallRuntimeFrame(intptr_t frame_space);
689 void LeaveCallRuntimeFrame(); 708 void LeaveCallRuntimeFrame();
690 709
691 710
692 void CallRuntime(const RuntimeEntry& entry); 711 void CallRuntime(const RuntimeEntry& entry);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 int prologue_offset() const { return prologue_offset_; } 743 int prologue_offset() const { return prologue_offset_; }
725 const ZoneGrowableArray<int>& GetPointerOffsets() const { 744 const ZoneGrowableArray<int>& GetPointerOffsets() const {
726 return buffer_.pointer_offsets(); 745 return buffer_.pointer_offsets();
727 } 746 }
728 const GrowableObjectArray& object_pool() const { return object_pool_; } 747 const GrowableObjectArray& object_pool() const { return object_pool_; }
729 748
730 void FinalizeInstructions(const MemoryRegion& region) { 749 void FinalizeInstructions(const MemoryRegion& region) {
731 buffer_.FinalizeInstructions(region); 750 buffer_.FinalizeInstructions(region);
732 } 751 }
733 752
753 void LoadPoolPointer(Register pp = PP);
754
734 // Set up a Dart frame on entry with a frame pointer and PC information to 755 // Set up a Dart frame on entry with a frame pointer and PC information to
735 // enable easy access to the RawInstruction object of code corresponding 756 // enable easy access to the RawInstruction object of code corresponding
736 // to this frame. 757 // to this frame.
737 // The dart frame layout is as follows: 758 // The dart frame layout is as follows:
738 // .... 759 // ....
739 // ret PC 760 // ret PC
740 // saved RBP <=== RBP 761 // saved RBP <=== RBP
741 // pc (used to derive the RawInstruction Object of the dart code) 762 // pc (used to derive the RawInstruction Object of the dart code)
763 // saved PP
742 // locals space <=== RSP 764 // locals space <=== RSP
743 // ..... 765 // .....
744 // This code sets this up with the sequence: 766 // This code sets this up with the sequence:
745 // pushq rbp 767 // pushq rbp
746 // movq rbp, rsp 768 // movq rbp, rsp
747 // call L 769 // call L
748 // L: <code to adjust saved pc if there is any intrinsification code> 770 // L: <code to adjust saved pc if there is any intrinsification code>
771 // ...
772 // pushq r15
749 // ..... 773 // .....
750 void EnterDartFrame(intptr_t frame_size); 774 void EnterDartFrame(intptr_t frame_size,
775 Register new_pp = PP, Register new_pc = kNoRegister);
Florian Schneider 2013/09/04 09:39:47 Again, two optional arguments is not a good idea,
zra 2013/09/04 21:00:41 Done.
751 776
752 // Set up a Dart frame for a function compiled for on-stack replacement. 777 // Set up a Dart frame for a function compiled for on-stack replacement.
753 // The frame layout is a normal Dart frame, but the frame is partially set 778 // The frame layout is a normal Dart frame, but the frame is partially set
754 // up on entry (it is the frame of the unoptimized code). 779 // up on entry (it is the frame of the unoptimized code).
755 void EnterOsrFrame(intptr_t extra_size); 780 void EnterOsrFrame(intptr_t extra_size,
781 Register new_pp = PP, Register new_pc = kNoRegister);
Florian Schneider 2013/09/04 09:39:47 Again, two optional arguments is not a good idea,
zra 2013/09/04 21:00:41 Done.
756 782
757 // Set up a stub frame so that the stack traversal code can easily identify 783 // Set up a stub frame so that the stack traversal code can easily identify
758 // a stub frame. 784 // a stub frame.
759 // The stub frame layout is as follows: 785 // The stub frame layout is as follows:
760 // .... 786 // ....
761 // ret PC 787 // ret PC
762 // saved RBP 788 // saved RBP
763 // pc (used to derive the RawInstruction Object of the stub) 789 // pc (used to derive the RawInstruction Object of the stub)
764 // ..... 790 // .....
765 // This code sets this up with the sequence: 791 // This code sets this up with the sequence:
766 // pushq rbp 792 // pushq rbp
767 // movq rbp, rsp 793 // movq rbp, rsp
768 // pushq immediate(0) 794 // pushq immediate(0)
769 // ..... 795 // .....
770 void EnterStubFrame(); 796 void EnterStubFrame(bool save_pp = false);
Florian Schneider 2013/09/04 09:39:47 This optional argument seems dangerous, too. Try t
zra 2013/09/04 21:00:41 Done.
771 797
772 // Instruction pattern from entrypoint is used in dart frame prologs 798 // Instruction pattern from entrypoint is used in dart frame prologues
773 // to set up the frame and save a PC which can be used to figure out the 799 // to set up the frame and save a PC which can be used to figure out the
774 // RawInstruction object corresponding to the code running in the frame. 800 // RawInstruction object corresponding to the code running in the frame.
775 // entrypoint: 801 // entrypoint:
776 // pushq rbp (size is 1 byte) 802 // pushq rbp (size is 1 byte)
777 // movq rbp, rsp (size is 3 bytes) 803 // movq rbp, rsp (size is 3 bytes)
778 // call L (size is 5 bytes) 804 // call L (size is 5 bytes)
779 // L: 805 // L:
780 static const intptr_t kEntryPointToPcMarkerOffset = 9; 806 static const intptr_t kEntryPointToPcMarkerOffset = 9;
781 807
782 // Inlined allocation of an instance of class 'cls', code has no runtime 808 // Inlined allocation of an instance of class 'cls', code has no runtime
(...skipping 12 matching lines...) Expand all
795 void Unreachable(const char* message); 821 void Unreachable(const char* message);
796 822
797 static void InitializeMemoryWithBreakpoints(uword data, int length); 823 static void InitializeMemoryWithBreakpoints(uword data, int length);
798 824
799 static const char* RegisterName(Register reg); 825 static const char* RegisterName(Register reg);
800 826
801 static const char* FpuRegisterName(FpuRegister reg); 827 static const char* FpuRegisterName(FpuRegister reg);
802 828
803 private: 829 private:
804 AssemblerBuffer buffer_; 830 AssemblerBuffer buffer_;
805 GrowableObjectArray& object_pool_; // Object pool is not used on x64. 831 GrowableObjectArray& object_pool_; // Objects and patchable jump targets.
806 int prologue_offset_; 832 int prologue_offset_;
807 833
808 class CodeComment : public ZoneAllocated { 834 class CodeComment : public ZoneAllocated {
809 public: 835 public:
810 CodeComment(intptr_t pc_offset, const String& comment) 836 CodeComment(intptr_t pc_offset, const String& comment)
811 : pc_offset_(pc_offset), comment_(comment) { } 837 : pc_offset_(pc_offset), comment_(comment) { }
812 838
813 intptr_t pc_offset() const { return pc_offset_; } 839 intptr_t pc_offset() const { return pc_offset_; }
814 const String& comment() const { return comment_; } 840 const String& comment() const { return comment_; }
815 841
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 963 }
938 964
939 965
940 inline void Assembler::EmitOperandSizeOverride() { 966 inline void Assembler::EmitOperandSizeOverride() {
941 EmitUint8(0x66); 967 EmitUint8(0x66);
942 } 968 }
943 969
944 } // namespace dart 970 } // namespace dart
945 971
946 #endif // VM_ASSEMBLER_X64_H_ 972 #endif // VM_ASSEMBLER_X64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698