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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. | 587 // Overrides the default provided by FLAG_debug_code. |
588 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } | 588 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } |
589 | 589 |
| 590 // Avoids using instructions that vary in size in unpredictable ways between |
| 591 // the snapshot and the running VM. This is needed by the full compiler so |
| 592 // that it can recompile code with debug support and fix the PC. |
| 593 void set_predictable_code_size(bool value) { predictable_code_size_ = value; } |
| 594 |
590 // GetCode emits any pending (non-emitted) code and fills the descriptor | 595 // GetCode emits any pending (non-emitted) code and fills the descriptor |
591 // desc. GetCode() is idempotent; it returns the same result if no other | 596 // desc. GetCode() is idempotent; it returns the same result if no other |
592 // Assembler functions are invoked in between GetCode() calls. | 597 // Assembler functions are invoked in between GetCode() calls. |
593 void GetCode(CodeDesc* desc); | 598 void GetCode(CodeDesc* desc); |
594 | 599 |
595 // Read/Modify the code target in the branch/call instruction at pc. | 600 // Read/Modify the code target in the branch/call instruction at pc. |
596 inline static Address target_address_at(Address pc); | 601 inline static Address target_address_at(Address pc); |
597 inline static void set_target_address_at(Address pc, Address target); | 602 inline static void set_target_address_at(Address pc, Address target); |
598 | 603 |
599 // This sets the branch destination (which is in the instruction on x86). | 604 // This sets the branch destination (which is in the instruction on x86). |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 | 1109 |
1105 // Avoid overflows for displacements etc. | 1110 // Avoid overflows for displacements etc. |
1106 static const int kMaximalBufferSize = 512*MB; | 1111 static const int kMaximalBufferSize = 512*MB; |
1107 static const int kMinimalBufferSize = 4*KB; | 1112 static const int kMinimalBufferSize = 4*KB; |
1108 | 1113 |
1109 byte byte_at(int pos) { return buffer_[pos]; } | 1114 byte byte_at(int pos) { return buffer_[pos]; } |
1110 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | 1115 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
1111 | 1116 |
1112 protected: | 1117 protected: |
1113 bool emit_debug_code() const { return emit_debug_code_; } | 1118 bool emit_debug_code() const { return emit_debug_code_; } |
| 1119 bool predictable_code_size() const { return predictable_code_size_ ; } |
1114 | 1120 |
1115 void movsd(XMMRegister dst, const Operand& src); | 1121 void movsd(XMMRegister dst, const Operand& src); |
1116 void movsd(const Operand& dst, XMMRegister src); | 1122 void movsd(const Operand& dst, XMMRegister src); |
1117 | 1123 |
1118 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 1124 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
1119 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 1125 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
1120 void emit_sse_operand(Register dst, XMMRegister src); | 1126 void emit_sse_operand(Register dst, XMMRegister src); |
1121 | 1127 |
1122 byte* addr_at(int pos) { return buffer_ + pos; } | 1128 byte* addr_at(int pos) { return buffer_ + pos; } |
1123 | 1129 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 // True if the assembler owns the buffer, false if buffer is external. | 1185 // True if the assembler owns the buffer, false if buffer is external. |
1180 bool own_buffer_; | 1186 bool own_buffer_; |
1181 | 1187 |
1182 // code generation | 1188 // code generation |
1183 byte* pc_; // the program counter; moves forward | 1189 byte* pc_; // the program counter; moves forward |
1184 RelocInfoWriter reloc_info_writer; | 1190 RelocInfoWriter reloc_info_writer; |
1185 | 1191 |
1186 PositionsRecorder positions_recorder_; | 1192 PositionsRecorder positions_recorder_; |
1187 | 1193 |
1188 bool emit_debug_code_; | 1194 bool emit_debug_code_; |
| 1195 bool predictable_code_size_; |
1189 | 1196 |
1190 friend class PositionsRecorder; | 1197 friend class PositionsRecorder; |
1191 }; | 1198 }; |
1192 | 1199 |
1193 | 1200 |
1194 // Helper class that ensures that there is enough space for generating | 1201 // Helper class that ensures that there is enough space for generating |
1195 // instructions and relocation information. The constructor makes | 1202 // instructions and relocation information. The constructor makes |
1196 // sure that there is enough space and (in debug mode) the destructor | 1203 // sure that there is enough space and (in debug mode) the destructor |
1197 // checks that we did not generate too much. | 1204 // checks that we did not generate too much. |
1198 class EnsureSpace BASE_EMBEDDED { | 1205 class EnsureSpace BASE_EMBEDDED { |
(...skipping 15 matching lines...) Expand all Loading... |
1214 private: | 1221 private: |
1215 Assembler* assembler_; | 1222 Assembler* assembler_; |
1216 #ifdef DEBUG | 1223 #ifdef DEBUG |
1217 int space_before_; | 1224 int space_before_; |
1218 #endif | 1225 #endif |
1219 }; | 1226 }; |
1220 | 1227 |
1221 } } // namespace v8::internal | 1228 } } // namespace v8::internal |
1222 | 1229 |
1223 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1230 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |