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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 static const int kNumAllocatableRegisters = 6; | 68 static const int kNumAllocatableRegisters = 6; |
69 static const int kNumRegisters = 8; | 69 static const int kNumRegisters = 8; |
70 | 70 |
71 static inline const char* AllocationIndexToString(int index); | 71 static inline const char* AllocationIndexToString(int index); |
72 | 72 |
73 static inline int ToAllocationIndex(Register reg); | 73 static inline int ToAllocationIndex(Register reg); |
74 | 74 |
75 static inline Register FromAllocationIndex(int index); | 75 static inline Register FromAllocationIndex(int index); |
76 | 76 |
77 static Register from_code(int code) { | 77 static Register from_code(int code) { |
| 78 ASSERT(code >= 0); |
| 79 ASSERT(code < kNumRegisters); |
78 Register r = { code }; | 80 Register r = { code }; |
79 return r; | 81 return r; |
80 } | 82 } |
81 bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } | 83 bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } |
82 bool is(Register reg) const { return code_ == reg.code_; } | 84 bool is(Register reg) const { return code_ == reg.code_; } |
83 // eax, ebx, ecx and edx are byte registers, the rest are not. | 85 // eax, ebx, ecx and edx are byte registers, the rest are not. |
84 bool is_byte_register() const { return code_ <= 3; } | 86 bool is_byte_register() const { return code_ <= 3; } |
85 int code() const { | 87 int code() const { |
86 ASSERT(is_valid()); | 88 ASSERT(is_valid()); |
87 return code_; | 89 return code_; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 342 } |
341 | 343 |
342 static Operand Cell(Handle<JSGlobalPropertyCell> cell) { | 344 static Operand Cell(Handle<JSGlobalPropertyCell> cell) { |
343 return Operand(reinterpret_cast<int32_t>(cell.location()), | 345 return Operand(reinterpret_cast<int32_t>(cell.location()), |
344 RelocInfo::GLOBAL_PROPERTY_CELL); | 346 RelocInfo::GLOBAL_PROPERTY_CELL); |
345 } | 347 } |
346 | 348 |
347 // Returns true if this Operand is a wrapper for the specified register. | 349 // Returns true if this Operand is a wrapper for the specified register. |
348 bool is_reg(Register reg) const; | 350 bool is_reg(Register reg) const; |
349 | 351 |
| 352 // Returns true if this Operand is a wrapper for one register. |
| 353 bool is_reg_only() const; |
| 354 |
| 355 // Asserts that this Operand is a wrapper for one register and returns the |
| 356 // register. |
| 357 Register reg() const; |
| 358 |
350 private: | 359 private: |
351 byte buf_[6]; | 360 byte buf_[6]; |
352 // The number of bytes in buf_. | 361 // The number of bytes in buf_. |
353 unsigned int len_; | 362 unsigned int len_; |
354 // Only valid if len_ > 4. | 363 // Only valid if len_ > 4. |
355 RelocInfo::Mode rmode_; | 364 RelocInfo::Mode rmode_; |
356 | 365 |
357 // Set the ModRM byte without an encoded 'reg' register. The | 366 // Set the ModRM byte without an encoded 'reg' register. The |
358 // register is encoded later as part of the emit_operand operation. | 367 // register is encoded later as part of the emit_operand operation. |
359 inline void set_modrm(int mod, Register rm); | 368 inline void set_modrm(int mod, Register rm); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 void stos(); | 718 void stos(); |
710 | 719 |
711 // Exchange two registers | 720 // Exchange two registers |
712 void xchg(Register dst, Register src); | 721 void xchg(Register dst, Register src); |
713 | 722 |
714 // Arithmetics | 723 // Arithmetics |
715 void adc(Register dst, int32_t imm32); | 724 void adc(Register dst, int32_t imm32); |
716 void adc(Register dst, const Operand& src); | 725 void adc(Register dst, const Operand& src); |
717 | 726 |
718 void add(Register dst, const Operand& src); | 727 void add(Register dst, const Operand& src); |
| 728 void add(const Operand& dst, Register src); |
719 void add(const Operand& dst, const Immediate& x); | 729 void add(const Operand& dst, const Immediate& x); |
720 | 730 |
721 void and_(Register dst, int32_t imm32); | 731 void and_(Register dst, int32_t imm32); |
722 void and_(Register dst, const Immediate& x); | 732 void and_(Register dst, const Immediate& x); |
723 void and_(Register dst, const Operand& src); | 733 void and_(Register dst, const Operand& src); |
724 void and_(const Operand& src, Register dst); | 734 void and_(const Operand& src, Register dst); |
725 void and_(const Operand& dst, const Immediate& x); | 735 void and_(const Operand& dst, const Immediate& x); |
726 | 736 |
727 void cmpb(const Operand& op, int8_t imm8); | 737 void cmpb(const Operand& op, int8_t imm8); |
728 void cmpb(Register src, const Operand& dst); | 738 void cmpb(Register src, const Operand& dst); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 void shld(Register dst, const Operand& src); | 789 void shld(Register dst, const Operand& src); |
780 | 790 |
781 void shl(Register dst, uint8_t imm8); | 791 void shl(Register dst, uint8_t imm8); |
782 void shl_cl(Register dst); | 792 void shl_cl(Register dst); |
783 | 793 |
784 void shrd(Register dst, const Operand& src); | 794 void shrd(Register dst, const Operand& src); |
785 | 795 |
786 void shr(Register dst, uint8_t imm8); | 796 void shr(Register dst, uint8_t imm8); |
787 void shr_cl(Register dst); | 797 void shr_cl(Register dst); |
788 | 798 |
789 void subb(const Operand& dst, int8_t imm8); | |
790 void subb(Register dst, const Operand& src); | |
791 void sub(const Operand& dst, const Immediate& x); | 799 void sub(const Operand& dst, const Immediate& x); |
792 void sub(Register dst, const Operand& src); | 800 void sub(Register dst, const Operand& src); |
793 void sub(const Operand& dst, Register src); | 801 void sub(const Operand& dst, Register src); |
794 | 802 |
795 void test(Register reg, const Immediate& imm); | 803 void test(Register reg, const Immediate& imm); |
796 void test(Register reg, const Operand& op); | 804 void test(Register reg, const Operand& op); |
797 void test_b(Register reg, const Operand& op); | 805 void test_b(Register reg, const Operand& op); |
798 void test(const Operand& op, const Immediate& imm); | 806 void test(const Operand& op, const Immediate& imm); |
799 void test_b(const Operand& op, uint8_t imm8); | 807 void test_b(const Operand& op, uint8_t imm8); |
800 | 808 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 1046 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
1039 | 1047 |
1040 int relocation_writer_size() { | 1048 int relocation_writer_size() { |
1041 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 1049 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
1042 } | 1050 } |
1043 | 1051 |
1044 // Avoid overflows for displacements etc. | 1052 // Avoid overflows for displacements etc. |
1045 static const int kMaximalBufferSize = 512*MB; | 1053 static const int kMaximalBufferSize = 512*MB; |
1046 static const int kMinimalBufferSize = 4*KB; | 1054 static const int kMinimalBufferSize = 4*KB; |
1047 | 1055 |
| 1056 byte byte_at(int pos) { return buffer_[pos]; } |
| 1057 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
| 1058 |
1048 protected: | 1059 protected: |
1049 bool emit_debug_code() const { return emit_debug_code_; } | 1060 bool emit_debug_code() const { return emit_debug_code_; } |
1050 | 1061 |
1051 void movsd(XMMRegister dst, const Operand& src); | 1062 void movsd(XMMRegister dst, const Operand& src); |
1052 void movsd(const Operand& dst, XMMRegister src); | 1063 void movsd(const Operand& dst, XMMRegister src); |
1053 | 1064 |
1054 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 1065 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
1055 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 1066 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
1056 void emit_sse_operand(Register dst, XMMRegister src); | 1067 void emit_sse_operand(Register dst, XMMRegister src); |
1057 | 1068 |
1058 byte* addr_at(int pos) { return buffer_ + pos; } | 1069 byte* addr_at(int pos) { return buffer_ + pos; } |
1059 | 1070 |
| 1071 |
1060 private: | 1072 private: |
1061 byte byte_at(int pos) { return buffer_[pos]; } | |
1062 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | |
1063 uint32_t long_at(int pos) { | 1073 uint32_t long_at(int pos) { |
1064 return *reinterpret_cast<uint32_t*>(addr_at(pos)); | 1074 return *reinterpret_cast<uint32_t*>(addr_at(pos)); |
1065 } | 1075 } |
1066 void long_at_put(int pos, uint32_t x) { | 1076 void long_at_put(int pos, uint32_t x) { |
1067 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; | 1077 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; |
1068 } | 1078 } |
1069 | 1079 |
1070 // code emission | 1080 // code emission |
1071 void GrowBuffer(); | 1081 void GrowBuffer(); |
1072 inline void emit(uint32_t x); | 1082 inline void emit(uint32_t x); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 private: | 1161 private: |
1152 Assembler* assembler_; | 1162 Assembler* assembler_; |
1153 #ifdef DEBUG | 1163 #ifdef DEBUG |
1154 int space_before_; | 1164 int space_before_; |
1155 #endif | 1165 #endif |
1156 }; | 1166 }; |
1157 | 1167 |
1158 } } // namespace v8::internal | 1168 } } // namespace v8::internal |
1159 | 1169 |
1160 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1170 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |