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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // such that we use an enum in optimized mode, and the struct in debug | 85 // such that we use an enum in optimized mode, and the struct in debug |
86 // mode. This way we get the compile-time error checking in debug mode | 86 // mode. This way we get the compile-time error checking in debug mode |
87 // and best performance in optimized code. | 87 // and best performance in optimized code. |
88 // | 88 // |
89 | 89 |
90 struct Register { | 90 struct Register { |
91 static Register toRegister(int code) { | 91 static Register toRegister(int code) { |
92 Register r = { code }; | 92 Register r = { code }; |
93 return r; | 93 return r; |
94 } | 94 } |
95 bool is_valid() const { return 0 <= code_ && code_ < 16; } | 95 bool is_valid() const { return 0 <= code_ && code_ < 16; } |
96 bool is(Register reg) const { return code_ == reg.code_; } | 96 bool is(Register reg) const { return code_ == reg.code_; } |
97 int code() const { | 97 int code() const { |
98 ASSERT(is_valid()); | 98 ASSERT(is_valid()); |
99 return code_; | 99 return code_; |
100 } | 100 } |
101 int bit() const { | 101 int bit() const { |
102 return 1 << code_; | 102 return 1 << code_; |
103 } | 103 } |
104 | 104 |
105 // Return the high bit of the register code as a 0 or 1. Used often | 105 // Return the high bit of the register code as a 0 or 1. Used often |
106 // when constructing the REX prefix byte. | 106 // when constructing the REX prefix byte. |
107 int high_bit() const { | 107 int high_bit() const { |
108 return code_ >> 3; | 108 return code_ >> 3; |
109 } | 109 } |
110 // Return the 3 low bits of the register code. Used when encoding registers | 110 // Return the 3 low bits of the register code. Used when encoding registers |
111 // in modR/M, SIB, and opcode bytes. | 111 // in modR/M, SIB, and opcode bytes. |
(...skipping 19 matching lines...) Expand all Loading... |
131 const Register r10 = { 10 }; | 131 const Register r10 = { 10 }; |
132 const Register r11 = { 11 }; | 132 const Register r11 = { 11 }; |
133 const Register r12 = { 12 }; | 133 const Register r12 = { 12 }; |
134 const Register r13 = { 13 }; | 134 const Register r13 = { 13 }; |
135 const Register r14 = { 14 }; | 135 const Register r14 = { 14 }; |
136 const Register r15 = { 15 }; | 136 const Register r15 = { 15 }; |
137 const Register no_reg = { -1 }; | 137 const Register no_reg = { -1 }; |
138 | 138 |
139 | 139 |
140 struct XMMRegister { | 140 struct XMMRegister { |
141 bool is_valid() const { return 0 <= code_ && code_ < 16; } | 141 bool is_valid() const { return 0 <= code_ && code_ < 16; } |
142 int code() const { | 142 int code() const { |
143 ASSERT(is_valid()); | 143 ASSERT(is_valid()); |
144 return code_; | 144 return code_; |
145 } | 145 } |
146 | 146 |
147 // Return the high bit of the register code as a 0 or 1. Used often | 147 // Return the high bit of the register code as a 0 or 1. Used often |
148 // when constructing the REX prefix byte. | 148 // when constructing the REX prefix byte. |
149 int high_bit() const { | 149 int high_bit() const { |
150 return code_ >> 3; | 150 return code_ >> 3; |
151 } | 151 } |
152 // Return the 3 low bits of the register code. Used when encoding registers | 152 // Return the 3 low bits of the register code. Used when encoding registers |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 void RecordDebugBreakSlot(); | 1171 void RecordDebugBreakSlot(); |
1172 | 1172 |
1173 // Record a comment relocation entry that can be used by a disassembler. | 1173 // Record a comment relocation entry that can be used by a disassembler. |
1174 // Use --debug_code to enable. | 1174 // Use --debug_code to enable. |
1175 void RecordComment(const char* msg); | 1175 void RecordComment(const char* msg); |
1176 | 1176 |
1177 void RecordPosition(int pos); | 1177 void RecordPosition(int pos); |
1178 void RecordStatementPosition(int pos); | 1178 void RecordStatementPosition(int pos); |
1179 bool WriteRecordedPositions(); | 1179 bool WriteRecordedPositions(); |
1180 | 1180 |
1181 int pc_offset() const { return static_cast<int>(pc_ - buffer_); } | 1181 int pc_offset() const { return static_cast<int>(pc_ - buffer_); } |
1182 int current_statement_position() const { return current_statement_position_; } | 1182 int current_statement_position() const { return current_statement_position_; } |
1183 int current_position() const { return current_position_; } | 1183 int current_position() const { return current_position_; } |
1184 | 1184 |
1185 // Check if there is less than kGap bytes available in the buffer. | 1185 // Check if there is less than kGap bytes available in the buffer. |
1186 // If this is the case, we need to grow the buffer before emitting | 1186 // If this is the case, we need to grow the buffer before emitting |
1187 // an instruction or relocation information. | 1187 // an instruction or relocation information. |
1188 inline bool buffer_overflow() const { | 1188 inline bool buffer_overflow() const { |
1189 return pc_ >= reloc_info_writer.pos() - kGap; | 1189 return pc_ >= reloc_info_writer.pos() - kGap; |
1190 } | 1190 } |
1191 | 1191 |
1192 // Get the number of bytes available in the buffer. | 1192 // Get the number of bytes available in the buffer. |
1193 inline int available_space() const { | 1193 inline int available_space() const { |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 private: | 1435 private: |
1436 Assembler* assembler_; | 1436 Assembler* assembler_; |
1437 #ifdef DEBUG | 1437 #ifdef DEBUG |
1438 int space_before_; | 1438 int space_before_; |
1439 #endif | 1439 #endif |
1440 }; | 1440 }; |
1441 | 1441 |
1442 } } // namespace v8::internal | 1442 } } // namespace v8::internal |
1443 | 1443 |
1444 #endif // V8_X64_ASSEMBLER_X64_H_ | 1444 #endif // V8_X64_ASSEMBLER_X64_H_ |
OLD | NEW |