| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Machine instruction Immediates | 178 // Machine instruction Immediates |
| 179 | 179 |
| 180 class Immediate BASE_EMBEDDED { | 180 class Immediate BASE_EMBEDDED { |
| 181 public: | 181 public: |
| 182 inline explicit Immediate(int x); | 182 inline explicit Immediate(int x); |
| 183 inline explicit Immediate(const char* s); | 183 inline explicit Immediate(const char* s); |
| 184 inline explicit Immediate(const ExternalReference& ext); | 184 inline explicit Immediate(const ExternalReference& ext); |
| 185 inline explicit Immediate(Handle<Object> handle); | 185 inline explicit Immediate(Handle<Object> handle); |
| 186 inline explicit Immediate(Smi* value); | 186 inline explicit Immediate(Smi* value); |
| 187 | 187 |
| 188 static Immediate CodeRelativeOffset(Label* label) { |
| 189 return Immediate(label); |
| 190 } |
| 191 |
| 188 bool is_zero() const { return x_ == 0 && rmode_ == RelocInfo::NONE; } | 192 bool is_zero() const { return x_ == 0 && rmode_ == RelocInfo::NONE; } |
| 189 bool is_int8() const { | 193 bool is_int8() const { |
| 190 return -128 <= x_ && x_ < 128 && rmode_ == RelocInfo::NONE; | 194 return -128 <= x_ && x_ < 128 && rmode_ == RelocInfo::NONE; |
| 191 } | 195 } |
| 192 bool is_int16() const { | 196 bool is_int16() const { |
| 193 return -32768 <= x_ && x_ < 32768 && rmode_ == RelocInfo::NONE; | 197 return -32768 <= x_ && x_ < 32768 && rmode_ == RelocInfo::NONE; |
| 194 } | 198 } |
| 195 | 199 |
| 196 private: | 200 private: |
| 201 inline explicit Immediate(Label* value); |
| 202 |
| 197 int x_; | 203 int x_; |
| 198 RelocInfo::Mode rmode_; | 204 RelocInfo::Mode rmode_; |
| 199 | 205 |
| 200 friend class Assembler; | 206 friend class Assembler; |
| 201 }; | 207 }; |
| 202 | 208 |
| 203 | 209 |
| 204 // ----------------------------------------------------------------------------- | 210 // ----------------------------------------------------------------------------- |
| 205 // Machine instruction Operands | 211 // Machine instruction Operands |
| 206 | 212 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 | 730 |
| 725 protected: | 731 protected: |
| 726 void movsd(XMMRegister dst, const Operand& src); | 732 void movsd(XMMRegister dst, const Operand& src); |
| 727 void movsd(const Operand& dst, XMMRegister src); | 733 void movsd(const Operand& dst, XMMRegister src); |
| 728 | 734 |
| 729 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 735 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
| 730 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 736 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
| 731 | 737 |
| 732 | 738 |
| 733 private: | 739 private: |
| 734 // Code buffer: | |
| 735 // The buffer into which code and relocation info are generated. | |
| 736 byte* buffer_; | |
| 737 int buffer_size_; | |
| 738 // True if the assembler owns the buffer, false if buffer is external. | |
| 739 bool own_buffer_; | |
| 740 | |
| 741 // code generation | |
| 742 byte* pc_; // the program counter; moves forward | |
| 743 RelocInfoWriter reloc_info_writer; | |
| 744 | |
| 745 // push-pop elimination | |
| 746 byte* last_pc_; | |
| 747 | |
| 748 // source position information | |
| 749 int last_position_; | |
| 750 int last_statement_position_; | |
| 751 | |
| 752 byte* addr_at(int pos) { return buffer_ + pos; } | 740 byte* addr_at(int pos) { return buffer_ + pos; } |
| 753 byte byte_at(int pos) { return buffer_[pos]; } | 741 byte byte_at(int pos) { return buffer_[pos]; } |
| 754 uint32_t long_at(int pos) { | 742 uint32_t long_at(int pos) { |
| 755 return *reinterpret_cast<uint32_t*>(addr_at(pos)); | 743 return *reinterpret_cast<uint32_t*>(addr_at(pos)); |
| 756 } | 744 } |
| 757 void long_at_put(int pos, uint32_t x) { | 745 void long_at_put(int pos, uint32_t x) { |
| 758 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; | 746 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; |
| 759 } | 747 } |
| 760 | 748 |
| 761 // code emission | 749 // code emission |
| 762 void GrowBuffer(); | 750 void GrowBuffer(); |
| 763 inline void emit(uint32_t x); | 751 inline void emit(uint32_t x); |
| 764 inline void emit(Handle<Object> handle); | 752 inline void emit(Handle<Object> handle); |
| 765 inline void emit(uint32_t x, RelocInfo::Mode rmode); | 753 inline void emit(uint32_t x, RelocInfo::Mode rmode); |
| 766 inline void emit(const Immediate& x); | 754 inline void emit(const Immediate& x); |
| 767 inline void emit_w(const Immediate& x); | 755 inline void emit_w(const Immediate& x); |
| 768 | 756 |
| 757 // Emit the code-object-relative offset of the label's position |
| 758 inline void emit_code_relative_offset(Label* label); |
| 759 |
| 769 // instruction generation | 760 // instruction generation |
| 770 void emit_arith_b(int op1, int op2, Register dst, int imm8); | 761 void emit_arith_b(int op1, int op2, Register dst, int imm8); |
| 771 | 762 |
| 772 // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81) | 763 // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81) |
| 773 // with a given destination expression and an immediate operand. It attempts | 764 // with a given destination expression and an immediate operand. It attempts |
| 774 // to use the shortest encoding possible. | 765 // to use the shortest encoding possible. |
| 775 // sel specifies the /n in the modrm byte (see the Intel PRM). | 766 // sel specifies the /n in the modrm byte (see the Intel PRM). |
| 776 void emit_arith(int sel, Operand dst, const Immediate& x); | 767 void emit_arith(int sel, Operand dst, const Immediate& x); |
| 777 | 768 |
| 778 void emit_operand(Register reg, const Operand& adr); | 769 void emit_operand(Register reg, const Operand& adr); |
| 779 | 770 |
| 780 void emit_farith(int b1, int b2, int i); | 771 void emit_farith(int b1, int b2, int i); |
| 781 | 772 |
| 782 // labels | 773 // labels |
| 783 void print(Label* L); | 774 void print(Label* L); |
| 784 void bind_to(Label* L, int pos); | 775 void bind_to(Label* L, int pos); |
| 785 void link_to(Label* L, Label* appendix); | 776 void link_to(Label* L, Label* appendix); |
| 786 | 777 |
| 787 // displacements | 778 // displacements |
| 788 inline Displacement disp_at(Label* L); | 779 inline Displacement disp_at(Label* L); |
| 789 inline void disp_at_put(Label* L, Displacement disp); | 780 inline void disp_at_put(Label* L, Displacement disp); |
| 790 inline void emit_disp(Label* L, Displacement::Type type); | 781 inline void emit_disp(Label* L, Displacement::Type type); |
| 791 | 782 |
| 792 // record reloc info for current pc_ | 783 // record reloc info for current pc_ |
| 793 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 784 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
| 794 | 785 |
| 795 friend class CodePatcher; | 786 friend class CodePatcher; |
| 796 friend class EnsureSpace; | 787 friend class EnsureSpace; |
| 788 |
| 789 // Code buffer: |
| 790 // The buffer into which code and relocation info are generated. |
| 791 byte* buffer_; |
| 792 int buffer_size_; |
| 793 // True if the assembler owns the buffer, false if buffer is external. |
| 794 bool own_buffer_; |
| 795 |
| 796 // code generation |
| 797 byte* pc_; // the program counter; moves forward |
| 798 RelocInfoWriter reloc_info_writer; |
| 799 |
| 800 // push-pop elimination |
| 801 byte* last_pc_; |
| 802 |
| 803 // source position information |
| 804 int last_position_; |
| 805 int last_statement_position_; |
| 797 }; | 806 }; |
| 798 | 807 |
| 799 | 808 |
| 800 // Helper class that ensures that there is enough space for generating | 809 // Helper class that ensures that there is enough space for generating |
| 801 // instructions and relocation information. The constructor makes | 810 // instructions and relocation information. The constructor makes |
| 802 // sure that there is enough space and (in debug mode) the destructor | 811 // sure that there is enough space and (in debug mode) the destructor |
| 803 // checks that we did not generate too much. | 812 // checks that we did not generate too much. |
| 804 class EnsureSpace BASE_EMBEDDED { | 813 class EnsureSpace BASE_EMBEDDED { |
| 805 public: | 814 public: |
| 806 explicit EnsureSpace(Assembler* assembler) : assembler_(assembler) { | 815 explicit EnsureSpace(Assembler* assembler) : assembler_(assembler) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 820 private: | 829 private: |
| 821 Assembler* assembler_; | 830 Assembler* assembler_; |
| 822 #ifdef DEBUG | 831 #ifdef DEBUG |
| 823 int space_before_; | 832 int space_before_; |
| 824 #endif | 833 #endif |
| 825 }; | 834 }; |
| 826 | 835 |
| 827 } } // namespace v8::internal | 836 } } // namespace v8::internal |
| 828 | 837 |
| 829 #endif // V8_ASSEMBLER_IA32_H_ | 838 #endif // V8_ASSEMBLER_IA32_H_ |
| OLD | NEW |