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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 // owned by the assembler and deallocated upon destruction of the assembler. | 577 // owned by the assembler and deallocated upon destruction of the assembler. |
578 // | 578 // |
579 // If the provided buffer is not NULL, the assembler uses the provided buffer | 579 // If the provided buffer is not NULL, the assembler uses the provided buffer |
580 // for code generation and assumes its size to be buffer_size. If the buffer | 580 // for code generation and assumes its size to be buffer_size. If the buffer |
581 // is too small, a fatal error occurs. No deallocation of the buffer is done | 581 // is too small, a fatal error occurs. No deallocation of the buffer is done |
582 // upon destruction of the assembler. | 582 // upon destruction of the assembler. |
583 // TODO(vitalyr): the assembler does not need an isolate. | 583 // TODO(vitalyr): the assembler does not need an isolate. |
584 Assembler(Isolate* isolate, void* buffer, int buffer_size); | 584 Assembler(Isolate* isolate, void* buffer, int buffer_size); |
585 ~Assembler(); | 585 ~Assembler(); |
586 | 586 |
587 // Overrides the default provided by FLAG_debug_code. | |
588 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } | |
589 | |
590 // GetCode emits any pending (non-emitted) code and fills the descriptor | 587 // GetCode emits any pending (non-emitted) code and fills the descriptor |
591 // desc. GetCode() is idempotent; it returns the same result if no other | 588 // desc. GetCode() is idempotent; it returns the same result if no other |
592 // Assembler functions are invoked in between GetCode() calls. | 589 // Assembler functions are invoked in between GetCode() calls. |
593 void GetCode(CodeDesc* desc); | 590 void GetCode(CodeDesc* desc); |
594 | 591 |
595 // Read/Modify the code target in the branch/call instruction at pc. | 592 // Read/Modify the code target in the branch/call instruction at pc. |
596 inline static Address target_address_at(Address pc); | 593 inline static Address target_address_at(Address pc); |
597 inline static void set_target_address_at(Address pc, Address target); | 594 inline static void set_target_address_at(Address pc, Address target); |
598 | 595 |
599 // Return the code target address at a call site from the return address | 596 // Return the code target address at a call site from the return address |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 } | 1110 } |
1114 | 1111 |
1115 // Avoid overflows for displacements etc. | 1112 // Avoid overflows for displacements etc. |
1116 static const int kMaximalBufferSize = 512*MB; | 1113 static const int kMaximalBufferSize = 512*MB; |
1117 static const int kMinimalBufferSize = 4*KB; | 1114 static const int kMinimalBufferSize = 4*KB; |
1118 | 1115 |
1119 byte byte_at(int pos) { return buffer_[pos]; } | 1116 byte byte_at(int pos) { return buffer_[pos]; } |
1120 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | 1117 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
1121 | 1118 |
1122 protected: | 1119 protected: |
1123 bool emit_debug_code() const { return emit_debug_code_; } | |
1124 | |
1125 void movsd(XMMRegister dst, const Operand& src); | 1120 void movsd(XMMRegister dst, const Operand& src); |
1126 void movsd(const Operand& dst, XMMRegister src); | 1121 void movsd(const Operand& dst, XMMRegister src); |
1127 | 1122 |
1128 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 1123 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
1129 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 1124 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
1130 void emit_sse_operand(Register dst, XMMRegister src); | 1125 void emit_sse_operand(Register dst, XMMRegister src); |
1131 | 1126 |
1132 byte* addr_at(int pos) { return buffer_ + pos; } | 1127 byte* addr_at(int pos) { return buffer_ + pos; } |
1133 | 1128 |
1134 | 1129 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 byte* buffer_; | 1182 byte* buffer_; |
1188 int buffer_size_; | 1183 int buffer_size_; |
1189 // True if the assembler owns the buffer, false if buffer is external. | 1184 // True if the assembler owns the buffer, false if buffer is external. |
1190 bool own_buffer_; | 1185 bool own_buffer_; |
1191 | 1186 |
1192 // code generation | 1187 // code generation |
1193 byte* pc_; // the program counter; moves forward | 1188 byte* pc_; // the program counter; moves forward |
1194 RelocInfoWriter reloc_info_writer; | 1189 RelocInfoWriter reloc_info_writer; |
1195 | 1190 |
1196 PositionsRecorder positions_recorder_; | 1191 PositionsRecorder positions_recorder_; |
1197 | |
1198 bool emit_debug_code_; | |
1199 | |
1200 friend class PositionsRecorder; | 1192 friend class PositionsRecorder; |
1201 }; | 1193 }; |
1202 | 1194 |
1203 | 1195 |
1204 // Helper class that ensures that there is enough space for generating | 1196 // Helper class that ensures that there is enough space for generating |
1205 // instructions and relocation information. The constructor makes | 1197 // instructions and relocation information. The constructor makes |
1206 // sure that there is enough space and (in debug mode) the destructor | 1198 // sure that there is enough space and (in debug mode) the destructor |
1207 // checks that we did not generate too much. | 1199 // checks that we did not generate too much. |
1208 class EnsureSpace BASE_EMBEDDED { | 1200 class EnsureSpace BASE_EMBEDDED { |
1209 public: | 1201 public: |
(...skipping 14 matching lines...) Expand all Loading... |
1224 private: | 1216 private: |
1225 Assembler* assembler_; | 1217 Assembler* assembler_; |
1226 #ifdef DEBUG | 1218 #ifdef DEBUG |
1227 int space_before_; | 1219 int space_before_; |
1228 #endif | 1220 #endif |
1229 }; | 1221 }; |
1230 | 1222 |
1231 } } // namespace v8::internal | 1223 } } // namespace v8::internal |
1232 | 1224 |
1233 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1225 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |