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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // buffer, and buffer_size determines the initial buffer size. The buffer is | 515 // buffer, and buffer_size determines the initial buffer size. The buffer is |
516 // owned by the assembler and deallocated upon destruction of the assembler. | 516 // owned by the assembler and deallocated upon destruction of the assembler. |
517 // | 517 // |
518 // If the provided buffer is not NULL, the assembler uses the provided buffer | 518 // If the provided buffer is not NULL, the assembler uses the provided buffer |
519 // for code generation and assumes its size to be buffer_size. If the buffer | 519 // for code generation and assumes its size to be buffer_size. If the buffer |
520 // is too small, a fatal error occurs. No deallocation of the buffer is done | 520 // is too small, a fatal error occurs. No deallocation of the buffer is done |
521 // upon destruction of the assembler. | 521 // upon destruction of the assembler. |
522 Assembler(void* buffer, int buffer_size); | 522 Assembler(void* buffer, int buffer_size); |
523 ~Assembler(); | 523 ~Assembler(); |
524 | 524 |
| 525 // Overrides the default provided by FLAG_debug_code. |
| 526 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } |
| 527 |
525 // GetCode emits any pending (non-emitted) code and fills the descriptor | 528 // GetCode emits any pending (non-emitted) code and fills the descriptor |
526 // desc. GetCode() is idempotent; it returns the same result if no other | 529 // desc. GetCode() is idempotent; it returns the same result if no other |
527 // Assembler functions are invoked in between GetCode() calls. | 530 // Assembler functions are invoked in between GetCode() calls. |
528 void GetCode(CodeDesc* desc); | 531 void GetCode(CodeDesc* desc); |
529 | 532 |
530 // Read/Modify the code target in the branch/call instruction at pc. | 533 // Read/Modify the code target in the branch/call instruction at pc. |
531 inline static Address target_address_at(Address pc); | 534 inline static Address target_address_at(Address pc); |
532 inline static void set_target_address_at(Address pc, Address target); | 535 inline static void set_target_address_at(Address pc, Address target); |
533 | 536 |
534 // This sets the branch destination (which is in the instruction on x86). | 537 // This sets the branch destination (which is in the instruction on x86). |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 | 978 |
976 int relocation_writer_size() { | 979 int relocation_writer_size() { |
977 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 980 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
978 } | 981 } |
979 | 982 |
980 // Avoid overflows for displacements etc. | 983 // Avoid overflows for displacements etc. |
981 static const int kMaximalBufferSize = 512*MB; | 984 static const int kMaximalBufferSize = 512*MB; |
982 static const int kMinimalBufferSize = 4*KB; | 985 static const int kMinimalBufferSize = 4*KB; |
983 | 986 |
984 protected: | 987 protected: |
| 988 bool emit_debug_code() const { return emit_debug_code_; } |
| 989 |
985 void movsd(XMMRegister dst, const Operand& src); | 990 void movsd(XMMRegister dst, const Operand& src); |
986 void movsd(const Operand& dst, XMMRegister src); | 991 void movsd(const Operand& dst, XMMRegister src); |
987 | 992 |
988 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 993 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
989 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 994 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
990 void emit_sse_operand(Register dst, XMMRegister src); | 995 void emit_sse_operand(Register dst, XMMRegister src); |
991 | 996 |
992 byte* addr_at(int pos) { return buffer_ + pos; } | 997 byte* addr_at(int pos) { return buffer_ + pos; } |
993 private: | 998 private: |
994 byte byte_at(int pos) { return buffer_[pos]; } | 999 byte byte_at(int pos) { return buffer_[pos]; } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 | 1055 |
1051 // code generation | 1056 // code generation |
1052 byte* pc_; // the program counter; moves forward | 1057 byte* pc_; // the program counter; moves forward |
1053 RelocInfoWriter reloc_info_writer; | 1058 RelocInfoWriter reloc_info_writer; |
1054 | 1059 |
1055 // push-pop elimination | 1060 // push-pop elimination |
1056 byte* last_pc_; | 1061 byte* last_pc_; |
1057 | 1062 |
1058 PositionsRecorder positions_recorder_; | 1063 PositionsRecorder positions_recorder_; |
1059 | 1064 |
| 1065 bool emit_debug_code_; |
| 1066 |
1060 friend class PositionsRecorder; | 1067 friend class PositionsRecorder; |
1061 }; | 1068 }; |
1062 | 1069 |
1063 | 1070 |
1064 // Helper class that ensures that there is enough space for generating | 1071 // Helper class that ensures that there is enough space for generating |
1065 // instructions and relocation information. The constructor makes | 1072 // instructions and relocation information. The constructor makes |
1066 // sure that there is enough space and (in debug mode) the destructor | 1073 // sure that there is enough space and (in debug mode) the destructor |
1067 // checks that we did not generate too much. | 1074 // checks that we did not generate too much. |
1068 class EnsureSpace BASE_EMBEDDED { | 1075 class EnsureSpace BASE_EMBEDDED { |
1069 public: | 1076 public: |
(...skipping 14 matching lines...) Expand all Loading... |
1084 private: | 1091 private: |
1085 Assembler* assembler_; | 1092 Assembler* assembler_; |
1086 #ifdef DEBUG | 1093 #ifdef DEBUG |
1087 int space_before_; | 1094 int space_before_; |
1088 #endif | 1095 #endif |
1089 }; | 1096 }; |
1090 | 1097 |
1091 } } // namespace v8::internal | 1098 } } // namespace v8::internal |
1092 | 1099 |
1093 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1100 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |