Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: src/ia32/assembler-ia32.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/ia32/assembler-ia32-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 64
65 void CpuFeatures::PrintTarget() { } 65 void CpuFeatures::PrintTarget() { }
66 void CpuFeatures::PrintFeatures() { } 66 void CpuFeatures::PrintFeatures() { }
67 67
68 68
69 // ----------------------------------------------------------------------------- 69 // -----------------------------------------------------------------------------
70 // Implementation of Displacement 70 // Implementation of Displacement
71 71
72 void Displacement::init(Label* L, Type type) { 72 void Displacement::init(Label* L, Type type) {
73 ASSERT(!L->is_bound()); 73 DCHECK(!L->is_bound());
74 int next = 0; 74 int next = 0;
75 if (L->is_linked()) { 75 if (L->is_linked()) {
76 next = L->pos(); 76 next = L->pos();
77 ASSERT(next > 0); // Displacements must be at positions > 0 77 DCHECK(next > 0); // Displacements must be at positions > 0
78 } 78 }
79 // Ensure that we _never_ overflow the next field. 79 // Ensure that we _never_ overflow the next field.
80 ASSERT(NextField::is_valid(Assembler::kMaximalBufferSize)); 80 DCHECK(NextField::is_valid(Assembler::kMaximalBufferSize));
81 data_ = NextField::encode(next) | TypeField::encode(type); 81 data_ = NextField::encode(next) | TypeField::encode(type);
82 } 82 }
83 83
84 84
85 // ----------------------------------------------------------------------------- 85 // -----------------------------------------------------------------------------
86 // Implementation of RelocInfo 86 // Implementation of RelocInfo
87 87
88 88
89 const int RelocInfo::kApplyMask = 89 const int RelocInfo::kApplyMask =
90 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY | 90 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Add a label for checking the size of the code used for returning. 130 // Add a label for checking the size of the code used for returning.
131 #ifdef DEBUG 131 #ifdef DEBUG
132 Label check_codesize; 132 Label check_codesize;
133 patcher.masm()->bind(&check_codesize); 133 patcher.masm()->bind(&check_codesize);
134 #endif 134 #endif
135 135
136 // Patch the code. 136 // Patch the code.
137 patcher.masm()->call(target, RelocInfo::NONE32); 137 patcher.masm()->call(target, RelocInfo::NONE32);
138 138
139 // Check that the size of the code generated is as expected. 139 // Check that the size of the code generated is as expected.
140 ASSERT_EQ(kCallCodeSize, 140 DCHECK_EQ(kCallCodeSize,
141 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); 141 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
142 142
143 // Add the requested number of int3 instructions after the call. 143 // Add the requested number of int3 instructions after the call.
144 ASSERT_GE(guard_bytes, 0); 144 DCHECK_GE(guard_bytes, 0);
145 for (int i = 0; i < guard_bytes; i++) { 145 for (int i = 0; i < guard_bytes; i++) {
146 patcher.masm()->int3(); 146 patcher.masm()->int3();
147 } 147 }
148 } 148 }
149 149
150 150
151 // ----------------------------------------------------------------------------- 151 // -----------------------------------------------------------------------------
152 // Implementation of Operand 152 // Implementation of Operand
153 153
154 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { 154 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) {
(...skipping 14 matching lines...) Expand all
169 set_dispr(disp, rmode); 169 set_dispr(disp, rmode);
170 } 170 }
171 } 171 }
172 172
173 173
174 Operand::Operand(Register base, 174 Operand::Operand(Register base,
175 Register index, 175 Register index,
176 ScaleFactor scale, 176 ScaleFactor scale,
177 int32_t disp, 177 int32_t disp,
178 RelocInfo::Mode rmode) { 178 RelocInfo::Mode rmode) {
179 ASSERT(!index.is(esp)); // illegal addressing mode 179 DCHECK(!index.is(esp)); // illegal addressing mode
180 // [base + index*scale + disp/r] 180 // [base + index*scale + disp/r]
181 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { 181 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) {
182 // [base + index*scale] 182 // [base + index*scale]
183 set_modrm(0, esp); 183 set_modrm(0, esp);
184 set_sib(scale, index, base); 184 set_sib(scale, index, base);
185 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { 185 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) {
186 // [base + index*scale + disp8] 186 // [base + index*scale + disp8]
187 set_modrm(1, esp); 187 set_modrm(1, esp);
188 set_sib(scale, index, base); 188 set_sib(scale, index, base);
189 set_disp8(disp); 189 set_disp8(disp);
190 } else { 190 } else {
191 // [base + index*scale + disp/r] 191 // [base + index*scale + disp/r]
192 set_modrm(2, esp); 192 set_modrm(2, esp);
193 set_sib(scale, index, base); 193 set_sib(scale, index, base);
194 set_dispr(disp, rmode); 194 set_dispr(disp, rmode);
195 } 195 }
196 } 196 }
197 197
198 198
199 Operand::Operand(Register index, 199 Operand::Operand(Register index,
200 ScaleFactor scale, 200 ScaleFactor scale,
201 int32_t disp, 201 int32_t disp,
202 RelocInfo::Mode rmode) { 202 RelocInfo::Mode rmode) {
203 ASSERT(!index.is(esp)); // illegal addressing mode 203 DCHECK(!index.is(esp)); // illegal addressing mode
204 // [index*scale + disp/r] 204 // [index*scale + disp/r]
205 set_modrm(0, esp); 205 set_modrm(0, esp);
206 set_sib(scale, index, ebp); 206 set_sib(scale, index, ebp);
207 set_dispr(disp, rmode); 207 set_dispr(disp, rmode);
208 } 208 }
209 209
210 210
211 bool Operand::is_reg(Register reg) const { 211 bool Operand::is_reg(Register reg) const {
212 return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only. 212 return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only.
213 && ((buf_[0] & 0x07) == reg.code()); // register codes match. 213 && ((buf_[0] & 0x07) == reg.code()); // register codes match.
214 } 214 }
215 215
216 216
217 bool Operand::is_reg_only() const { 217 bool Operand::is_reg_only() const {
218 return (buf_[0] & 0xF8) == 0xC0; // Addressing mode is register only. 218 return (buf_[0] & 0xF8) == 0xC0; // Addressing mode is register only.
219 } 219 }
220 220
221 221
222 Register Operand::reg() const { 222 Register Operand::reg() const {
223 ASSERT(is_reg_only()); 223 DCHECK(is_reg_only());
224 return Register::from_code(buf_[0] & 0x07); 224 return Register::from_code(buf_[0] & 0x07);
225 } 225 }
226 226
227 227
228 // ----------------------------------------------------------------------------- 228 // -----------------------------------------------------------------------------
229 // Implementation of Assembler. 229 // Implementation of Assembler.
230 230
231 // Emit a single byte. Must always be inlined. 231 // Emit a single byte. Must always be inlined.
232 #define EMIT(x) \ 232 #define EMIT(x) \
233 *pc_++ = (x) 233 *pc_++ = (x)
(...skipping 19 matching lines...) Expand all
253 253
254 #ifdef GENERATED_CODE_COVERAGE 254 #ifdef GENERATED_CODE_COVERAGE
255 InitCoverageLog(); 255 InitCoverageLog();
256 #endif 256 #endif
257 } 257 }
258 258
259 259
260 void Assembler::GetCode(CodeDesc* desc) { 260 void Assembler::GetCode(CodeDesc* desc) {
261 // Finalize code (at this point overflow() may be true, but the gap ensures 261 // Finalize code (at this point overflow() may be true, but the gap ensures
262 // that we are still not overlapping instructions and relocation info). 262 // that we are still not overlapping instructions and relocation info).
263 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. 263 DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
264 // Set up code descriptor. 264 // Set up code descriptor.
265 desc->buffer = buffer_; 265 desc->buffer = buffer_;
266 desc->buffer_size = buffer_size_; 266 desc->buffer_size = buffer_size_;
267 desc->instr_size = pc_offset(); 267 desc->instr_size = pc_offset();
268 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); 268 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
269 desc->origin = this; 269 desc->origin = this;
270 } 270 }
271 271
272 272
273 void Assembler::Align(int m) { 273 void Assembler::Align(int m) {
274 ASSERT(IsPowerOf2(m)); 274 DCHECK(IsPowerOf2(m));
275 int mask = m - 1; 275 int mask = m - 1;
276 int addr = pc_offset(); 276 int addr = pc_offset();
277 Nop((m - (addr & mask)) & mask); 277 Nop((m - (addr & mask)) & mask);
278 } 278 }
279 279
280 280
281 bool Assembler::IsNop(Address addr) { 281 bool Assembler::IsNop(Address addr) {
282 Address a = addr; 282 Address a = addr;
283 while (*a == 0x66) a++; 283 while (*a == 0x66) a++;
284 if (*a == 0x90) return true; 284 if (*a == 0x90) return true;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 415
416 void Assembler::push(const Operand& src) { 416 void Assembler::push(const Operand& src) {
417 EnsureSpace ensure_space(this); 417 EnsureSpace ensure_space(this);
418 EMIT(0xFF); 418 EMIT(0xFF);
419 emit_operand(esi, src); 419 emit_operand(esi, src);
420 } 420 }
421 421
422 422
423 void Assembler::pop(Register dst) { 423 void Assembler::pop(Register dst) {
424 ASSERT(reloc_info_writer.last_pc() != NULL); 424 DCHECK(reloc_info_writer.last_pc() != NULL);
425 EnsureSpace ensure_space(this); 425 EnsureSpace ensure_space(this);
426 EMIT(0x58 | dst.code()); 426 EMIT(0x58 | dst.code());
427 } 427 }
428 428
429 429
430 void Assembler::pop(const Operand& dst) { 430 void Assembler::pop(const Operand& dst) {
431 EnsureSpace ensure_space(this); 431 EnsureSpace ensure_space(this);
432 EMIT(0x8F); 432 EMIT(0x8F);
433 emit_operand(eax, dst); 433 emit_operand(eax, dst);
434 } 434 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 662
663 663
664 void Assembler::add(const Operand& dst, Register src) { 664 void Assembler::add(const Operand& dst, Register src) {
665 EnsureSpace ensure_space(this); 665 EnsureSpace ensure_space(this);
666 EMIT(0x01); 666 EMIT(0x01);
667 emit_operand(src, dst); 667 emit_operand(src, dst);
668 } 668 }
669 669
670 670
671 void Assembler::add(const Operand& dst, const Immediate& x) { 671 void Assembler::add(const Operand& dst, const Immediate& x) {
672 ASSERT(reloc_info_writer.last_pc() != NULL); 672 DCHECK(reloc_info_writer.last_pc() != NULL);
673 EnsureSpace ensure_space(this); 673 EnsureSpace ensure_space(this);
674 emit_arith(0, dst, x); 674 emit_arith(0, dst, x);
675 } 675 }
676 676
677 677
678 void Assembler::and_(Register dst, int32_t imm32) { 678 void Assembler::and_(Register dst, int32_t imm32) {
679 and_(dst, Immediate(imm32)); 679 and_(dst, Immediate(imm32));
680 } 680 }
681 681
682 682
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 728
729 void Assembler::cmpb(Register reg, const Operand& op) { 729 void Assembler::cmpb(Register reg, const Operand& op) {
730 CHECK(reg.is_byte_register()); 730 CHECK(reg.is_byte_register());
731 EnsureSpace ensure_space(this); 731 EnsureSpace ensure_space(this);
732 EMIT(0x3A); 732 EMIT(0x3A);
733 emit_operand(reg, op); 733 emit_operand(reg, op);
734 } 734 }
735 735
736 736
737 void Assembler::cmpw(const Operand& op, Immediate imm16) { 737 void Assembler::cmpw(const Operand& op, Immediate imm16) {
738 ASSERT(imm16.is_int16()); 738 DCHECK(imm16.is_int16());
739 EnsureSpace ensure_space(this); 739 EnsureSpace ensure_space(this);
740 EMIT(0x66); 740 EMIT(0x66);
741 EMIT(0x81); 741 EMIT(0x81);
742 emit_operand(edi, op); 742 emit_operand(edi, op);
743 emit_w(imm16); 743 emit_w(imm16);
744 } 744 }
745 745
746 746
747 void Assembler::cmp(Register reg, int32_t imm32) { 747 void Assembler::cmp(Register reg, int32_t imm32) {
748 EnsureSpace ensure_space(this); 748 EnsureSpace ensure_space(this);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 948
949 void Assembler::or_(const Operand& dst, Register src) { 949 void Assembler::or_(const Operand& dst, Register src) {
950 EnsureSpace ensure_space(this); 950 EnsureSpace ensure_space(this);
951 EMIT(0x09); 951 EMIT(0x09);
952 emit_operand(src, dst); 952 emit_operand(src, dst);
953 } 953 }
954 954
955 955
956 void Assembler::rcl(Register dst, uint8_t imm8) { 956 void Assembler::rcl(Register dst, uint8_t imm8) {
957 EnsureSpace ensure_space(this); 957 EnsureSpace ensure_space(this);
958 ASSERT(is_uint5(imm8)); // illegal shift count 958 DCHECK(is_uint5(imm8)); // illegal shift count
959 if (imm8 == 1) { 959 if (imm8 == 1) {
960 EMIT(0xD1); 960 EMIT(0xD1);
961 EMIT(0xD0 | dst.code()); 961 EMIT(0xD0 | dst.code());
962 } else { 962 } else {
963 EMIT(0xC1); 963 EMIT(0xC1);
964 EMIT(0xD0 | dst.code()); 964 EMIT(0xD0 | dst.code());
965 EMIT(imm8); 965 EMIT(imm8);
966 } 966 }
967 } 967 }
968 968
969 969
970 void Assembler::rcr(Register dst, uint8_t imm8) { 970 void Assembler::rcr(Register dst, uint8_t imm8) {
971 EnsureSpace ensure_space(this); 971 EnsureSpace ensure_space(this);
972 ASSERT(is_uint5(imm8)); // illegal shift count 972 DCHECK(is_uint5(imm8)); // illegal shift count
973 if (imm8 == 1) { 973 if (imm8 == 1) {
974 EMIT(0xD1); 974 EMIT(0xD1);
975 EMIT(0xD8 | dst.code()); 975 EMIT(0xD8 | dst.code());
976 } else { 976 } else {
977 EMIT(0xC1); 977 EMIT(0xC1);
978 EMIT(0xD8 | dst.code()); 978 EMIT(0xD8 | dst.code());
979 EMIT(imm8); 979 EMIT(imm8);
980 } 980 }
981 } 981 }
982 982
983 983
984 void Assembler::ror(Register dst, uint8_t imm8) { 984 void Assembler::ror(Register dst, uint8_t imm8) {
985 EnsureSpace ensure_space(this); 985 EnsureSpace ensure_space(this);
986 ASSERT(is_uint5(imm8)); // illegal shift count 986 DCHECK(is_uint5(imm8)); // illegal shift count
987 if (imm8 == 1) { 987 if (imm8 == 1) {
988 EMIT(0xD1); 988 EMIT(0xD1);
989 EMIT(0xC8 | dst.code()); 989 EMIT(0xC8 | dst.code());
990 } else { 990 } else {
991 EMIT(0xC1); 991 EMIT(0xC1);
992 EMIT(0xC8 | dst.code()); 992 EMIT(0xC8 | dst.code());
993 EMIT(imm8); 993 EMIT(imm8);
994 } 994 }
995 } 995 }
996 996
997 997
998 void Assembler::ror_cl(Register dst) { 998 void Assembler::ror_cl(Register dst) {
999 EnsureSpace ensure_space(this); 999 EnsureSpace ensure_space(this);
1000 EMIT(0xD3); 1000 EMIT(0xD3);
1001 EMIT(0xC8 | dst.code()); 1001 EMIT(0xC8 | dst.code());
1002 } 1002 }
1003 1003
1004 1004
1005 void Assembler::sar(const Operand& dst, uint8_t imm8) { 1005 void Assembler::sar(const Operand& dst, uint8_t imm8) {
1006 EnsureSpace ensure_space(this); 1006 EnsureSpace ensure_space(this);
1007 ASSERT(is_uint5(imm8)); // illegal shift count 1007 DCHECK(is_uint5(imm8)); // illegal shift count
1008 if (imm8 == 1) { 1008 if (imm8 == 1) {
1009 EMIT(0xD1); 1009 EMIT(0xD1);
1010 emit_operand(edi, dst); 1010 emit_operand(edi, dst);
1011 } else { 1011 } else {
1012 EMIT(0xC1); 1012 EMIT(0xC1);
1013 emit_operand(edi, dst); 1013 emit_operand(edi, dst);
1014 EMIT(imm8); 1014 EMIT(imm8);
1015 } 1015 }
1016 } 1016 }
1017 1017
(...skipping 15 matching lines...) Expand all
1033 void Assembler::shld(Register dst, const Operand& src) { 1033 void Assembler::shld(Register dst, const Operand& src) {
1034 EnsureSpace ensure_space(this); 1034 EnsureSpace ensure_space(this);
1035 EMIT(0x0F); 1035 EMIT(0x0F);
1036 EMIT(0xA5); 1036 EMIT(0xA5);
1037 emit_operand(dst, src); 1037 emit_operand(dst, src);
1038 } 1038 }
1039 1039
1040 1040
1041 void Assembler::shl(const Operand& dst, uint8_t imm8) { 1041 void Assembler::shl(const Operand& dst, uint8_t imm8) {
1042 EnsureSpace ensure_space(this); 1042 EnsureSpace ensure_space(this);
1043 ASSERT(is_uint5(imm8)); // illegal shift count 1043 DCHECK(is_uint5(imm8)); // illegal shift count
1044 if (imm8 == 1) { 1044 if (imm8 == 1) {
1045 EMIT(0xD1); 1045 EMIT(0xD1);
1046 emit_operand(esp, dst); 1046 emit_operand(esp, dst);
1047 } else { 1047 } else {
1048 EMIT(0xC1); 1048 EMIT(0xC1);
1049 emit_operand(esp, dst); 1049 emit_operand(esp, dst);
1050 EMIT(imm8); 1050 EMIT(imm8);
1051 } 1051 }
1052 } 1052 }
1053 1053
1054 1054
1055 void Assembler::shl_cl(const Operand& dst) { 1055 void Assembler::shl_cl(const Operand& dst) {
1056 EnsureSpace ensure_space(this); 1056 EnsureSpace ensure_space(this);
1057 EMIT(0xD3); 1057 EMIT(0xD3);
1058 emit_operand(esp, dst); 1058 emit_operand(esp, dst);
1059 } 1059 }
1060 1060
1061 1061
1062 void Assembler::shrd(Register dst, const Operand& src) { 1062 void Assembler::shrd(Register dst, const Operand& src) {
1063 EnsureSpace ensure_space(this); 1063 EnsureSpace ensure_space(this);
1064 EMIT(0x0F); 1064 EMIT(0x0F);
1065 EMIT(0xAD); 1065 EMIT(0xAD);
1066 emit_operand(dst, src); 1066 emit_operand(dst, src);
1067 } 1067 }
1068 1068
1069 1069
1070 void Assembler::shr(const Operand& dst, uint8_t imm8) { 1070 void Assembler::shr(const Operand& dst, uint8_t imm8) {
1071 EnsureSpace ensure_space(this); 1071 EnsureSpace ensure_space(this);
1072 ASSERT(is_uint5(imm8)); // illegal shift count 1072 DCHECK(is_uint5(imm8)); // illegal shift count
1073 if (imm8 == 1) { 1073 if (imm8 == 1) {
1074 EMIT(0xD1); 1074 EMIT(0xD1);
1075 emit_operand(ebp, dst); 1075 emit_operand(ebp, dst);
1076 } else { 1076 } else {
1077 EMIT(0xC1); 1077 EMIT(0xC1);
1078 emit_operand(ebp, dst); 1078 emit_operand(ebp, dst);
1079 EMIT(imm8); 1079 EMIT(imm8);
1080 } 1080 }
1081 } 1081 }
1082 1082
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 1249
1250 1250
1251 void Assembler::nop() { 1251 void Assembler::nop() {
1252 EnsureSpace ensure_space(this); 1252 EnsureSpace ensure_space(this);
1253 EMIT(0x90); 1253 EMIT(0x90);
1254 } 1254 }
1255 1255
1256 1256
1257 void Assembler::ret(int imm16) { 1257 void Assembler::ret(int imm16) {
1258 EnsureSpace ensure_space(this); 1258 EnsureSpace ensure_space(this);
1259 ASSERT(is_uint16(imm16)); 1259 DCHECK(is_uint16(imm16));
1260 if (imm16 == 0) { 1260 if (imm16 == 0) {
1261 EMIT(0xC3); 1261 EMIT(0xC3);
1262 } else { 1262 } else {
1263 EMIT(0xC2); 1263 EMIT(0xC2);
1264 EMIT(imm16 & 0xFF); 1264 EMIT(imm16 & 0xFF);
1265 EMIT((imm16 >> 8) & 0xFF); 1265 EMIT((imm16 >> 8) & 0xFF);
1266 } 1266 }
1267 } 1267 }
1268 1268
1269 1269
(...skipping 24 matching lines...) Expand all
1294 disp.next(&l); 1294 disp.next(&l);
1295 } 1295 }
1296 } else { 1296 } else {
1297 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); 1297 PrintF("label in inconsistent state (pos = %d)\n", L->pos_);
1298 } 1298 }
1299 } 1299 }
1300 1300
1301 1301
1302 void Assembler::bind_to(Label* L, int pos) { 1302 void Assembler::bind_to(Label* L, int pos) {
1303 EnsureSpace ensure_space(this); 1303 EnsureSpace ensure_space(this);
1304 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position 1304 DCHECK(0 <= pos && pos <= pc_offset()); // must have a valid binding position
1305 while (L->is_linked()) { 1305 while (L->is_linked()) {
1306 Displacement disp = disp_at(L); 1306 Displacement disp = disp_at(L);
1307 int fixup_pos = L->pos(); 1307 int fixup_pos = L->pos();
1308 if (disp.type() == Displacement::CODE_RELATIVE) { 1308 if (disp.type() == Displacement::CODE_RELATIVE) {
1309 // Relative to Code* heap object pointer. 1309 // Relative to Code* heap object pointer.
1310 long_at_put(fixup_pos, pos + Code::kHeaderSize - kHeapObjectTag); 1310 long_at_put(fixup_pos, pos + Code::kHeaderSize - kHeapObjectTag);
1311 } else { 1311 } else {
1312 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { 1312 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) {
1313 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected 1313 DCHECK(byte_at(fixup_pos - 1) == 0xE9); // jmp expected
1314 } 1314 }
1315 // Relative address, relative to point after address. 1315 // Relative address, relative to point after address.
1316 int imm32 = pos - (fixup_pos + sizeof(int32_t)); 1316 int imm32 = pos - (fixup_pos + sizeof(int32_t));
1317 long_at_put(fixup_pos, imm32); 1317 long_at_put(fixup_pos, imm32);
1318 } 1318 }
1319 disp.next(L); 1319 disp.next(L);
1320 } 1320 }
1321 while (L->is_near_linked()) { 1321 while (L->is_near_linked()) {
1322 int fixup_pos = L->near_link_pos(); 1322 int fixup_pos = L->near_link_pos();
1323 int offset_to_next = 1323 int offset_to_next =
1324 static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos))); 1324 static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos)));
1325 ASSERT(offset_to_next <= 0); 1325 DCHECK(offset_to_next <= 0);
1326 // Relative address, relative to point after address. 1326 // Relative address, relative to point after address.
1327 int disp = pos - fixup_pos - sizeof(int8_t); 1327 int disp = pos - fixup_pos - sizeof(int8_t);
1328 CHECK(0 <= disp && disp <= 127); 1328 CHECK(0 <= disp && disp <= 127);
1329 set_byte_at(fixup_pos, disp); 1329 set_byte_at(fixup_pos, disp);
1330 if (offset_to_next < 0) { 1330 if (offset_to_next < 0) {
1331 L->link_to(fixup_pos + offset_to_next, Label::kNear); 1331 L->link_to(fixup_pos + offset_to_next, Label::kNear);
1332 } else { 1332 } else {
1333 L->UnuseNear(); 1333 L->UnuseNear();
1334 } 1334 }
1335 } 1335 }
1336 L->bind_to(pos); 1336 L->bind_to(pos);
1337 } 1337 }
1338 1338
1339 1339
1340 void Assembler::bind(Label* L) { 1340 void Assembler::bind(Label* L) {
1341 EnsureSpace ensure_space(this); 1341 EnsureSpace ensure_space(this);
1342 ASSERT(!L->is_bound()); // label can only be bound once 1342 DCHECK(!L->is_bound()); // label can only be bound once
1343 bind_to(L, pc_offset()); 1343 bind_to(L, pc_offset());
1344 } 1344 }
1345 1345
1346 1346
1347 void Assembler::call(Label* L) { 1347 void Assembler::call(Label* L) {
1348 positions_recorder()->WriteRecordedPositions(); 1348 positions_recorder()->WriteRecordedPositions();
1349 EnsureSpace ensure_space(this); 1349 EnsureSpace ensure_space(this);
1350 if (L->is_bound()) { 1350 if (L->is_bound()) {
1351 const int long_size = 5; 1351 const int long_size = 5;
1352 int offs = L->pos() - pc_offset(); 1352 int offs = L->pos() - pc_offset();
1353 ASSERT(offs <= 0); 1353 DCHECK(offs <= 0);
1354 // 1110 1000 #32-bit disp. 1354 // 1110 1000 #32-bit disp.
1355 EMIT(0xE8); 1355 EMIT(0xE8);
1356 emit(offs - long_size); 1356 emit(offs - long_size);
1357 } else { 1357 } else {
1358 // 1110 1000 #32-bit disp. 1358 // 1110 1000 #32-bit disp.
1359 EMIT(0xE8); 1359 EMIT(0xE8);
1360 emit_disp(L, Displacement::OTHER); 1360 emit_disp(L, Displacement::OTHER);
1361 } 1361 }
1362 } 1362 }
1363 1363
1364 1364
1365 void Assembler::call(byte* entry, RelocInfo::Mode rmode) { 1365 void Assembler::call(byte* entry, RelocInfo::Mode rmode) {
1366 positions_recorder()->WriteRecordedPositions(); 1366 positions_recorder()->WriteRecordedPositions();
1367 EnsureSpace ensure_space(this); 1367 EnsureSpace ensure_space(this);
1368 ASSERT(!RelocInfo::IsCodeTarget(rmode)); 1368 DCHECK(!RelocInfo::IsCodeTarget(rmode));
1369 EMIT(0xE8); 1369 EMIT(0xE8);
1370 if (RelocInfo::IsRuntimeEntry(rmode)) { 1370 if (RelocInfo::IsRuntimeEntry(rmode)) {
1371 emit(reinterpret_cast<uint32_t>(entry), rmode); 1371 emit(reinterpret_cast<uint32_t>(entry), rmode);
1372 } else { 1372 } else {
1373 emit(entry - (pc_ + sizeof(int32_t)), rmode); 1373 emit(entry - (pc_ + sizeof(int32_t)), rmode);
1374 } 1374 }
1375 } 1375 }
1376 1376
1377 1377
1378 int Assembler::CallSize(const Operand& adr) { 1378 int Assembler::CallSize(const Operand& adr) {
(...skipping 13 matching lines...) Expand all
1392 int Assembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode) { 1392 int Assembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode) {
1393 return 1 /* EMIT */ + sizeof(uint32_t) /* emit */; 1393 return 1 /* EMIT */ + sizeof(uint32_t) /* emit */;
1394 } 1394 }
1395 1395
1396 1396
1397 void Assembler::call(Handle<Code> code, 1397 void Assembler::call(Handle<Code> code,
1398 RelocInfo::Mode rmode, 1398 RelocInfo::Mode rmode,
1399 TypeFeedbackId ast_id) { 1399 TypeFeedbackId ast_id) {
1400 positions_recorder()->WriteRecordedPositions(); 1400 positions_recorder()->WriteRecordedPositions();
1401 EnsureSpace ensure_space(this); 1401 EnsureSpace ensure_space(this);
1402 ASSERT(RelocInfo::IsCodeTarget(rmode) 1402 DCHECK(RelocInfo::IsCodeTarget(rmode)
1403 || rmode == RelocInfo::CODE_AGE_SEQUENCE); 1403 || rmode == RelocInfo::CODE_AGE_SEQUENCE);
1404 EMIT(0xE8); 1404 EMIT(0xE8);
1405 emit(code, rmode, ast_id); 1405 emit(code, rmode, ast_id);
1406 } 1406 }
1407 1407
1408 1408
1409 void Assembler::jmp(Label* L, Label::Distance distance) { 1409 void Assembler::jmp(Label* L, Label::Distance distance) {
1410 EnsureSpace ensure_space(this); 1410 EnsureSpace ensure_space(this);
1411 if (L->is_bound()) { 1411 if (L->is_bound()) {
1412 const int short_size = 2; 1412 const int short_size = 2;
1413 const int long_size = 5; 1413 const int long_size = 5;
1414 int offs = L->pos() - pc_offset(); 1414 int offs = L->pos() - pc_offset();
1415 ASSERT(offs <= 0); 1415 DCHECK(offs <= 0);
1416 if (is_int8(offs - short_size)) { 1416 if (is_int8(offs - short_size)) {
1417 // 1110 1011 #8-bit disp. 1417 // 1110 1011 #8-bit disp.
1418 EMIT(0xEB); 1418 EMIT(0xEB);
1419 EMIT((offs - short_size) & 0xFF); 1419 EMIT((offs - short_size) & 0xFF);
1420 } else { 1420 } else {
1421 // 1110 1001 #32-bit disp. 1421 // 1110 1001 #32-bit disp.
1422 EMIT(0xE9); 1422 EMIT(0xE9);
1423 emit(offs - long_size); 1423 emit(offs - long_size);
1424 } 1424 }
1425 } else if (distance == Label::kNear) { 1425 } else if (distance == Label::kNear) {
1426 EMIT(0xEB); 1426 EMIT(0xEB);
1427 emit_near_disp(L); 1427 emit_near_disp(L);
1428 } else { 1428 } else {
1429 // 1110 1001 #32-bit disp. 1429 // 1110 1001 #32-bit disp.
1430 EMIT(0xE9); 1430 EMIT(0xE9);
1431 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); 1431 emit_disp(L, Displacement::UNCONDITIONAL_JUMP);
1432 } 1432 }
1433 } 1433 }
1434 1434
1435 1435
1436 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { 1436 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) {
1437 EnsureSpace ensure_space(this); 1437 EnsureSpace ensure_space(this);
1438 ASSERT(!RelocInfo::IsCodeTarget(rmode)); 1438 DCHECK(!RelocInfo::IsCodeTarget(rmode));
1439 EMIT(0xE9); 1439 EMIT(0xE9);
1440 if (RelocInfo::IsRuntimeEntry(rmode)) { 1440 if (RelocInfo::IsRuntimeEntry(rmode)) {
1441 emit(reinterpret_cast<uint32_t>(entry), rmode); 1441 emit(reinterpret_cast<uint32_t>(entry), rmode);
1442 } else { 1442 } else {
1443 emit(entry - (pc_ + sizeof(int32_t)), rmode); 1443 emit(entry - (pc_ + sizeof(int32_t)), rmode);
1444 } 1444 }
1445 } 1445 }
1446 1446
1447 1447
1448 void Assembler::jmp(const Operand& adr) { 1448 void Assembler::jmp(const Operand& adr) {
1449 EnsureSpace ensure_space(this); 1449 EnsureSpace ensure_space(this);
1450 EMIT(0xFF); 1450 EMIT(0xFF);
1451 emit_operand(esp, adr); 1451 emit_operand(esp, adr);
1452 } 1452 }
1453 1453
1454 1454
1455 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { 1455 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) {
1456 EnsureSpace ensure_space(this); 1456 EnsureSpace ensure_space(this);
1457 ASSERT(RelocInfo::IsCodeTarget(rmode)); 1457 DCHECK(RelocInfo::IsCodeTarget(rmode));
1458 EMIT(0xE9); 1458 EMIT(0xE9);
1459 emit(code, rmode); 1459 emit(code, rmode);
1460 } 1460 }
1461 1461
1462 1462
1463 void Assembler::j(Condition cc, Label* L, Label::Distance distance) { 1463 void Assembler::j(Condition cc, Label* L, Label::Distance distance) {
1464 EnsureSpace ensure_space(this); 1464 EnsureSpace ensure_space(this);
1465 ASSERT(0 <= cc && static_cast<int>(cc) < 16); 1465 DCHECK(0 <= cc && static_cast<int>(cc) < 16);
1466 if (L->is_bound()) { 1466 if (L->is_bound()) {
1467 const int short_size = 2; 1467 const int short_size = 2;
1468 const int long_size = 6; 1468 const int long_size = 6;
1469 int offs = L->pos() - pc_offset(); 1469 int offs = L->pos() - pc_offset();
1470 ASSERT(offs <= 0); 1470 DCHECK(offs <= 0);
1471 if (is_int8(offs - short_size)) { 1471 if (is_int8(offs - short_size)) {
1472 // 0111 tttn #8-bit disp 1472 // 0111 tttn #8-bit disp
1473 EMIT(0x70 | cc); 1473 EMIT(0x70 | cc);
1474 EMIT((offs - short_size) & 0xFF); 1474 EMIT((offs - short_size) & 0xFF);
1475 } else { 1475 } else {
1476 // 0000 1111 1000 tttn #32-bit disp 1476 // 0000 1111 1000 tttn #32-bit disp
1477 EMIT(0x0F); 1477 EMIT(0x0F);
1478 EMIT(0x80 | cc); 1478 EMIT(0x80 | cc);
1479 emit(offs - long_size); 1479 emit(offs - long_size);
1480 } 1480 }
1481 } else if (distance == Label::kNear) { 1481 } else if (distance == Label::kNear) {
1482 EMIT(0x70 | cc); 1482 EMIT(0x70 | cc);
1483 emit_near_disp(L); 1483 emit_near_disp(L);
1484 } else { 1484 } else {
1485 // 0000 1111 1000 tttn #32-bit disp 1485 // 0000 1111 1000 tttn #32-bit disp
1486 // Note: could eliminate cond. jumps to this jump if condition 1486 // Note: could eliminate cond. jumps to this jump if condition
1487 // is the same however, seems to be rather unlikely case. 1487 // is the same however, seems to be rather unlikely case.
1488 EMIT(0x0F); 1488 EMIT(0x0F);
1489 EMIT(0x80 | cc); 1489 EMIT(0x80 | cc);
1490 emit_disp(L, Displacement::OTHER); 1490 emit_disp(L, Displacement::OTHER);
1491 } 1491 }
1492 } 1492 }
1493 1493
1494 1494
1495 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode) { 1495 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode) {
1496 EnsureSpace ensure_space(this); 1496 EnsureSpace ensure_space(this);
1497 ASSERT((0 <= cc) && (static_cast<int>(cc) < 16)); 1497 DCHECK((0 <= cc) && (static_cast<int>(cc) < 16));
1498 // 0000 1111 1000 tttn #32-bit disp. 1498 // 0000 1111 1000 tttn #32-bit disp.
1499 EMIT(0x0F); 1499 EMIT(0x0F);
1500 EMIT(0x80 | cc); 1500 EMIT(0x80 | cc);
1501 if (RelocInfo::IsRuntimeEntry(rmode)) { 1501 if (RelocInfo::IsRuntimeEntry(rmode)) {
1502 emit(reinterpret_cast<uint32_t>(entry), rmode); 1502 emit(reinterpret_cast<uint32_t>(entry), rmode);
1503 } else { 1503 } else {
1504 emit(entry - (pc_ + sizeof(int32_t)), rmode); 1504 emit(entry - (pc_ + sizeof(int32_t)), rmode);
1505 } 1505 }
1506 } 1506 }
1507 1507
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 1614
1615 1615
1616 void Assembler::fistp_s(const Operand& adr) { 1616 void Assembler::fistp_s(const Operand& adr) {
1617 EnsureSpace ensure_space(this); 1617 EnsureSpace ensure_space(this);
1618 EMIT(0xDB); 1618 EMIT(0xDB);
1619 emit_operand(ebx, adr); 1619 emit_operand(ebx, adr);
1620 } 1620 }
1621 1621
1622 1622
1623 void Assembler::fisttp_s(const Operand& adr) { 1623 void Assembler::fisttp_s(const Operand& adr) {
1624 ASSERT(IsEnabled(SSE3)); 1624 DCHECK(IsEnabled(SSE3));
1625 EnsureSpace ensure_space(this); 1625 EnsureSpace ensure_space(this);
1626 EMIT(0xDB); 1626 EMIT(0xDB);
1627 emit_operand(ecx, adr); 1627 emit_operand(ecx, adr);
1628 } 1628 }
1629 1629
1630 1630
1631 void Assembler::fisttp_d(const Operand& adr) { 1631 void Assembler::fisttp_d(const Operand& adr) {
1632 ASSERT(IsEnabled(SSE3)); 1632 DCHECK(IsEnabled(SSE3));
1633 EnsureSpace ensure_space(this); 1633 EnsureSpace ensure_space(this);
1634 EMIT(0xDD); 1634 EMIT(0xDD);
1635 emit_operand(ecx, adr); 1635 emit_operand(ecx, adr);
1636 } 1636 }
1637 1637
1638 1638
1639 void Assembler::fist_s(const Operand& adr) { 1639 void Assembler::fist_s(const Operand& adr) {
1640 EnsureSpace ensure_space(this); 1640 EnsureSpace ensure_space(this);
1641 EMIT(0xDB); 1641 EMIT(0xDB);
1642 emit_operand(edx, adr); 1642 emit_operand(edx, adr);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 } 1899 }
1900 1900
1901 1901
1902 void Assembler::sahf() { 1902 void Assembler::sahf() {
1903 EnsureSpace ensure_space(this); 1903 EnsureSpace ensure_space(this);
1904 EMIT(0x9E); 1904 EMIT(0x9E);
1905 } 1905 }
1906 1906
1907 1907
1908 void Assembler::setcc(Condition cc, Register reg) { 1908 void Assembler::setcc(Condition cc, Register reg) {
1909 ASSERT(reg.is_byte_register()); 1909 DCHECK(reg.is_byte_register());
1910 EnsureSpace ensure_space(this); 1910 EnsureSpace ensure_space(this);
1911 EMIT(0x0F); 1911 EMIT(0x0F);
1912 EMIT(0x90 | cc); 1912 EMIT(0x90 | cc);
1913 EMIT(0xC0 | reg.code()); 1913 EMIT(0xC0 | reg.code());
1914 } 1914 }
1915 1915
1916 1916
1917 void Assembler::cvttss2si(Register dst, const Operand& src) { 1917 void Assembler::cvttss2si(Register dst, const Operand& src) {
1918 EnsureSpace ensure_space(this); 1918 EnsureSpace ensure_space(this);
1919 EMIT(0xF3); 1919 EMIT(0xF3);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 void Assembler::ucomisd(XMMRegister dst, const Operand& src) { 2126 void Assembler::ucomisd(XMMRegister dst, const Operand& src) {
2127 EnsureSpace ensure_space(this); 2127 EnsureSpace ensure_space(this);
2128 EMIT(0x66); 2128 EMIT(0x66);
2129 EMIT(0x0F); 2129 EMIT(0x0F);
2130 EMIT(0x2E); 2130 EMIT(0x2E);
2131 emit_sse_operand(dst, src); 2131 emit_sse_operand(dst, src);
2132 } 2132 }
2133 2133
2134 2134
2135 void Assembler::roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode) { 2135 void Assembler::roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode) {
2136 ASSERT(IsEnabled(SSE4_1)); 2136 DCHECK(IsEnabled(SSE4_1));
2137 EnsureSpace ensure_space(this); 2137 EnsureSpace ensure_space(this);
2138 EMIT(0x66); 2138 EMIT(0x66);
2139 EMIT(0x0F); 2139 EMIT(0x0F);
2140 EMIT(0x3A); 2140 EMIT(0x3A);
2141 EMIT(0x0B); 2141 EMIT(0x0B);
2142 emit_sse_operand(dst, src); 2142 emit_sse_operand(dst, src);
2143 // Mask precision exeption. 2143 // Mask precision exeption.
2144 EMIT(static_cast<byte>(mode) | 0x8); 2144 EMIT(static_cast<byte>(mode) | 0x8);
2145 } 2145 }
2146 2146
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 2183
2184 void Assembler::movaps(XMMRegister dst, XMMRegister src) { 2184 void Assembler::movaps(XMMRegister dst, XMMRegister src) {
2185 EnsureSpace ensure_space(this); 2185 EnsureSpace ensure_space(this);
2186 EMIT(0x0F); 2186 EMIT(0x0F);
2187 EMIT(0x28); 2187 EMIT(0x28);
2188 emit_sse_operand(dst, src); 2188 emit_sse_operand(dst, src);
2189 } 2189 }
2190 2190
2191 2191
2192 void Assembler::shufps(XMMRegister dst, XMMRegister src, byte imm8) { 2192 void Assembler::shufps(XMMRegister dst, XMMRegister src, byte imm8) {
2193 ASSERT(is_uint8(imm8)); 2193 DCHECK(is_uint8(imm8));
2194 EnsureSpace ensure_space(this); 2194 EnsureSpace ensure_space(this);
2195 EMIT(0x0F); 2195 EMIT(0x0F);
2196 EMIT(0xC6); 2196 EMIT(0xC6);
2197 emit_sse_operand(dst, src); 2197 emit_sse_operand(dst, src);
2198 EMIT(imm8); 2198 EMIT(imm8);
2199 } 2199 }
2200 2200
2201 2201
2202 void Assembler::movdqa(const Operand& dst, XMMRegister src) { 2202 void Assembler::movdqa(const Operand& dst, XMMRegister src) {
2203 EnsureSpace ensure_space(this); 2203 EnsureSpace ensure_space(this);
(...skipping 25 matching lines...) Expand all
2229 void Assembler::movdqu(XMMRegister dst, const Operand& src) { 2229 void Assembler::movdqu(XMMRegister dst, const Operand& src) {
2230 EnsureSpace ensure_space(this); 2230 EnsureSpace ensure_space(this);
2231 EMIT(0xF3); 2231 EMIT(0xF3);
2232 EMIT(0x0F); 2232 EMIT(0x0F);
2233 EMIT(0x6F); 2233 EMIT(0x6F);
2234 emit_sse_operand(dst, src); 2234 emit_sse_operand(dst, src);
2235 } 2235 }
2236 2236
2237 2237
2238 void Assembler::movntdqa(XMMRegister dst, const Operand& src) { 2238 void Assembler::movntdqa(XMMRegister dst, const Operand& src) {
2239 ASSERT(IsEnabled(SSE4_1)); 2239 DCHECK(IsEnabled(SSE4_1));
2240 EnsureSpace ensure_space(this); 2240 EnsureSpace ensure_space(this);
2241 EMIT(0x66); 2241 EMIT(0x66);
2242 EMIT(0x0F); 2242 EMIT(0x0F);
2243 EMIT(0x38); 2243 EMIT(0x38);
2244 EMIT(0x2A); 2244 EMIT(0x2A);
2245 emit_sse_operand(dst, src); 2245 emit_sse_operand(dst, src);
2246 } 2246 }
2247 2247
2248 2248
2249 void Assembler::movntdq(const Operand& dst, XMMRegister src) { 2249 void Assembler::movntdq(const Operand& dst, XMMRegister src) {
2250 EnsureSpace ensure_space(this); 2250 EnsureSpace ensure_space(this);
2251 EMIT(0x66); 2251 EMIT(0x66);
2252 EMIT(0x0F); 2252 EMIT(0x0F);
2253 EMIT(0xE7); 2253 EMIT(0xE7);
2254 emit_sse_operand(src, dst); 2254 emit_sse_operand(src, dst);
2255 } 2255 }
2256 2256
2257 2257
2258 void Assembler::prefetch(const Operand& src, int level) { 2258 void Assembler::prefetch(const Operand& src, int level) {
2259 ASSERT(is_uint2(level)); 2259 DCHECK(is_uint2(level));
2260 EnsureSpace ensure_space(this); 2260 EnsureSpace ensure_space(this);
2261 EMIT(0x0F); 2261 EMIT(0x0F);
2262 EMIT(0x18); 2262 EMIT(0x18);
2263 // Emit hint number in Reg position of RegR/M. 2263 // Emit hint number in Reg position of RegR/M.
2264 XMMRegister code = XMMRegister::from_code(level); 2264 XMMRegister code = XMMRegister::from_code(level);
2265 emit_sse_operand(code, src); 2265 emit_sse_operand(code, src);
2266 } 2266 }
2267 2267
2268 2268
2269 void Assembler::movsd(const Operand& dst, XMMRegister src ) { 2269 void Assembler::movsd(const Operand& dst, XMMRegister src ) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 void Assembler::movd(const Operand& dst, XMMRegister src) { 2314 void Assembler::movd(const Operand& dst, XMMRegister src) {
2315 EnsureSpace ensure_space(this); 2315 EnsureSpace ensure_space(this);
2316 EMIT(0x66); 2316 EMIT(0x66);
2317 EMIT(0x0F); 2317 EMIT(0x0F);
2318 EMIT(0x7E); 2318 EMIT(0x7E);
2319 emit_sse_operand(src, dst); 2319 emit_sse_operand(src, dst);
2320 } 2320 }
2321 2321
2322 2322
2323 void Assembler::extractps(Register dst, XMMRegister src, byte imm8) { 2323 void Assembler::extractps(Register dst, XMMRegister src, byte imm8) {
2324 ASSERT(IsEnabled(SSE4_1)); 2324 DCHECK(IsEnabled(SSE4_1));
2325 ASSERT(is_uint8(imm8)); 2325 DCHECK(is_uint8(imm8));
2326 EnsureSpace ensure_space(this); 2326 EnsureSpace ensure_space(this);
2327 EMIT(0x66); 2327 EMIT(0x66);
2328 EMIT(0x0F); 2328 EMIT(0x0F);
2329 EMIT(0x3A); 2329 EMIT(0x3A);
2330 EMIT(0x17); 2330 EMIT(0x17);
2331 emit_sse_operand(src, dst); 2331 emit_sse_operand(src, dst);
2332 EMIT(imm8); 2332 EMIT(imm8);
2333 } 2333 }
2334 2334
2335 2335
(...skipping 18 matching lines...) Expand all
2354 void Assembler::por(XMMRegister dst, XMMRegister src) { 2354 void Assembler::por(XMMRegister dst, XMMRegister src) {
2355 EnsureSpace ensure_space(this); 2355 EnsureSpace ensure_space(this);
2356 EMIT(0x66); 2356 EMIT(0x66);
2357 EMIT(0x0F); 2357 EMIT(0x0F);
2358 EMIT(0xEB); 2358 EMIT(0xEB);
2359 emit_sse_operand(dst, src); 2359 emit_sse_operand(dst, src);
2360 } 2360 }
2361 2361
2362 2362
2363 void Assembler::ptest(XMMRegister dst, XMMRegister src) { 2363 void Assembler::ptest(XMMRegister dst, XMMRegister src) {
2364 ASSERT(IsEnabled(SSE4_1)); 2364 DCHECK(IsEnabled(SSE4_1));
2365 EnsureSpace ensure_space(this); 2365 EnsureSpace ensure_space(this);
2366 EMIT(0x66); 2366 EMIT(0x66);
2367 EMIT(0x0F); 2367 EMIT(0x0F);
2368 EMIT(0x38); 2368 EMIT(0x38);
2369 EMIT(0x17); 2369 EMIT(0x17);
2370 emit_sse_operand(dst, src); 2370 emit_sse_operand(dst, src);
2371 } 2371 }
2372 2372
2373 2373
2374 void Assembler::psllq(XMMRegister reg, int8_t shift) { 2374 void Assembler::psllq(XMMRegister reg, int8_t shift) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 EnsureSpace ensure_space(this); 2413 EnsureSpace ensure_space(this);
2414 EMIT(0x66); 2414 EMIT(0x66);
2415 EMIT(0x0F); 2415 EMIT(0x0F);
2416 EMIT(0x70); 2416 EMIT(0x70);
2417 emit_sse_operand(dst, src); 2417 emit_sse_operand(dst, src);
2418 EMIT(shuffle); 2418 EMIT(shuffle);
2419 } 2419 }
2420 2420
2421 2421
2422 void Assembler::pextrd(const Operand& dst, XMMRegister src, int8_t offset) { 2422 void Assembler::pextrd(const Operand& dst, XMMRegister src, int8_t offset) {
2423 ASSERT(IsEnabled(SSE4_1)); 2423 DCHECK(IsEnabled(SSE4_1));
2424 EnsureSpace ensure_space(this); 2424 EnsureSpace ensure_space(this);
2425 EMIT(0x66); 2425 EMIT(0x66);
2426 EMIT(0x0F); 2426 EMIT(0x0F);
2427 EMIT(0x3A); 2427 EMIT(0x3A);
2428 EMIT(0x16); 2428 EMIT(0x16);
2429 emit_sse_operand(src, dst); 2429 emit_sse_operand(src, dst);
2430 EMIT(offset); 2430 EMIT(offset);
2431 } 2431 }
2432 2432
2433 2433
2434 void Assembler::pinsrd(XMMRegister dst, const Operand& src, int8_t offset) { 2434 void Assembler::pinsrd(XMMRegister dst, const Operand& src, int8_t offset) {
2435 ASSERT(IsEnabled(SSE4_1)); 2435 DCHECK(IsEnabled(SSE4_1));
2436 EnsureSpace ensure_space(this); 2436 EnsureSpace ensure_space(this);
2437 EMIT(0x66); 2437 EMIT(0x66);
2438 EMIT(0x0F); 2438 EMIT(0x0F);
2439 EMIT(0x3A); 2439 EMIT(0x3A);
2440 EMIT(0x22); 2440 EMIT(0x22);
2441 emit_sse_operand(dst, src); 2441 emit_sse_operand(dst, src);
2442 EMIT(offset); 2442 EMIT(offset);
2443 } 2443 }
2444 2444
2445 2445
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 2485
2486 void Assembler::RecordComment(const char* msg, bool force) { 2486 void Assembler::RecordComment(const char* msg, bool force) {
2487 if (FLAG_code_comments || force) { 2487 if (FLAG_code_comments || force) {
2488 EnsureSpace ensure_space(this); 2488 EnsureSpace ensure_space(this);
2489 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); 2489 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg));
2490 } 2490 }
2491 } 2491 }
2492 2492
2493 2493
2494 void Assembler::GrowBuffer() { 2494 void Assembler::GrowBuffer() {
2495 ASSERT(buffer_overflow()); 2495 DCHECK(buffer_overflow());
2496 if (!own_buffer_) FATAL("external code buffer is too small"); 2496 if (!own_buffer_) FATAL("external code buffer is too small");
2497 2497
2498 // Compute new buffer size. 2498 // Compute new buffer size.
2499 CodeDesc desc; // the new buffer 2499 CodeDesc desc; // the new buffer
2500 if (buffer_size_ < 4*KB) { 2500 if (buffer_size_ < 4*KB) {
2501 desc.buffer_size = 4*KB; 2501 desc.buffer_size = 4*KB;
2502 } else { 2502 } else {
2503 desc.buffer_size = 2*buffer_size_; 2503 desc.buffer_size = 2*buffer_size_;
2504 } 2504 }
2505 // Some internal data structures overflow for very large buffers, 2505 // Some internal data structures overflow for very large buffers,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 for (RelocIterator it(desc); !it.done(); it.next()) { 2544 for (RelocIterator it(desc); !it.done(); it.next()) {
2545 RelocInfo::Mode rmode = it.rinfo()->rmode(); 2545 RelocInfo::Mode rmode = it.rinfo()->rmode();
2546 if (rmode == RelocInfo::INTERNAL_REFERENCE) { 2546 if (rmode == RelocInfo::INTERNAL_REFERENCE) {
2547 int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc()); 2547 int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
2548 if (*p != 0) { // 0 means uninitialized. 2548 if (*p != 0) { // 0 means uninitialized.
2549 *p += pc_delta; 2549 *p += pc_delta;
2550 } 2550 }
2551 } 2551 }
2552 } 2552 }
2553 2553
2554 ASSERT(!buffer_overflow()); 2554 DCHECK(!buffer_overflow());
2555 } 2555 }
2556 2556
2557 2557
2558 void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) { 2558 void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) {
2559 ASSERT(is_uint8(op1) && is_uint8(op2)); // wrong opcode 2559 DCHECK(is_uint8(op1) && is_uint8(op2)); // wrong opcode
2560 ASSERT(is_uint8(imm8)); 2560 DCHECK(is_uint8(imm8));
2561 ASSERT((op1 & 0x01) == 0); // should be 8bit operation 2561 DCHECK((op1 & 0x01) == 0); // should be 8bit operation
2562 EMIT(op1); 2562 EMIT(op1);
2563 EMIT(op2 | dst.code()); 2563 EMIT(op2 | dst.code());
2564 EMIT(imm8); 2564 EMIT(imm8);
2565 } 2565 }
2566 2566
2567 2567
2568 void Assembler::emit_arith(int sel, Operand dst, const Immediate& x) { 2568 void Assembler::emit_arith(int sel, Operand dst, const Immediate& x) {
2569 ASSERT((0 <= sel) && (sel <= 7)); 2569 DCHECK((0 <= sel) && (sel <= 7));
2570 Register ireg = { sel }; 2570 Register ireg = { sel };
2571 if (x.is_int8()) { 2571 if (x.is_int8()) {
2572 EMIT(0x83); // using a sign-extended 8-bit immediate. 2572 EMIT(0x83); // using a sign-extended 8-bit immediate.
2573 emit_operand(ireg, dst); 2573 emit_operand(ireg, dst);
2574 EMIT(x.x_ & 0xFF); 2574 EMIT(x.x_ & 0xFF);
2575 } else if (dst.is_reg(eax)) { 2575 } else if (dst.is_reg(eax)) {
2576 EMIT((sel << 3) | 0x05); // short form if the destination is eax. 2576 EMIT((sel << 3) | 0x05); // short form if the destination is eax.
2577 emit(x); 2577 emit(x);
2578 } else { 2578 } else {
2579 EMIT(0x81); // using a literal 32-bit immediate. 2579 EMIT(0x81); // using a literal 32-bit immediate.
2580 emit_operand(ireg, dst); 2580 emit_operand(ireg, dst);
2581 emit(x); 2581 emit(x);
2582 } 2582 }
2583 } 2583 }
2584 2584
2585 2585
2586 void Assembler::emit_operand(Register reg, const Operand& adr) { 2586 void Assembler::emit_operand(Register reg, const Operand& adr) {
2587 const unsigned length = adr.len_; 2587 const unsigned length = adr.len_;
2588 ASSERT(length > 0); 2588 DCHECK(length > 0);
2589 2589
2590 // Emit updated ModRM byte containing the given register. 2590 // Emit updated ModRM byte containing the given register.
2591 pc_[0] = (adr.buf_[0] & ~0x38) | (reg.code() << 3); 2591 pc_[0] = (adr.buf_[0] & ~0x38) | (reg.code() << 3);
2592 2592
2593 // Emit the rest of the encoded operand. 2593 // Emit the rest of the encoded operand.
2594 for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i]; 2594 for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i];
2595 pc_ += length; 2595 pc_ += length;
2596 2596
2597 // Emit relocation information if necessary. 2597 // Emit relocation information if necessary.
2598 if (length >= sizeof(int32_t) && !RelocInfo::IsNone(adr.rmode_)) { 2598 if (length >= sizeof(int32_t) && !RelocInfo::IsNone(adr.rmode_)) {
2599 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32 2599 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32
2600 RecordRelocInfo(adr.rmode_); 2600 RecordRelocInfo(adr.rmode_);
2601 pc_ += sizeof(int32_t); 2601 pc_ += sizeof(int32_t);
2602 } 2602 }
2603 } 2603 }
2604 2604
2605 2605
2606 void Assembler::emit_farith(int b1, int b2, int i) { 2606 void Assembler::emit_farith(int b1, int b2, int i) {
2607 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode 2607 DCHECK(is_uint8(b1) && is_uint8(b2)); // wrong opcode
2608 ASSERT(0 <= i && i < 8); // illegal stack offset 2608 DCHECK(0 <= i && i < 8); // illegal stack offset
2609 EMIT(b1); 2609 EMIT(b1);
2610 EMIT(b2 + i); 2610 EMIT(b2 + i);
2611 } 2611 }
2612 2612
2613 2613
2614 void Assembler::db(uint8_t data) { 2614 void Assembler::db(uint8_t data) {
2615 EnsureSpace ensure_space(this); 2615 EnsureSpace ensure_space(this);
2616 EMIT(data); 2616 EMIT(data);
2617 } 2617 }
2618 2618
2619 2619
2620 void Assembler::dd(uint32_t data) { 2620 void Assembler::dd(uint32_t data) {
2621 EnsureSpace ensure_space(this); 2621 EnsureSpace ensure_space(this);
2622 emit(data); 2622 emit(data);
2623 } 2623 }
2624 2624
2625 2625
2626 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { 2626 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
2627 ASSERT(!RelocInfo::IsNone(rmode)); 2627 DCHECK(!RelocInfo::IsNone(rmode));
2628 // Don't record external references unless the heap will be serialized. 2628 // Don't record external references unless the heap will be serialized.
2629 if (rmode == RelocInfo::EXTERNAL_REFERENCE && 2629 if (rmode == RelocInfo::EXTERNAL_REFERENCE &&
2630 !serializer_enabled() && !emit_debug_code()) { 2630 !serializer_enabled() && !emit_debug_code()) {
2631 return; 2631 return;
2632 } 2632 }
2633 RelocInfo rinfo(pc_, rmode, data, NULL); 2633 RelocInfo rinfo(pc_, rmode, data, NULL);
2634 reloc_info_writer.Write(&rinfo); 2634 reloc_info_writer.Write(&rinfo);
2635 } 2635 }
2636 2636
2637 2637
2638 Handle<ConstantPoolArray> Assembler::NewConstantPool(Isolate* isolate) { 2638 Handle<ConstantPoolArray> Assembler::NewConstantPool(Isolate* isolate) {
2639 // No out-of-line constant pool support. 2639 // No out-of-line constant pool support.
2640 ASSERT(!FLAG_enable_ool_constant_pool); 2640 DCHECK(!FLAG_enable_ool_constant_pool);
2641 return isolate->factory()->empty_constant_pool_array(); 2641 return isolate->factory()->empty_constant_pool_array();
2642 } 2642 }
2643 2643
2644 2644
2645 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) { 2645 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) {
2646 // No out-of-line constant pool support. 2646 // No out-of-line constant pool support.
2647 ASSERT(!FLAG_enable_ool_constant_pool); 2647 DCHECK(!FLAG_enable_ool_constant_pool);
2648 return; 2648 return;
2649 } 2649 }
2650 2650
2651 2651
2652 #ifdef GENERATED_CODE_COVERAGE 2652 #ifdef GENERATED_CODE_COVERAGE
2653 static FILE* coverage_log = NULL; 2653 static FILE* coverage_log = NULL;
2654 2654
2655 2655
2656 static void InitCoverageLog() { 2656 static void InitCoverageLog() {
2657 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG"); 2657 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG");
(...skipping 12 matching lines...) Expand all
2670 fprintf(coverage_log, "%s\n", file_line); 2670 fprintf(coverage_log, "%s\n", file_line);
2671 fflush(coverage_log); 2671 fflush(coverage_log);
2672 } 2672 }
2673 } 2673 }
2674 2674
2675 #endif 2675 #endif
2676 2676
2677 } } // namespace v8::internal 2677 } } // namespace v8::internal
2678 2678
2679 #endif // V8_TARGET_ARCH_IA32 2679 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/ia32/assembler-ia32-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698