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

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

Issue 165443: X64: Implement RegExp natively. (Closed)
Patch Set: Addressed review comments. Created 11 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
OLDNEW
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) { 431 void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) {
432 EnsureSpace ensure_space(this); 432 EnsureSpace ensure_space(this);
433 last_pc_ = pc_; 433 last_pc_ = pc_;
434 emit_rex_64(reg, op); 434 emit_rex_64(reg, op);
435 emit(opcode); 435 emit(opcode);
436 emit_operand(reg, op); 436 emit_operand(reg, op);
437 } 437 }
438 438
439 439
440 void Assembler::arithmetic_op(byte opcode, Register dst, Register src) { 440 void Assembler::arithmetic_op(byte opcode, Register reg, Register rm_reg) {
441 EnsureSpace ensure_space(this); 441 EnsureSpace ensure_space(this);
442 last_pc_ = pc_; 442 last_pc_ = pc_;
443 emit_rex_64(dst, src); 443 emit_rex_64(reg, rm_reg);
444 emit(opcode); 444 emit(opcode);
445 emit_modrm(dst, src); 445 emit_modrm(reg, rm_reg);
446 } 446 }
447 447
448 448
449 void Assembler::arithmetic_op_32(byte opcode, Register dst, Register src) { 449 void Assembler::arithmetic_op_16(byte opcode, Register reg, Register rm_reg) {
450 EnsureSpace ensure_space(this); 450 EnsureSpace ensure_space(this);
451 last_pc_ = pc_; 451 last_pc_ = pc_;
452 emit_optional_rex_32(dst, src); 452 emit(0x66);
453 emit_optional_rex_32(reg, rm_reg);
453 emit(opcode); 454 emit(opcode);
454 emit_modrm(dst, src); 455 emit_modrm(reg, rm_reg);
455 } 456 }
456 457
457 458
459 void Assembler::arithmetic_op_16(byte opcode,
460 Register reg,
461 const Operand& rm_reg) {
462 EnsureSpace ensure_space(this);
463 last_pc_ = pc_;
464 emit(0x66);
465 emit_optional_rex_32(reg, rm_reg);
466 emit(opcode);
467 emit_operand(reg, rm_reg);
468 }
469
470
471 void Assembler::arithmetic_op_32(byte opcode, Register reg, Register rm_reg) {
472 EnsureSpace ensure_space(this);
473 last_pc_ = pc_;
474 emit_optional_rex_32(reg, rm_reg);
475 emit(opcode);
476 emit_modrm(reg, rm_reg);
477 }
478
479
458 void Assembler::arithmetic_op_32(byte opcode, 480 void Assembler::arithmetic_op_32(byte opcode,
459 Register reg, 481 Register reg,
460 const Operand& rm_reg) { 482 const Operand& rm_reg) {
461 EnsureSpace ensure_space(this); 483 EnsureSpace ensure_space(this);
462 last_pc_ = pc_; 484 last_pc_ = pc_;
463 emit_optional_rex_32(reg, rm_reg); 485 emit_optional_rex_32(reg, rm_reg);
464 emit(opcode); 486 emit(opcode);
465 emit_operand(reg, rm_reg); 487 emit_operand(reg, rm_reg);
466 } 488 }
467 489
(...skipping 29 matching lines...) Expand all
497 emit_operand(subcode, dst); 519 emit_operand(subcode, dst);
498 emit(src.value_); 520 emit(src.value_);
499 } else { 521 } else {
500 emit(0x81); 522 emit(0x81);
501 emit_operand(subcode, dst); 523 emit_operand(subcode, dst);
502 emitl(src.value_); 524 emitl(src.value_);
503 } 525 }
504 } 526 }
505 527
506 528
529 void Assembler::immediate_arithmetic_op_16(byte subcode,
530 Register dst,
531 Immediate src) {
532 EnsureSpace ensure_space(this);
533 last_pc_ = pc_;
534 emit(0x66); // Operand size override prefix.
535 emit_optional_rex_32(dst);
536 if (is_int8(src.value_)) {
537 emit(0x83);
538 emit_modrm(subcode, dst);
539 emit(src.value_);
540 } else if (dst.is(rax)) {
541 emit(0x05 | (subcode << 3));
542 emitl(src.value_);
543 } else {
544 emit(0x81);
545 emit_modrm(subcode, dst);
546 emitl(src.value_);
547 }
548 }
549
550
551 void Assembler::immediate_arithmetic_op_16(byte subcode,
552 const Operand& dst,
553 Immediate src) {
554 EnsureSpace ensure_space(this);
555 last_pc_ = pc_;
556 emit(0x66); // Operand size override prefix.
557 emit_optional_rex_32(dst);
558 if (is_int8(src.value_)) {
559 emit(0x83);
560 emit_operand(subcode, dst);
561 emit(src.value_);
562 } else {
563 emit(0x81);
564 emit_operand(subcode, dst);
565 emitl(src.value_);
566 }
567 }
568
569
507 void Assembler::immediate_arithmetic_op_32(byte subcode, 570 void Assembler::immediate_arithmetic_op_32(byte subcode,
508 Register dst, 571 Register dst,
509 Immediate src) { 572 Immediate src) {
510 EnsureSpace ensure_space(this); 573 EnsureSpace ensure_space(this);
511 last_pc_ = pc_; 574 last_pc_ = pc_;
512 emit_optional_rex_32(dst); 575 emit_optional_rex_32(dst);
513 if (is_int8(src.value_)) { 576 if (is_int8(src.value_)) {
514 emit(0x83); 577 emit(0x83);
515 emit_modrm(subcode, dst); 578 emit_modrm(subcode, dst);
516 emit(src.value_); 579 emit(src.value_);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 EnsureSpace ensure_space(this); 800 EnsureSpace ensure_space(this);
738 last_pc_ = pc_; 801 last_pc_ = pc_;
739 // Opcode: 0f 40 + cc /r 802 // Opcode: 0f 40 + cc /r
740 emit_optional_rex_32(dst, src); 803 emit_optional_rex_32(dst, src);
741 emit(0x0f); 804 emit(0x0f);
742 emit(0x40 + cc); 805 emit(0x40 + cc);
743 emit_operand(dst, src); 806 emit_operand(dst, src);
744 } 807 }
745 808
746 809
810 void Assembler::cmpb_al(Immediate imm8) {
811 ASSERT(is_int8(imm8.value_) || is_uint8(imm8.value_));
812 EnsureSpace ensure_space(this);
813 last_pc_ = pc_;
814 emit(0x3c);
815 emit(imm8.value_);
816 }
817
747 818
748 void Assembler::cpuid() { 819 void Assembler::cpuid() {
749 ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID)); 820 ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID));
750 EnsureSpace ensure_space(this); 821 EnsureSpace ensure_space(this);
751 last_pc_ = pc_; 822 last_pc_ = pc_;
752 emit(0x0F); 823 emit(0x0F);
753 emit(0xA2); 824 emit(0xA2);
754 } 825 }
755 826
756 827
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 void Assembler::movq(const Operand& dst, Immediate value) { 1257 void Assembler::movq(const Operand& dst, Immediate value) {
1187 EnsureSpace ensure_space(this); 1258 EnsureSpace ensure_space(this);
1188 last_pc_ = pc_; 1259 last_pc_ = pc_;
1189 emit_rex_64(dst); 1260 emit_rex_64(dst);
1190 emit(0xC7); 1261 emit(0xC7);
1191 emit_operand(0, dst); 1262 emit_operand(0, dst);
1192 emit(value); 1263 emit(value);
1193 } 1264 }
1194 1265
1195 1266
1267 /*
1268 * Loads the ip-relative location of the src label into the target
1269 * location (as a 32-bit offset sign extended to 64-bit).
1270 */
1271 void Assembler::movl(const Operand& dst, Label* src) {
1272 EnsureSpace ensure_space(this);
1273 last_pc_ = pc_;
1274 emit_optional_rex_32(dst);
1275 emit(0xC7);
1276 emit_operand(0, dst);
1277 if (src->is_bound()) {
1278 int offset = src->pos() - pc_offset() - sizeof(int32_t);
1279 ASSERT(offset <= 0);
1280 emitl(offset);
1281 } else if (src->is_linked()) {
1282 emitl(src->pos());
1283 src->link_to(pc_offset() - sizeof(int32_t));
1284 } else {
1285 ASSERT(src->is_unused());
1286 int32_t current = pc_offset();
1287 emitl(current);
1288 src->link_to(current);
1289 }
1290 }
1291
1292
1196 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { 1293 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) {
1197 // If there is no relocation info, emit the value of the handle efficiently 1294 // If there is no relocation info, emit the value of the handle efficiently
1198 // (possibly using less that 8 bytes for the value). 1295 // (possibly using less that 8 bytes for the value).
1199 if (mode == RelocInfo::NONE) { 1296 if (mode == RelocInfo::NONE) {
1200 // There is no possible reason to store a heap pointer without relocation 1297 // There is no possible reason to store a heap pointer without relocation
1201 // info, so it must be a smi. 1298 // info, so it must be a smi.
1202 ASSERT(value->IsSmi()); 1299 ASSERT(value->IsSmi());
1203 // Smis never have more than 32 significant bits, but they might 1300 // Smis never have more than 32 significant bits, but they might
1204 // have garbage in the high bits. 1301 // have garbage in the high bits.
1205 movq(dst, 1302 movq(dst,
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 RecordRelocInfo(RelocInfo::POSITION, current_position_); 2321 RecordRelocInfo(RelocInfo::POSITION, current_position_);
2225 written_position_ = current_position_; 2322 written_position_ = current_position_;
2226 } 2323 }
2227 } 2324 }
2228 2325
2229 2326
2230 const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE; 2327 const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE;
2231 2328
2232 2329
2233 } } // namespace v8::internal 2330 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698