OLD | NEW |
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_IA32_H_ | 5 #ifndef VM_ASSEMBLER_IA32_H_ |
6 #define VM_ASSEMBLER_IA32_H_ | 6 #define VM_ASSEMBLER_IA32_H_ |
7 | 7 |
8 #ifndef VM_ASSEMBLER_H_ | 8 #ifndef VM_ASSEMBLER_H_ |
9 #error Do not include assembler_ia32.h directly; use assembler.h instead. | 9 #error Do not include assembler_ia32.h directly; use assembler.h instead. |
10 #endif | 10 #endif |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 #endif | 304 #endif |
305 }; | 305 }; |
306 | 306 |
307 | 307 |
308 class Assembler : public ValueObject { | 308 class Assembler : public ValueObject { |
309 public: | 309 public: |
310 explicit Assembler(bool use_far_branches = false) | 310 explicit Assembler(bool use_far_branches = false) |
311 : buffer_(), | 311 : buffer_(), |
312 object_pool_(GrowableObjectArray::Handle()), | 312 object_pool_(GrowableObjectArray::Handle()), |
313 prologue_offset_(-1), | 313 prologue_offset_(-1), |
314 comments_(), | 314 jit_cookie_(0), |
315 jit_cookie_(1017109444) { | 315 comments_() { |
316 // This mode is only needed and implemented for MIPS and ARM. | 316 // This mode is only needed and implemented for MIPS and ARM. |
317 ASSERT(!use_far_branches); | 317 ASSERT(!use_far_branches); |
318 } | 318 } |
319 ~Assembler() { } | 319 ~Assembler() { } |
320 | 320 |
321 static const bool kNearJump = true; | 321 static const bool kNearJump = true; |
322 static const bool kFarJump = false; | 322 static const bool kFarJump = false; |
323 | 323 |
324 /* | 324 /* |
325 * Emit Machine Instructions. | 325 * Emit Machine Instructions. |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 static bool IsSafe(const Object& object) { | 791 static bool IsSafe(const Object& object) { |
792 return !object.IsSmi() || | 792 return !object.IsSmi() || |
793 Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw())); | 793 Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw())); |
794 } | 794 } |
795 static bool IsSafeSmi(const Object& object) { | 795 static bool IsSafeSmi(const Object& object) { |
796 return object.IsSmi() && | 796 return object.IsSmi() && |
797 Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw())); | 797 Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw())); |
798 } | 798 } |
799 | 799 |
800 private: | 800 private: |
801 AssemblerBuffer buffer_; | |
802 GrowableObjectArray& object_pool_; // Object pool is not used on ia32. | |
803 intptr_t prologue_offset_; | |
804 | |
805 class CodeComment : public ZoneAllocated { | 801 class CodeComment : public ZoneAllocated { |
806 public: | 802 public: |
807 CodeComment(intptr_t pc_offset, const String& comment) | 803 CodeComment(intptr_t pc_offset, const String& comment) |
808 : pc_offset_(pc_offset), comment_(comment) { } | 804 : pc_offset_(pc_offset), comment_(comment) { } |
809 | 805 |
810 intptr_t pc_offset() const { return pc_offset_; } | 806 intptr_t pc_offset() const { return pc_offset_; } |
811 const String& comment() const { return comment_; } | 807 const String& comment() const { return comment_; } |
812 | 808 |
813 private: | 809 private: |
814 intptr_t pc_offset_; | 810 intptr_t pc_offset_; |
815 const String& comment_; | 811 const String& comment_; |
816 | 812 |
817 DISALLOW_COPY_AND_ASSIGN(CodeComment); | 813 DISALLOW_COPY_AND_ASSIGN(CodeComment); |
818 }; | 814 }; |
819 | 815 |
820 GrowableArray<CodeComment*> comments_; | |
821 | |
822 int32_t jit_cookie_; | |
823 | 816 |
824 inline void EmitUint8(uint8_t value); | 817 inline void EmitUint8(uint8_t value); |
825 inline void EmitInt32(int32_t value); | 818 inline void EmitInt32(int32_t value); |
826 inline void EmitRegisterOperand(int rm, int reg); | 819 inline void EmitRegisterOperand(int rm, int reg); |
827 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg); | 820 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg); |
828 inline void EmitFixup(AssemblerFixup* fixup); | 821 inline void EmitFixup(AssemblerFixup* fixup); |
829 inline void EmitOperandSizeOverride(); | 822 inline void EmitOperandSizeOverride(); |
830 | 823 |
831 void EmitOperand(int rm, const Operand& operand); | 824 void EmitOperand(int rm, const Operand& operand); |
832 void EmitImmediate(const Immediate& imm); | 825 void EmitImmediate(const Immediate& imm); |
833 void EmitComplex(int rm, const Operand& operand, const Immediate& immediate); | 826 void EmitComplex(int rm, const Operand& operand, const Immediate& immediate); |
834 void EmitLabel(Label* label, intptr_t instruction_size); | 827 void EmitLabel(Label* label, intptr_t instruction_size); |
835 void EmitLabelLink(Label* label); | 828 void EmitLabelLink(Label* label); |
836 void EmitNearLabelLink(Label* label); | 829 void EmitNearLabelLink(Label* label); |
837 | 830 |
838 void EmitGenericShift(int rm, Register reg, const Immediate& imm); | 831 void EmitGenericShift(int rm, Register reg, const Immediate& imm); |
839 void EmitGenericShift(int rm, const Operand& operand, Register shifter); | 832 void EmitGenericShift(int rm, const Operand& operand, Register shifter); |
840 | 833 |
841 void StoreIntoObjectFilter(Register object, Register value, Label* no_update); | 834 void StoreIntoObjectFilter(Register object, Register value, Label* no_update); |
842 | 835 |
843 // Shorter filtering sequence that assumes that value is not a smi. | 836 // Shorter filtering sequence that assumes that value is not a smi. |
844 void StoreIntoObjectFilterNoSmi(Register object, | 837 void StoreIntoObjectFilterNoSmi(Register object, |
845 Register value, | 838 Register value, |
846 Label* no_update); | 839 Label* no_update); |
847 | 840 |
| 841 int32_t jit_cookie(); |
| 842 |
| 843 AssemblerBuffer buffer_; |
| 844 GrowableObjectArray& object_pool_; // Object pool is not used on ia32. |
| 845 intptr_t prologue_offset_; |
| 846 int32_t jit_cookie_; |
| 847 GrowableArray<CodeComment*> comments_; |
| 848 |
848 DISALLOW_ALLOCATION(); | 849 DISALLOW_ALLOCATION(); |
849 DISALLOW_COPY_AND_ASSIGN(Assembler); | 850 DISALLOW_COPY_AND_ASSIGN(Assembler); |
850 }; | 851 }; |
851 | 852 |
852 | 853 |
853 inline void Assembler::EmitUint8(uint8_t value) { | 854 inline void Assembler::EmitUint8(uint8_t value) { |
854 buffer_.Emit<uint8_t>(value); | 855 buffer_.Emit<uint8_t>(value); |
855 } | 856 } |
856 | 857 |
857 | 858 |
(...skipping 18 matching lines...) Expand all Loading... |
876 } | 877 } |
877 | 878 |
878 | 879 |
879 inline void Assembler::EmitOperandSizeOverride() { | 880 inline void Assembler::EmitOperandSizeOverride() { |
880 EmitUint8(0x66); | 881 EmitUint8(0x66); |
881 } | 882 } |
882 | 883 |
883 } // namespace dart | 884 } // namespace dart |
884 | 885 |
885 #endif // VM_ASSEMBLER_IA32_H_ | 886 #endif // VM_ASSEMBLER_IA32_H_ |
OLD | NEW |