| 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 const XMMRegister xmm3 = { 3 }; | 178 const XMMRegister xmm3 = { 3 }; |
| 179 const XMMRegister xmm4 = { 4 }; | 179 const XMMRegister xmm4 = { 4 }; |
| 180 const XMMRegister xmm5 = { 5 }; | 180 const XMMRegister xmm5 = { 5 }; |
| 181 const XMMRegister xmm6 = { 6 }; | 181 const XMMRegister xmm6 = { 6 }; |
| 182 const XMMRegister xmm7 = { 7 }; | 182 const XMMRegister xmm7 = { 7 }; |
| 183 | 183 |
| 184 | 184 |
| 185 typedef XMMRegister DoubleRegister; | 185 typedef XMMRegister DoubleRegister; |
| 186 | 186 |
| 187 | 187 |
| 188 // Index of register used in pusha/popa. | |
| 189 // Order of pushed registers: EAX, ECX, EDX, EBX, ESP, EBP, ESI, and EDI | |
| 190 inline int EspIndexForPushAll(Register reg) { | |
| 191 return Register::kNumRegisters - 1 - reg.code(); | |
| 192 } | |
| 193 | |
| 194 | |
| 195 enum Condition { | 188 enum Condition { |
| 196 // any value < 0 is considered no_condition | 189 // any value < 0 is considered no_condition |
| 197 no_condition = -1, | 190 no_condition = -1, |
| 198 | 191 |
| 199 overflow = 0, | 192 overflow = 0, |
| 200 no_overflow = 1, | 193 no_overflow = 1, |
| 201 below = 2, | 194 below = 2, |
| 202 above_equal = 3, | 195 above_equal = 3, |
| 203 equal = 4, | 196 equal = 4, |
| 204 not_equal = 5, | 197 not_equal = 5, |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // buffer, and buffer_size determines the initial buffer size. The buffer is | 517 // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 525 // owned by the assembler and deallocated upon destruction of the assembler. | 518 // owned by the assembler and deallocated upon destruction of the assembler. |
| 526 // | 519 // |
| 527 // If the provided buffer is not NULL, the assembler uses the provided buffer | 520 // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 528 // for code generation and assumes its size to be buffer_size. If the buffer | 521 // for code generation and assumes its size to be buffer_size. If the buffer |
| 529 // is too small, a fatal error occurs. No deallocation of the buffer is done | 522 // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 530 // upon destruction of the assembler. | 523 // upon destruction of the assembler. |
| 531 Assembler(void* buffer, int buffer_size); | 524 Assembler(void* buffer, int buffer_size); |
| 532 ~Assembler(); | 525 ~Assembler(); |
| 533 | 526 |
| 527 // Overrides the default provided by FLAG_debug_code. |
| 528 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } |
| 529 |
| 534 // GetCode emits any pending (non-emitted) code and fills the descriptor | 530 // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 535 // desc. GetCode() is idempotent; it returns the same result if no other | 531 // desc. GetCode() is idempotent; it returns the same result if no other |
| 536 // Assembler functions are invoked in between GetCode() calls. | 532 // Assembler functions are invoked in between GetCode() calls. |
| 537 void GetCode(CodeDesc* desc); | 533 void GetCode(CodeDesc* desc); |
| 538 | 534 |
| 539 // Read/Modify the code target in the branch/call instruction at pc. | 535 // Read/Modify the code target in the branch/call instruction at pc. |
| 540 inline static Address target_address_at(Address pc); | 536 inline static Address target_address_at(Address pc); |
| 541 inline static void set_target_address_at(Address pc, Address target); | 537 inline static void set_target_address_at(Address pc, Address target); |
| 542 | 538 |
| 543 // This sets the branch destination (which is in the instruction on x86). | 539 // This sets the branch destination (which is in the instruction on x86). |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 // an instruction or relocation information. | 971 // an instruction or relocation information. |
| 976 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } | 972 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } |
| 977 | 973 |
| 978 // Get the number of bytes available in the buffer. | 974 // Get the number of bytes available in the buffer. |
| 979 inline int available_space() const { return reloc_info_writer.pos() - pc_; } | 975 inline int available_space() const { return reloc_info_writer.pos() - pc_; } |
| 980 | 976 |
| 981 static bool IsNop(Address addr) { return *addr == 0x90; } | 977 static bool IsNop(Address addr) { return *addr == 0x90; } |
| 982 | 978 |
| 983 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 979 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
| 984 | 980 |
| 981 int relocation_writer_size() { |
| 982 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
| 983 } |
| 984 |
| 985 // Avoid overflows for displacements etc. | 985 // Avoid overflows for displacements etc. |
| 986 static const int kMaximalBufferSize = 512*MB; | 986 static const int kMaximalBufferSize = 512*MB; |
| 987 static const int kMinimalBufferSize = 4*KB; | 987 static const int kMinimalBufferSize = 4*KB; |
| 988 | 988 |
| 989 protected: | 989 protected: |
| 990 bool emit_debug_code() const { return emit_debug_code_; } |
| 991 |
| 990 void movsd(XMMRegister dst, const Operand& src); | 992 void movsd(XMMRegister dst, const Operand& src); |
| 991 void movsd(const Operand& dst, XMMRegister src); | 993 void movsd(const Operand& dst, XMMRegister src); |
| 992 | 994 |
| 993 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 995 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
| 994 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 996 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
| 995 void emit_sse_operand(Register dst, XMMRegister src); | 997 void emit_sse_operand(Register dst, XMMRegister src); |
| 996 | 998 |
| 997 byte* addr_at(int pos) { return buffer_ + pos; } | 999 byte* addr_at(int pos) { return buffer_ + pos; } |
| 998 private: | 1000 private: |
| 999 byte byte_at(int pos) { return buffer_[pos]; } | 1001 byte byte_at(int pos) { return buffer_[pos]; } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 | 1057 |
| 1056 // code generation | 1058 // code generation |
| 1057 byte* pc_; // the program counter; moves forward | 1059 byte* pc_; // the program counter; moves forward |
| 1058 RelocInfoWriter reloc_info_writer; | 1060 RelocInfoWriter reloc_info_writer; |
| 1059 | 1061 |
| 1060 // push-pop elimination | 1062 // push-pop elimination |
| 1061 byte* last_pc_; | 1063 byte* last_pc_; |
| 1062 | 1064 |
| 1063 PositionsRecorder positions_recorder_; | 1065 PositionsRecorder positions_recorder_; |
| 1064 | 1066 |
| 1067 bool emit_debug_code_; |
| 1068 |
| 1065 friend class PositionsRecorder; | 1069 friend class PositionsRecorder; |
| 1066 }; | 1070 }; |
| 1067 | 1071 |
| 1068 | 1072 |
| 1069 // Helper class that ensures that there is enough space for generating | 1073 // Helper class that ensures that there is enough space for generating |
| 1070 // instructions and relocation information. The constructor makes | 1074 // instructions and relocation information. The constructor makes |
| 1071 // sure that there is enough space and (in debug mode) the destructor | 1075 // sure that there is enough space and (in debug mode) the destructor |
| 1072 // checks that we did not generate too much. | 1076 // checks that we did not generate too much. |
| 1073 class EnsureSpace BASE_EMBEDDED { | 1077 class EnsureSpace BASE_EMBEDDED { |
| 1074 public: | 1078 public: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1089 private: | 1093 private: |
| 1090 Assembler* assembler_; | 1094 Assembler* assembler_; |
| 1091 #ifdef DEBUG | 1095 #ifdef DEBUG |
| 1092 int space_before_; | 1096 int space_before_; |
| 1093 #endif | 1097 #endif |
| 1094 }; | 1098 }; |
| 1095 | 1099 |
| 1096 } } // namespace v8::internal | 1100 } } // namespace v8::internal |
| 1097 | 1101 |
| 1098 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1102 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
| OLD | NEW |