OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 } | 411 } |
412 L->bind_to(pos); | 412 L->bind_to(pos); |
413 } | 413 } |
414 | 414 |
415 | 415 |
416 void Assembler::bind(Label* L) { | 416 void Assembler::bind(Label* L) { |
417 bind_to(L, pc_offset()); | 417 bind_to(L, pc_offset()); |
418 } | 418 } |
419 | 419 |
420 | 420 |
| 421 void Assembler::bind(NearLabel* L) { |
| 422 ASSERT(!L->is_bound()); |
| 423 last_pc_ = NULL; |
| 424 while (L->unresolved_branches_ > 0) { |
| 425 int branch_pos = L->unresolved_positions_[L->unresolved_branches_ - 1]; |
| 426 int disp = pc_offset() - branch_pos; |
| 427 ASSERT(is_int8(disp)); |
| 428 set_byte_at(branch_pos - sizeof(int8_t), disp); |
| 429 L->unresolved_branches_--; |
| 430 } |
| 431 L->bind_to(pc_offset()); |
| 432 } |
| 433 |
| 434 |
421 void Assembler::GrowBuffer() { | 435 void Assembler::GrowBuffer() { |
422 ASSERT(buffer_overflow()); | 436 ASSERT(buffer_overflow()); |
423 if (!own_buffer_) FATAL("external code buffer is too small"); | 437 if (!own_buffer_) FATAL("external code buffer is too small"); |
424 | 438 |
425 // Compute new buffer size. | 439 // Compute new buffer size. |
426 CodeDesc desc; // the new buffer | 440 CodeDesc desc; // the new buffer |
427 if (buffer_size_ < 4*KB) { | 441 if (buffer_size_ < 4*KB) { |
428 desc.buffer_size = 4*KB; | 442 desc.buffer_size = 4*KB; |
429 } else { | 443 } else { |
430 desc.buffer_size = 2*buffer_size_; | 444 desc.buffer_size = 2*buffer_size_; |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 EnsureSpace ensure_space(this); | 1234 EnsureSpace ensure_space(this); |
1221 last_pc_ = pc_; | 1235 last_pc_ = pc_; |
1222 ASSERT(is_uint4(cc)); | 1236 ASSERT(is_uint4(cc)); |
1223 // 0000 1111 1000 tttn #32-bit disp. | 1237 // 0000 1111 1000 tttn #32-bit disp. |
1224 emit(0x0F); | 1238 emit(0x0F); |
1225 emit(0x80 | cc); | 1239 emit(0x80 | cc); |
1226 emit_code_target(target, rmode); | 1240 emit_code_target(target, rmode); |
1227 } | 1241 } |
1228 | 1242 |
1229 | 1243 |
| 1244 void Assembler::j(Condition cc, NearLabel* L, Hint hint) { |
| 1245 EnsureSpace ensure_space(this); |
| 1246 last_pc_ = pc_; |
| 1247 ASSERT(0 <= cc && cc < 16); |
| 1248 if (FLAG_emit_branch_hints && hint != no_hint) emit(hint); |
| 1249 if (L->is_bound()) { |
| 1250 const int short_size = 2; |
| 1251 int offs = L->pos() - pc_offset(); |
| 1252 ASSERT(offs <= 0); |
| 1253 ASSERT(is_int8(offs - short_size)); |
| 1254 // 0111 tttn #8-bit disp |
| 1255 emit(0x70 | cc); |
| 1256 emit((offs - short_size) & 0xFF); |
| 1257 } else { |
| 1258 emit(0x70 | cc); |
| 1259 emit(0x00); // The displacement will be resolved later. |
| 1260 L->link_to(pc_offset()); |
| 1261 } |
| 1262 } |
| 1263 |
| 1264 |
1230 void Assembler::jmp(Label* L) { | 1265 void Assembler::jmp(Label* L) { |
1231 EnsureSpace ensure_space(this); | 1266 EnsureSpace ensure_space(this); |
1232 last_pc_ = pc_; | 1267 last_pc_ = pc_; |
1233 const int short_size = sizeof(int8_t); | 1268 const int short_size = sizeof(int8_t); |
1234 const int long_size = sizeof(int32_t); | 1269 const int long_size = sizeof(int32_t); |
1235 if (L->is_bound()) { | 1270 if (L->is_bound()) { |
1236 int offs = L->pos() - pc_offset() - 1; | 1271 int offs = L->pos() - pc_offset() - 1; |
1237 ASSERT(offs <= 0); | 1272 ASSERT(offs <= 0); |
1238 if (is_int8(offs - short_size)) { | 1273 if (is_int8(offs - short_size)) { |
1239 // 1110 1011 #8-bit disp. | 1274 // 1110 1011 #8-bit disp. |
(...skipping 22 matching lines...) Expand all Loading... |
1262 | 1297 |
1263 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { | 1298 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { |
1264 EnsureSpace ensure_space(this); | 1299 EnsureSpace ensure_space(this); |
1265 last_pc_ = pc_; | 1300 last_pc_ = pc_; |
1266 // 1110 1001 #32-bit disp. | 1301 // 1110 1001 #32-bit disp. |
1267 emit(0xE9); | 1302 emit(0xE9); |
1268 emit_code_target(target, rmode); | 1303 emit_code_target(target, rmode); |
1269 } | 1304 } |
1270 | 1305 |
1271 | 1306 |
| 1307 void Assembler::jmp(NearLabel* L) { |
| 1308 EnsureSpace ensure_space(this); |
| 1309 last_pc_ = pc_; |
| 1310 if (L->is_bound()) { |
| 1311 const int short_size = sizeof(int8_t); |
| 1312 int offs = L->pos() - pc_offset(); |
| 1313 ASSERT(offs <= 0); |
| 1314 ASSERT(is_int8(offs - short_size)); |
| 1315 // 1110 1011 #8-bit disp. |
| 1316 emit(0xEB); |
| 1317 emit((offs - short_size) & 0xFF); |
| 1318 } else { |
| 1319 emit(0xEB); |
| 1320 emit(0x00); // The displacement will be resolved later. |
| 1321 L->link_to(pc_offset()); |
| 1322 } |
| 1323 } |
| 1324 |
| 1325 |
1272 void Assembler::jmp(Register target) { | 1326 void Assembler::jmp(Register target) { |
1273 EnsureSpace ensure_space(this); | 1327 EnsureSpace ensure_space(this); |
1274 last_pc_ = pc_; | 1328 last_pc_ = pc_; |
1275 // Opcode FF/4 r64. | 1329 // Opcode FF/4 r64. |
1276 emit_optional_rex_32(target); | 1330 emit_optional_rex_32(target); |
1277 emit(0xFF); | 1331 emit(0xFF); |
1278 emit_modrm(0x4, target); | 1332 emit_modrm(0x4, target); |
1279 } | 1333 } |
1280 | 1334 |
1281 | 1335 |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 // specially coded on x64 means that it is a relative 32 bit address, as used | 3004 // specially coded on x64 means that it is a relative 32 bit address, as used |
2951 // by branch instructions. | 3005 // by branch instructions. |
2952 return (1 << rmode_) & kApplyMask; | 3006 return (1 << rmode_) & kApplyMask; |
2953 } | 3007 } |
2954 | 3008 |
2955 | 3009 |
2956 | 3010 |
2957 } } // namespace v8::internal | 3011 } } // namespace v8::internal |
2958 | 3012 |
2959 #endif // V8_TARGET_ARCH_X64 | 3013 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |