| 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 // write a comment. | 1009 // write a comment. |
| 1010 void RecordComment(const char* msg, bool force = false); | 1010 void RecordComment(const char* msg, bool force = false); |
| 1011 | 1011 |
| 1012 // Writes a single byte or word of data in the code stream. Used for | 1012 // Writes a single byte or word of data in the code stream. Used for |
| 1013 // inline tables, e.g., jump-tables. | 1013 // inline tables, e.g., jump-tables. |
| 1014 void db(uint8_t data); | 1014 void db(uint8_t data); |
| 1015 void dd(uint32_t data); | 1015 void dd(uint32_t data); |
| 1016 | 1016 |
| 1017 int pc_offset() const { return pc_ - buffer_; } | 1017 int pc_offset() const { return pc_ - buffer_; } |
| 1018 | 1018 |
| 1019 // Used for patching the code stream while it is being emitted. | |
| 1020 inline byte get_opcode(int offset) { | |
| 1021 ASSERT(offset < 0); | |
| 1022 ASSERT(pc_ + offset >= buffer_); | |
| 1023 return pc_[offset]; | |
| 1024 } | |
| 1025 inline void set_opcode(int offset, byte opcode) { | |
| 1026 ASSERT(offset < 0); | |
| 1027 ASSERT(pc_ + offset >= buffer_); | |
| 1028 pc_[offset] = opcode; | |
| 1029 } | |
| 1030 | |
| 1031 // Check if there is less than kGap bytes available in the buffer. | 1019 // Check if there is less than kGap bytes available in the buffer. |
| 1032 // If this is the case, we need to grow the buffer before emitting | 1020 // If this is the case, we need to grow the buffer before emitting |
| 1033 // an instruction or relocation information. | 1021 // an instruction or relocation information. |
| 1034 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } | 1022 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } |
| 1035 | 1023 |
| 1036 // Get the number of bytes available in the buffer. | 1024 // Get the number of bytes available in the buffer. |
| 1037 inline int available_space() const { return reloc_info_writer.pos() - pc_; } | 1025 inline int available_space() const { return reloc_info_writer.pos() - pc_; } |
| 1038 | 1026 |
| 1039 static bool IsNop(Address addr) { return *addr == 0x90; } | 1027 static bool IsNop(Address addr) { return *addr == 0x90; } |
| 1040 | 1028 |
| 1041 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 1029 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
| 1042 | 1030 |
| 1043 int relocation_writer_size() { | 1031 int relocation_writer_size() { |
| 1044 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 1032 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
| 1045 } | 1033 } |
| 1046 | 1034 |
| 1047 // Avoid overflows for displacements etc. | 1035 // Avoid overflows for displacements etc. |
| 1048 static const int kMaximalBufferSize = 512*MB; | 1036 static const int kMaximalBufferSize = 512*MB; |
| 1049 static const int kMinimalBufferSize = 4*KB; | 1037 static const int kMinimalBufferSize = 4*KB; |
| 1050 | 1038 |
| 1039 byte byte_at(int pos) { return buffer_[pos]; } |
| 1040 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
| 1041 |
| 1051 protected: | 1042 protected: |
| 1052 bool emit_debug_code() const { return emit_debug_code_; } | 1043 bool emit_debug_code() const { return emit_debug_code_; } |
| 1053 | 1044 |
| 1054 void movsd(XMMRegister dst, const Operand& src); | 1045 void movsd(XMMRegister dst, const Operand& src); |
| 1055 void movsd(const Operand& dst, XMMRegister src); | 1046 void movsd(const Operand& dst, XMMRegister src); |
| 1056 | 1047 |
| 1057 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 1048 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
| 1058 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 1049 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
| 1059 void emit_sse_operand(Register dst, XMMRegister src); | 1050 void emit_sse_operand(Register dst, XMMRegister src); |
| 1060 | 1051 |
| 1061 byte* addr_at(int pos) { return buffer_ + pos; } | 1052 byte* addr_at(int pos) { return buffer_ + pos; } |
| 1062 | 1053 |
| 1063 | 1054 |
| 1064 private: | 1055 private: |
| 1065 byte byte_at(int pos) { return buffer_[pos]; } | |
| 1066 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | |
| 1067 uint32_t long_at(int pos) { | 1056 uint32_t long_at(int pos) { |
| 1068 return *reinterpret_cast<uint32_t*>(addr_at(pos)); | 1057 return *reinterpret_cast<uint32_t*>(addr_at(pos)); |
| 1069 } | 1058 } |
| 1070 void long_at_put(int pos, uint32_t x) { | 1059 void long_at_put(int pos, uint32_t x) { |
| 1071 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; | 1060 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; |
| 1072 } | 1061 } |
| 1073 | 1062 |
| 1074 // code emission | 1063 // code emission |
| 1075 void GrowBuffer(); | 1064 void GrowBuffer(); |
| 1076 inline void emit(uint32_t x); | 1065 inline void emit(uint32_t x); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 private: | 1144 private: |
| 1156 Assembler* assembler_; | 1145 Assembler* assembler_; |
| 1157 #ifdef DEBUG | 1146 #ifdef DEBUG |
| 1158 int space_before_; | 1147 int space_before_; |
| 1159 #endif | 1148 #endif |
| 1160 }; | 1149 }; |
| 1161 | 1150 |
| 1162 } } // namespace v8::internal | 1151 } } // namespace v8::internal |
| 1163 | 1152 |
| 1164 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1153 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
| OLD | NEW |