OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (own_buffer_) { | 381 if (own_buffer_) { |
382 memset(buffer_, 0xCC, buffer_size); // int3 | 382 memset(buffer_, 0xCC, buffer_size); // int3 |
383 } | 383 } |
384 #endif | 384 #endif |
385 | 385 |
386 // Setup buffer pointers. | 386 // Setup buffer pointers. |
387 ASSERT(buffer_ != NULL); | 387 ASSERT(buffer_ != NULL); |
388 pc_ = buffer_; | 388 pc_ = buffer_; |
389 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); | 389 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); |
390 | 390 |
| 391 last_pc_ = NULL; |
391 | 392 |
392 #ifdef GENERATED_CODE_COVERAGE | 393 #ifdef GENERATED_CODE_COVERAGE |
393 InitCoverageLog(); | 394 InitCoverageLog(); |
394 #endif | 395 #endif |
395 } | 396 } |
396 | 397 |
397 | 398 |
398 Assembler::~Assembler() { | 399 Assembler::~Assembler() { |
399 if (own_buffer_) { | 400 if (own_buffer_) { |
400 if (isolate() != NULL && | 401 if (isolate() != NULL && |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 437 } |
437 | 438 |
438 | 439 |
439 void Assembler::CodeTargetAlign() { | 440 void Assembler::CodeTargetAlign() { |
440 Align(16); // Preferred alignment of jump targets on x64. | 441 Align(16); // Preferred alignment of jump targets on x64. |
441 } | 442 } |
442 | 443 |
443 | 444 |
444 void Assembler::bind_to(Label* L, int pos) { | 445 void Assembler::bind_to(Label* L, int pos) { |
445 ASSERT(!L->is_bound()); // Label may only be bound once. | 446 ASSERT(!L->is_bound()); // Label may only be bound once. |
| 447 last_pc_ = NULL; |
446 ASSERT(0 <= pos && pos <= pc_offset()); // Position must be valid. | 448 ASSERT(0 <= pos && pos <= pc_offset()); // Position must be valid. |
447 if (L->is_linked()) { | 449 if (L->is_linked()) { |
448 int current = L->pos(); | 450 int current = L->pos(); |
449 int next = long_at(current); | 451 int next = long_at(current); |
450 while (next != current) { | 452 while (next != current) { |
451 // Relative address, relative to point after address. | 453 // Relative address, relative to point after address. |
452 int imm32 = pos - (current + sizeof(int32_t)); | 454 int imm32 = pos - (current + sizeof(int32_t)); |
453 long_at_put(current, imm32); | 455 long_at_put(current, imm32); |
454 current = next; | 456 current = next; |
455 next = long_at(next); | 457 next = long_at(next); |
456 } | 458 } |
457 // Fix up last fixup on linked list. | 459 // Fix up last fixup on linked list. |
458 int last_imm32 = pos - (current + sizeof(int32_t)); | 460 int last_imm32 = pos - (current + sizeof(int32_t)); |
459 long_at_put(current, last_imm32); | 461 long_at_put(current, last_imm32); |
460 } | 462 } |
461 L->bind_to(pos); | 463 L->bind_to(pos); |
462 } | 464 } |
463 | 465 |
464 | 466 |
465 void Assembler::bind(Label* L) { | 467 void Assembler::bind(Label* L) { |
466 bind_to(L, pc_offset()); | 468 bind_to(L, pc_offset()); |
467 } | 469 } |
468 | 470 |
469 | 471 |
470 void Assembler::bind(NearLabel* L) { | 472 void Assembler::bind(NearLabel* L) { |
471 ASSERT(!L->is_bound()); | 473 ASSERT(!L->is_bound()); |
| 474 last_pc_ = NULL; |
472 while (L->unresolved_branches_ > 0) { | 475 while (L->unresolved_branches_ > 0) { |
473 int branch_pos = L->unresolved_positions_[L->unresolved_branches_ - 1]; | 476 int branch_pos = L->unresolved_positions_[L->unresolved_branches_ - 1]; |
474 int disp = pc_offset() - branch_pos; | 477 int disp = pc_offset() - branch_pos; |
475 ASSERT(is_int8(disp)); | 478 ASSERT(is_int8(disp)); |
476 set_byte_at(branch_pos - sizeof(int8_t), disp); | 479 set_byte_at(branch_pos - sizeof(int8_t), disp); |
477 L->unresolved_branches_--; | 480 L->unresolved_branches_--; |
478 } | 481 } |
479 L->bind_to(pc_offset()); | 482 L->bind_to(pc_offset()); |
480 } | 483 } |
481 | 484 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 if (isolate() != NULL && | 525 if (isolate() != NULL && |
523 isolate()->assembler_spare_buffer() == NULL && | 526 isolate()->assembler_spare_buffer() == NULL && |
524 buffer_size_ == kMinimalBufferSize) { | 527 buffer_size_ == kMinimalBufferSize) { |
525 isolate()->set_assembler_spare_buffer(buffer_); | 528 isolate()->set_assembler_spare_buffer(buffer_); |
526 } else { | 529 } else { |
527 DeleteArray(buffer_); | 530 DeleteArray(buffer_); |
528 } | 531 } |
529 buffer_ = desc.buffer; | 532 buffer_ = desc.buffer; |
530 buffer_size_ = desc.buffer_size; | 533 buffer_size_ = desc.buffer_size; |
531 pc_ += pc_delta; | 534 pc_ += pc_delta; |
| 535 if (last_pc_ != NULL) { |
| 536 last_pc_ += pc_delta; |
| 537 } |
532 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, | 538 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, |
533 reloc_info_writer.last_pc() + pc_delta); | 539 reloc_info_writer.last_pc() + pc_delta); |
534 | 540 |
535 // Relocate runtime entries. | 541 // Relocate runtime entries. |
536 for (RelocIterator it(desc); !it.done(); it.next()) { | 542 for (RelocIterator it(desc); !it.done(); it.next()) { |
537 RelocInfo::Mode rmode = it.rinfo()->rmode(); | 543 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
538 if (rmode == RelocInfo::INTERNAL_REFERENCE) { | 544 if (rmode == RelocInfo::INTERNAL_REFERENCE) { |
539 intptr_t* p = reinterpret_cast<intptr_t*>(it.rinfo()->pc()); | 545 intptr_t* p = reinterpret_cast<intptr_t*>(it.rinfo()->pc()); |
540 if (*p != 0) { // 0 means uninitialized. | 546 if (*p != 0) { // 0 means uninitialized. |
541 *p += pc_delta; | 547 *p += pc_delta; |
(...skipping 17 matching lines...) Expand all Loading... |
559 // Emit the rest of the encoded operand. | 565 // Emit the rest of the encoded operand. |
560 for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i]; | 566 for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i]; |
561 pc_ += length; | 567 pc_ += length; |
562 } | 568 } |
563 | 569 |
564 | 570 |
565 // Assembler Instruction implementations. | 571 // Assembler Instruction implementations. |
566 | 572 |
567 void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) { | 573 void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) { |
568 EnsureSpace ensure_space(this); | 574 EnsureSpace ensure_space(this); |
| 575 last_pc_ = pc_; |
569 emit_rex_64(reg, op); | 576 emit_rex_64(reg, op); |
570 emit(opcode); | 577 emit(opcode); |
571 emit_operand(reg, op); | 578 emit_operand(reg, op); |
572 } | 579 } |
573 | 580 |
574 | 581 |
575 void Assembler::arithmetic_op(byte opcode, Register reg, Register rm_reg) { | 582 void Assembler::arithmetic_op(byte opcode, Register reg, Register rm_reg) { |
576 EnsureSpace ensure_space(this); | 583 EnsureSpace ensure_space(this); |
| 584 last_pc_ = pc_; |
577 ASSERT((opcode & 0xC6) == 2); | 585 ASSERT((opcode & 0xC6) == 2); |
578 if (rm_reg.low_bits() == 4) { // Forces SIB byte. | 586 if (rm_reg.low_bits() == 4) { // Forces SIB byte. |
579 // Swap reg and rm_reg and change opcode operand order. | 587 // Swap reg and rm_reg and change opcode operand order. |
580 emit_rex_64(rm_reg, reg); | 588 emit_rex_64(rm_reg, reg); |
581 emit(opcode ^ 0x02); | 589 emit(opcode ^ 0x02); |
582 emit_modrm(rm_reg, reg); | 590 emit_modrm(rm_reg, reg); |
583 } else { | 591 } else { |
584 emit_rex_64(reg, rm_reg); | 592 emit_rex_64(reg, rm_reg); |
585 emit(opcode); | 593 emit(opcode); |
586 emit_modrm(reg, rm_reg); | 594 emit_modrm(reg, rm_reg); |
587 } | 595 } |
588 } | 596 } |
589 | 597 |
590 | 598 |
591 void Assembler::arithmetic_op_16(byte opcode, Register reg, Register rm_reg) { | 599 void Assembler::arithmetic_op_16(byte opcode, Register reg, Register rm_reg) { |
592 EnsureSpace ensure_space(this); | 600 EnsureSpace ensure_space(this); |
| 601 last_pc_ = pc_; |
593 ASSERT((opcode & 0xC6) == 2); | 602 ASSERT((opcode & 0xC6) == 2); |
594 if (rm_reg.low_bits() == 4) { // Forces SIB byte. | 603 if (rm_reg.low_bits() == 4) { // Forces SIB byte. |
595 // Swap reg and rm_reg and change opcode operand order. | 604 // Swap reg and rm_reg and change opcode operand order. |
596 emit(0x66); | 605 emit(0x66); |
597 emit_optional_rex_32(rm_reg, reg); | 606 emit_optional_rex_32(rm_reg, reg); |
598 emit(opcode ^ 0x02); | 607 emit(opcode ^ 0x02); |
599 emit_modrm(rm_reg, reg); | 608 emit_modrm(rm_reg, reg); |
600 } else { | 609 } else { |
601 emit(0x66); | 610 emit(0x66); |
602 emit_optional_rex_32(reg, rm_reg); | 611 emit_optional_rex_32(reg, rm_reg); |
603 emit(opcode); | 612 emit(opcode); |
604 emit_modrm(reg, rm_reg); | 613 emit_modrm(reg, rm_reg); |
605 } | 614 } |
606 } | 615 } |
607 | 616 |
608 | 617 |
609 void Assembler::arithmetic_op_16(byte opcode, | 618 void Assembler::arithmetic_op_16(byte opcode, |
610 Register reg, | 619 Register reg, |
611 const Operand& rm_reg) { | 620 const Operand& rm_reg) { |
612 EnsureSpace ensure_space(this); | 621 EnsureSpace ensure_space(this); |
| 622 last_pc_ = pc_; |
613 emit(0x66); | 623 emit(0x66); |
614 emit_optional_rex_32(reg, rm_reg); | 624 emit_optional_rex_32(reg, rm_reg); |
615 emit(opcode); | 625 emit(opcode); |
616 emit_operand(reg, rm_reg); | 626 emit_operand(reg, rm_reg); |
617 } | 627 } |
618 | 628 |
619 | 629 |
620 void Assembler::arithmetic_op_32(byte opcode, Register reg, Register rm_reg) { | 630 void Assembler::arithmetic_op_32(byte opcode, Register reg, Register rm_reg) { |
621 EnsureSpace ensure_space(this); | 631 EnsureSpace ensure_space(this); |
| 632 last_pc_ = pc_; |
622 ASSERT((opcode & 0xC6) == 2); | 633 ASSERT((opcode & 0xC6) == 2); |
623 if (rm_reg.low_bits() == 4) { // Forces SIB byte. | 634 if (rm_reg.low_bits() == 4) { // Forces SIB byte. |
624 // Swap reg and rm_reg and change opcode operand order. | 635 // Swap reg and rm_reg and change opcode operand order. |
625 emit_optional_rex_32(rm_reg, reg); | 636 emit_optional_rex_32(rm_reg, reg); |
626 emit(opcode ^ 0x02); // E.g. 0x03 -> 0x01 for ADD. | 637 emit(opcode ^ 0x02); // E.g. 0x03 -> 0x01 for ADD. |
627 emit_modrm(rm_reg, reg); | 638 emit_modrm(rm_reg, reg); |
628 } else { | 639 } else { |
629 emit_optional_rex_32(reg, rm_reg); | 640 emit_optional_rex_32(reg, rm_reg); |
630 emit(opcode); | 641 emit(opcode); |
631 emit_modrm(reg, rm_reg); | 642 emit_modrm(reg, rm_reg); |
632 } | 643 } |
633 } | 644 } |
634 | 645 |
635 | 646 |
636 void Assembler::arithmetic_op_32(byte opcode, | 647 void Assembler::arithmetic_op_32(byte opcode, |
637 Register reg, | 648 Register reg, |
638 const Operand& rm_reg) { | 649 const Operand& rm_reg) { |
639 EnsureSpace ensure_space(this); | 650 EnsureSpace ensure_space(this); |
| 651 last_pc_ = pc_; |
640 emit_optional_rex_32(reg, rm_reg); | 652 emit_optional_rex_32(reg, rm_reg); |
641 emit(opcode); | 653 emit(opcode); |
642 emit_operand(reg, rm_reg); | 654 emit_operand(reg, rm_reg); |
643 } | 655 } |
644 | 656 |
645 | 657 |
646 void Assembler::immediate_arithmetic_op(byte subcode, | 658 void Assembler::immediate_arithmetic_op(byte subcode, |
647 Register dst, | 659 Register dst, |
648 Immediate src) { | 660 Immediate src) { |
649 EnsureSpace ensure_space(this); | 661 EnsureSpace ensure_space(this); |
| 662 last_pc_ = pc_; |
650 emit_rex_64(dst); | 663 emit_rex_64(dst); |
651 if (is_int8(src.value_)) { | 664 if (is_int8(src.value_)) { |
652 emit(0x83); | 665 emit(0x83); |
653 emit_modrm(subcode, dst); | 666 emit_modrm(subcode, dst); |
654 emit(src.value_); | 667 emit(src.value_); |
655 } else if (dst.is(rax)) { | 668 } else if (dst.is(rax)) { |
656 emit(0x05 | (subcode << 3)); | 669 emit(0x05 | (subcode << 3)); |
657 emitl(src.value_); | 670 emitl(src.value_); |
658 } else { | 671 } else { |
659 emit(0x81); | 672 emit(0x81); |
660 emit_modrm(subcode, dst); | 673 emit_modrm(subcode, dst); |
661 emitl(src.value_); | 674 emitl(src.value_); |
662 } | 675 } |
663 } | 676 } |
664 | 677 |
665 void Assembler::immediate_arithmetic_op(byte subcode, | 678 void Assembler::immediate_arithmetic_op(byte subcode, |
666 const Operand& dst, | 679 const Operand& dst, |
667 Immediate src) { | 680 Immediate src) { |
668 EnsureSpace ensure_space(this); | 681 EnsureSpace ensure_space(this); |
| 682 last_pc_ = pc_; |
669 emit_rex_64(dst); | 683 emit_rex_64(dst); |
670 if (is_int8(src.value_)) { | 684 if (is_int8(src.value_)) { |
671 emit(0x83); | 685 emit(0x83); |
672 emit_operand(subcode, dst); | 686 emit_operand(subcode, dst); |
673 emit(src.value_); | 687 emit(src.value_); |
674 } else { | 688 } else { |
675 emit(0x81); | 689 emit(0x81); |
676 emit_operand(subcode, dst); | 690 emit_operand(subcode, dst); |
677 emitl(src.value_); | 691 emitl(src.value_); |
678 } | 692 } |
679 } | 693 } |
680 | 694 |
681 | 695 |
682 void Assembler::immediate_arithmetic_op_16(byte subcode, | 696 void Assembler::immediate_arithmetic_op_16(byte subcode, |
683 Register dst, | 697 Register dst, |
684 Immediate src) { | 698 Immediate src) { |
685 EnsureSpace ensure_space(this); | 699 EnsureSpace ensure_space(this); |
| 700 last_pc_ = pc_; |
686 emit(0x66); // Operand size override prefix. | 701 emit(0x66); // Operand size override prefix. |
687 emit_optional_rex_32(dst); | 702 emit_optional_rex_32(dst); |
688 if (is_int8(src.value_)) { | 703 if (is_int8(src.value_)) { |
689 emit(0x83); | 704 emit(0x83); |
690 emit_modrm(subcode, dst); | 705 emit_modrm(subcode, dst); |
691 emit(src.value_); | 706 emit(src.value_); |
692 } else if (dst.is(rax)) { | 707 } else if (dst.is(rax)) { |
693 emit(0x05 | (subcode << 3)); | 708 emit(0x05 | (subcode << 3)); |
694 emitw(src.value_); | 709 emitw(src.value_); |
695 } else { | 710 } else { |
696 emit(0x81); | 711 emit(0x81); |
697 emit_modrm(subcode, dst); | 712 emit_modrm(subcode, dst); |
698 emitw(src.value_); | 713 emitw(src.value_); |
699 } | 714 } |
700 } | 715 } |
701 | 716 |
702 | 717 |
703 void Assembler::immediate_arithmetic_op_16(byte subcode, | 718 void Assembler::immediate_arithmetic_op_16(byte subcode, |
704 const Operand& dst, | 719 const Operand& dst, |
705 Immediate src) { | 720 Immediate src) { |
706 EnsureSpace ensure_space(this); | 721 EnsureSpace ensure_space(this); |
| 722 last_pc_ = pc_; |
707 emit(0x66); // Operand size override prefix. | 723 emit(0x66); // Operand size override prefix. |
708 emit_optional_rex_32(dst); | 724 emit_optional_rex_32(dst); |
709 if (is_int8(src.value_)) { | 725 if (is_int8(src.value_)) { |
710 emit(0x83); | 726 emit(0x83); |
711 emit_operand(subcode, dst); | 727 emit_operand(subcode, dst); |
712 emit(src.value_); | 728 emit(src.value_); |
713 } else { | 729 } else { |
714 emit(0x81); | 730 emit(0x81); |
715 emit_operand(subcode, dst); | 731 emit_operand(subcode, dst); |
716 emitw(src.value_); | 732 emitw(src.value_); |
717 } | 733 } |
718 } | 734 } |
719 | 735 |
720 | 736 |
721 void Assembler::immediate_arithmetic_op_32(byte subcode, | 737 void Assembler::immediate_arithmetic_op_32(byte subcode, |
722 Register dst, | 738 Register dst, |
723 Immediate src) { | 739 Immediate src) { |
724 EnsureSpace ensure_space(this); | 740 EnsureSpace ensure_space(this); |
| 741 last_pc_ = pc_; |
725 emit_optional_rex_32(dst); | 742 emit_optional_rex_32(dst); |
726 if (is_int8(src.value_)) { | 743 if (is_int8(src.value_)) { |
727 emit(0x83); | 744 emit(0x83); |
728 emit_modrm(subcode, dst); | 745 emit_modrm(subcode, dst); |
729 emit(src.value_); | 746 emit(src.value_); |
730 } else if (dst.is(rax)) { | 747 } else if (dst.is(rax)) { |
731 emit(0x05 | (subcode << 3)); | 748 emit(0x05 | (subcode << 3)); |
732 emitl(src.value_); | 749 emitl(src.value_); |
733 } else { | 750 } else { |
734 emit(0x81); | 751 emit(0x81); |
735 emit_modrm(subcode, dst); | 752 emit_modrm(subcode, dst); |
736 emitl(src.value_); | 753 emitl(src.value_); |
737 } | 754 } |
738 } | 755 } |
739 | 756 |
740 | 757 |
741 void Assembler::immediate_arithmetic_op_32(byte subcode, | 758 void Assembler::immediate_arithmetic_op_32(byte subcode, |
742 const Operand& dst, | 759 const Operand& dst, |
743 Immediate src) { | 760 Immediate src) { |
744 EnsureSpace ensure_space(this); | 761 EnsureSpace ensure_space(this); |
| 762 last_pc_ = pc_; |
745 emit_optional_rex_32(dst); | 763 emit_optional_rex_32(dst); |
746 if (is_int8(src.value_)) { | 764 if (is_int8(src.value_)) { |
747 emit(0x83); | 765 emit(0x83); |
748 emit_operand(subcode, dst); | 766 emit_operand(subcode, dst); |
749 emit(src.value_); | 767 emit(src.value_); |
750 } else { | 768 } else { |
751 emit(0x81); | 769 emit(0x81); |
752 emit_operand(subcode, dst); | 770 emit_operand(subcode, dst); |
753 emitl(src.value_); | 771 emitl(src.value_); |
754 } | 772 } |
755 } | 773 } |
756 | 774 |
757 | 775 |
758 void Assembler::immediate_arithmetic_op_8(byte subcode, | 776 void Assembler::immediate_arithmetic_op_8(byte subcode, |
759 const Operand& dst, | 777 const Operand& dst, |
760 Immediate src) { | 778 Immediate src) { |
761 EnsureSpace ensure_space(this); | 779 EnsureSpace ensure_space(this); |
| 780 last_pc_ = pc_; |
762 emit_optional_rex_32(dst); | 781 emit_optional_rex_32(dst); |
763 ASSERT(is_int8(src.value_) || is_uint8(src.value_)); | 782 ASSERT(is_int8(src.value_) || is_uint8(src.value_)); |
764 emit(0x80); | 783 emit(0x80); |
765 emit_operand(subcode, dst); | 784 emit_operand(subcode, dst); |
766 emit(src.value_); | 785 emit(src.value_); |
767 } | 786 } |
768 | 787 |
769 | 788 |
770 void Assembler::immediate_arithmetic_op_8(byte subcode, | 789 void Assembler::immediate_arithmetic_op_8(byte subcode, |
771 Register dst, | 790 Register dst, |
772 Immediate src) { | 791 Immediate src) { |
773 EnsureSpace ensure_space(this); | 792 EnsureSpace ensure_space(this); |
| 793 last_pc_ = pc_; |
774 if (dst.code() > 3) { | 794 if (dst.code() > 3) { |
775 // Use 64-bit mode byte registers. | 795 // Use 64-bit mode byte registers. |
776 emit_rex_64(dst); | 796 emit_rex_64(dst); |
777 } | 797 } |
778 ASSERT(is_int8(src.value_) || is_uint8(src.value_)); | 798 ASSERT(is_int8(src.value_) || is_uint8(src.value_)); |
779 emit(0x80); | 799 emit(0x80); |
780 emit_modrm(subcode, dst); | 800 emit_modrm(subcode, dst); |
781 emit(src.value_); | 801 emit(src.value_); |
782 } | 802 } |
783 | 803 |
784 | 804 |
785 void Assembler::shift(Register dst, Immediate shift_amount, int subcode) { | 805 void Assembler::shift(Register dst, Immediate shift_amount, int subcode) { |
786 EnsureSpace ensure_space(this); | 806 EnsureSpace ensure_space(this); |
| 807 last_pc_ = pc_; |
787 ASSERT(is_uint6(shift_amount.value_)); // illegal shift count | 808 ASSERT(is_uint6(shift_amount.value_)); // illegal shift count |
788 if (shift_amount.value_ == 1) { | 809 if (shift_amount.value_ == 1) { |
789 emit_rex_64(dst); | 810 emit_rex_64(dst); |
790 emit(0xD1); | 811 emit(0xD1); |
791 emit_modrm(subcode, dst); | 812 emit_modrm(subcode, dst); |
792 } else { | 813 } else { |
793 emit_rex_64(dst); | 814 emit_rex_64(dst); |
794 emit(0xC1); | 815 emit(0xC1); |
795 emit_modrm(subcode, dst); | 816 emit_modrm(subcode, dst); |
796 emit(shift_amount.value_); | 817 emit(shift_amount.value_); |
797 } | 818 } |
798 } | 819 } |
799 | 820 |
800 | 821 |
801 void Assembler::shift(Register dst, int subcode) { | 822 void Assembler::shift(Register dst, int subcode) { |
802 EnsureSpace ensure_space(this); | 823 EnsureSpace ensure_space(this); |
| 824 last_pc_ = pc_; |
803 emit_rex_64(dst); | 825 emit_rex_64(dst); |
804 emit(0xD3); | 826 emit(0xD3); |
805 emit_modrm(subcode, dst); | 827 emit_modrm(subcode, dst); |
806 } | 828 } |
807 | 829 |
808 | 830 |
809 void Assembler::shift_32(Register dst, int subcode) { | 831 void Assembler::shift_32(Register dst, int subcode) { |
810 EnsureSpace ensure_space(this); | 832 EnsureSpace ensure_space(this); |
| 833 last_pc_ = pc_; |
811 emit_optional_rex_32(dst); | 834 emit_optional_rex_32(dst); |
812 emit(0xD3); | 835 emit(0xD3); |
813 emit_modrm(subcode, dst); | 836 emit_modrm(subcode, dst); |
814 } | 837 } |
815 | 838 |
816 | 839 |
817 void Assembler::shift_32(Register dst, Immediate shift_amount, int subcode) { | 840 void Assembler::shift_32(Register dst, Immediate shift_amount, int subcode) { |
818 EnsureSpace ensure_space(this); | 841 EnsureSpace ensure_space(this); |
| 842 last_pc_ = pc_; |
819 ASSERT(is_uint5(shift_amount.value_)); // illegal shift count | 843 ASSERT(is_uint5(shift_amount.value_)); // illegal shift count |
820 if (shift_amount.value_ == 1) { | 844 if (shift_amount.value_ == 1) { |
821 emit_optional_rex_32(dst); | 845 emit_optional_rex_32(dst); |
822 emit(0xD1); | 846 emit(0xD1); |
823 emit_modrm(subcode, dst); | 847 emit_modrm(subcode, dst); |
824 } else { | 848 } else { |
825 emit_optional_rex_32(dst); | 849 emit_optional_rex_32(dst); |
826 emit(0xC1); | 850 emit(0xC1); |
827 emit_modrm(subcode, dst); | 851 emit_modrm(subcode, dst); |
828 emit(shift_amount.value_); | 852 emit(shift_amount.value_); |
829 } | 853 } |
830 } | 854 } |
831 | 855 |
832 | 856 |
833 void Assembler::bt(const Operand& dst, Register src) { | 857 void Assembler::bt(const Operand& dst, Register src) { |
834 EnsureSpace ensure_space(this); | 858 EnsureSpace ensure_space(this); |
| 859 last_pc_ = pc_; |
835 emit_rex_64(src, dst); | 860 emit_rex_64(src, dst); |
836 emit(0x0F); | 861 emit(0x0F); |
837 emit(0xA3); | 862 emit(0xA3); |
838 emit_operand(src, dst); | 863 emit_operand(src, dst); |
839 } | 864 } |
840 | 865 |
841 | 866 |
842 void Assembler::bts(const Operand& dst, Register src) { | 867 void Assembler::bts(const Operand& dst, Register src) { |
843 EnsureSpace ensure_space(this); | 868 EnsureSpace ensure_space(this); |
| 869 last_pc_ = pc_; |
844 emit_rex_64(src, dst); | 870 emit_rex_64(src, dst); |
845 emit(0x0F); | 871 emit(0x0F); |
846 emit(0xAB); | 872 emit(0xAB); |
847 emit_operand(src, dst); | 873 emit_operand(src, dst); |
848 } | 874 } |
849 | 875 |
850 | 876 |
851 void Assembler::call(Label* L) { | 877 void Assembler::call(Label* L) { |
852 positions_recorder()->WriteRecordedPositions(); | 878 positions_recorder()->WriteRecordedPositions(); |
853 EnsureSpace ensure_space(this); | 879 EnsureSpace ensure_space(this); |
| 880 last_pc_ = pc_; |
854 // 1110 1000 #32-bit disp. | 881 // 1110 1000 #32-bit disp. |
855 emit(0xE8); | 882 emit(0xE8); |
856 if (L->is_bound()) { | 883 if (L->is_bound()) { |
857 int offset = L->pos() - pc_offset() - sizeof(int32_t); | 884 int offset = L->pos() - pc_offset() - sizeof(int32_t); |
858 ASSERT(offset <= 0); | 885 ASSERT(offset <= 0); |
859 emitl(offset); | 886 emitl(offset); |
860 } else if (L->is_linked()) { | 887 } else if (L->is_linked()) { |
861 emitl(L->pos()); | 888 emitl(L->pos()); |
862 L->link_to(pc_offset() - sizeof(int32_t)); | 889 L->link_to(pc_offset() - sizeof(int32_t)); |
863 } else { | 890 } else { |
864 ASSERT(L->is_unused()); | 891 ASSERT(L->is_unused()); |
865 int32_t current = pc_offset(); | 892 int32_t current = pc_offset(); |
866 emitl(current); | 893 emitl(current); |
867 L->link_to(current); | 894 L->link_to(current); |
868 } | 895 } |
869 } | 896 } |
870 | 897 |
871 | 898 |
872 void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) { | 899 void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) { |
873 positions_recorder()->WriteRecordedPositions(); | 900 positions_recorder()->WriteRecordedPositions(); |
874 EnsureSpace ensure_space(this); | 901 EnsureSpace ensure_space(this); |
| 902 last_pc_ = pc_; |
875 // 1110 1000 #32-bit disp. | 903 // 1110 1000 #32-bit disp. |
876 emit(0xE8); | 904 emit(0xE8); |
877 emit_code_target(target, rmode); | 905 emit_code_target(target, rmode); |
878 } | 906 } |
879 | 907 |
880 | 908 |
881 void Assembler::call(Register adr) { | 909 void Assembler::call(Register adr) { |
882 positions_recorder()->WriteRecordedPositions(); | 910 positions_recorder()->WriteRecordedPositions(); |
883 EnsureSpace ensure_space(this); | 911 EnsureSpace ensure_space(this); |
| 912 last_pc_ = pc_; |
884 // Opcode: FF /2 r64. | 913 // Opcode: FF /2 r64. |
885 emit_optional_rex_32(adr); | 914 emit_optional_rex_32(adr); |
886 emit(0xFF); | 915 emit(0xFF); |
887 emit_modrm(0x2, adr); | 916 emit_modrm(0x2, adr); |
888 } | 917 } |
889 | 918 |
890 | 919 |
891 void Assembler::call(const Operand& op) { | 920 void Assembler::call(const Operand& op) { |
892 positions_recorder()->WriteRecordedPositions(); | 921 positions_recorder()->WriteRecordedPositions(); |
893 EnsureSpace ensure_space(this); | 922 EnsureSpace ensure_space(this); |
| 923 last_pc_ = pc_; |
894 // Opcode: FF /2 m64. | 924 // Opcode: FF /2 m64. |
895 emit_optional_rex_32(op); | 925 emit_optional_rex_32(op); |
896 emit(0xFF); | 926 emit(0xFF); |
897 emit_operand(0x2, op); | 927 emit_operand(0x2, op); |
898 } | 928 } |
899 | 929 |
900 | 930 |
901 // Calls directly to the given address using a relative offset. | 931 // Calls directly to the given address using a relative offset. |
902 // Should only ever be used in Code objects for calls within the | 932 // Should only ever be used in Code objects for calls within the |
903 // same Code object. Should not be used when generating new code (use labels), | 933 // same Code object. Should not be used when generating new code (use labels), |
904 // but only when patching existing code. | 934 // but only when patching existing code. |
905 void Assembler::call(Address target) { | 935 void Assembler::call(Address target) { |
906 positions_recorder()->WriteRecordedPositions(); | 936 positions_recorder()->WriteRecordedPositions(); |
907 EnsureSpace ensure_space(this); | 937 EnsureSpace ensure_space(this); |
| 938 last_pc_ = pc_; |
908 // 1110 1000 #32-bit disp. | 939 // 1110 1000 #32-bit disp. |
909 emit(0xE8); | 940 emit(0xE8); |
910 Address source = pc_ + 4; | 941 Address source = pc_ + 4; |
911 intptr_t displacement = target - source; | 942 intptr_t displacement = target - source; |
912 ASSERT(is_int32(displacement)); | 943 ASSERT(is_int32(displacement)); |
913 emitl(static_cast<int32_t>(displacement)); | 944 emitl(static_cast<int32_t>(displacement)); |
914 } | 945 } |
915 | 946 |
916 | 947 |
917 void Assembler::clc() { | 948 void Assembler::clc() { |
918 EnsureSpace ensure_space(this); | 949 EnsureSpace ensure_space(this); |
| 950 last_pc_ = pc_; |
919 emit(0xF8); | 951 emit(0xF8); |
920 } | 952 } |
921 | 953 |
922 void Assembler::cld() { | 954 void Assembler::cld() { |
923 EnsureSpace ensure_space(this); | 955 EnsureSpace ensure_space(this); |
| 956 last_pc_ = pc_; |
924 emit(0xFC); | 957 emit(0xFC); |
925 } | 958 } |
926 | 959 |
927 void Assembler::cdq() { | 960 void Assembler::cdq() { |
928 EnsureSpace ensure_space(this); | 961 EnsureSpace ensure_space(this); |
| 962 last_pc_ = pc_; |
929 emit(0x99); | 963 emit(0x99); |
930 } | 964 } |
931 | 965 |
932 | 966 |
933 void Assembler::cmovq(Condition cc, Register dst, Register src) { | 967 void Assembler::cmovq(Condition cc, Register dst, Register src) { |
934 if (cc == always) { | 968 if (cc == always) { |
935 movq(dst, src); | 969 movq(dst, src); |
936 } else if (cc == never) { | 970 } else if (cc == never) { |
937 return; | 971 return; |
938 } | 972 } |
939 // No need to check CpuInfo for CMOV support, it's a required part of the | 973 // No need to check CpuInfo for CMOV support, it's a required part of the |
940 // 64-bit architecture. | 974 // 64-bit architecture. |
941 ASSERT(cc >= 0); // Use mov for unconditional moves. | 975 ASSERT(cc >= 0); // Use mov for unconditional moves. |
942 EnsureSpace ensure_space(this); | 976 EnsureSpace ensure_space(this); |
| 977 last_pc_ = pc_; |
943 // Opcode: REX.W 0f 40 + cc /r. | 978 // Opcode: REX.W 0f 40 + cc /r. |
944 emit_rex_64(dst, src); | 979 emit_rex_64(dst, src); |
945 emit(0x0f); | 980 emit(0x0f); |
946 emit(0x40 + cc); | 981 emit(0x40 + cc); |
947 emit_modrm(dst, src); | 982 emit_modrm(dst, src); |
948 } | 983 } |
949 | 984 |
950 | 985 |
951 void Assembler::cmovq(Condition cc, Register dst, const Operand& src) { | 986 void Assembler::cmovq(Condition cc, Register dst, const Operand& src) { |
952 if (cc == always) { | 987 if (cc == always) { |
953 movq(dst, src); | 988 movq(dst, src); |
954 } else if (cc == never) { | 989 } else if (cc == never) { |
955 return; | 990 return; |
956 } | 991 } |
957 ASSERT(cc >= 0); | 992 ASSERT(cc >= 0); |
958 EnsureSpace ensure_space(this); | 993 EnsureSpace ensure_space(this); |
| 994 last_pc_ = pc_; |
959 // Opcode: REX.W 0f 40 + cc /r. | 995 // Opcode: REX.W 0f 40 + cc /r. |
960 emit_rex_64(dst, src); | 996 emit_rex_64(dst, src); |
961 emit(0x0f); | 997 emit(0x0f); |
962 emit(0x40 + cc); | 998 emit(0x40 + cc); |
963 emit_operand(dst, src); | 999 emit_operand(dst, src); |
964 } | 1000 } |
965 | 1001 |
966 | 1002 |
967 void Assembler::cmovl(Condition cc, Register dst, Register src) { | 1003 void Assembler::cmovl(Condition cc, Register dst, Register src) { |
968 if (cc == always) { | 1004 if (cc == always) { |
969 movl(dst, src); | 1005 movl(dst, src); |
970 } else if (cc == never) { | 1006 } else if (cc == never) { |
971 return; | 1007 return; |
972 } | 1008 } |
973 ASSERT(cc >= 0); | 1009 ASSERT(cc >= 0); |
974 EnsureSpace ensure_space(this); | 1010 EnsureSpace ensure_space(this); |
| 1011 last_pc_ = pc_; |
975 // Opcode: 0f 40 + cc /r. | 1012 // Opcode: 0f 40 + cc /r. |
976 emit_optional_rex_32(dst, src); | 1013 emit_optional_rex_32(dst, src); |
977 emit(0x0f); | 1014 emit(0x0f); |
978 emit(0x40 + cc); | 1015 emit(0x40 + cc); |
979 emit_modrm(dst, src); | 1016 emit_modrm(dst, src); |
980 } | 1017 } |
981 | 1018 |
982 | 1019 |
983 void Assembler::cmovl(Condition cc, Register dst, const Operand& src) { | 1020 void Assembler::cmovl(Condition cc, Register dst, const Operand& src) { |
984 if (cc == always) { | 1021 if (cc == always) { |
985 movl(dst, src); | 1022 movl(dst, src); |
986 } else if (cc == never) { | 1023 } else if (cc == never) { |
987 return; | 1024 return; |
988 } | 1025 } |
989 ASSERT(cc >= 0); | 1026 ASSERT(cc >= 0); |
990 EnsureSpace ensure_space(this); | 1027 EnsureSpace ensure_space(this); |
| 1028 last_pc_ = pc_; |
991 // Opcode: 0f 40 + cc /r. | 1029 // Opcode: 0f 40 + cc /r. |
992 emit_optional_rex_32(dst, src); | 1030 emit_optional_rex_32(dst, src); |
993 emit(0x0f); | 1031 emit(0x0f); |
994 emit(0x40 + cc); | 1032 emit(0x40 + cc); |
995 emit_operand(dst, src); | 1033 emit_operand(dst, src); |
996 } | 1034 } |
997 | 1035 |
998 | 1036 |
999 void Assembler::cmpb_al(Immediate imm8) { | 1037 void Assembler::cmpb_al(Immediate imm8) { |
1000 ASSERT(is_int8(imm8.value_) || is_uint8(imm8.value_)); | 1038 ASSERT(is_int8(imm8.value_) || is_uint8(imm8.value_)); |
1001 EnsureSpace ensure_space(this); | 1039 EnsureSpace ensure_space(this); |
| 1040 last_pc_ = pc_; |
1002 emit(0x3c); | 1041 emit(0x3c); |
1003 emit(imm8.value_); | 1042 emit(imm8.value_); |
1004 } | 1043 } |
1005 | 1044 |
1006 | 1045 |
1007 void Assembler::cpuid() { | 1046 void Assembler::cpuid() { |
1008 ASSERT(CpuFeatures::IsEnabled(CPUID)); | 1047 ASSERT(CpuFeatures::IsEnabled(CPUID)); |
1009 EnsureSpace ensure_space(this); | 1048 EnsureSpace ensure_space(this); |
| 1049 last_pc_ = pc_; |
1010 emit(0x0F); | 1050 emit(0x0F); |
1011 emit(0xA2); | 1051 emit(0xA2); |
1012 } | 1052 } |
1013 | 1053 |
1014 | 1054 |
1015 void Assembler::cqo() { | 1055 void Assembler::cqo() { |
1016 EnsureSpace ensure_space(this); | 1056 EnsureSpace ensure_space(this); |
| 1057 last_pc_ = pc_; |
1017 emit_rex_64(); | 1058 emit_rex_64(); |
1018 emit(0x99); | 1059 emit(0x99); |
1019 } | 1060 } |
1020 | 1061 |
1021 | 1062 |
1022 void Assembler::decq(Register dst) { | 1063 void Assembler::decq(Register dst) { |
1023 EnsureSpace ensure_space(this); | 1064 EnsureSpace ensure_space(this); |
| 1065 last_pc_ = pc_; |
1024 emit_rex_64(dst); | 1066 emit_rex_64(dst); |
1025 emit(0xFF); | 1067 emit(0xFF); |
1026 emit_modrm(0x1, dst); | 1068 emit_modrm(0x1, dst); |
1027 } | 1069 } |
1028 | 1070 |
1029 | 1071 |
1030 void Assembler::decq(const Operand& dst) { | 1072 void Assembler::decq(const Operand& dst) { |
1031 EnsureSpace ensure_space(this); | 1073 EnsureSpace ensure_space(this); |
| 1074 last_pc_ = pc_; |
1032 emit_rex_64(dst); | 1075 emit_rex_64(dst); |
1033 emit(0xFF); | 1076 emit(0xFF); |
1034 emit_operand(1, dst); | 1077 emit_operand(1, dst); |
1035 } | 1078 } |
1036 | 1079 |
1037 | 1080 |
1038 void Assembler::decl(Register dst) { | 1081 void Assembler::decl(Register dst) { |
1039 EnsureSpace ensure_space(this); | 1082 EnsureSpace ensure_space(this); |
| 1083 last_pc_ = pc_; |
1040 emit_optional_rex_32(dst); | 1084 emit_optional_rex_32(dst); |
1041 emit(0xFF); | 1085 emit(0xFF); |
1042 emit_modrm(0x1, dst); | 1086 emit_modrm(0x1, dst); |
1043 } | 1087 } |
1044 | 1088 |
1045 | 1089 |
1046 void Assembler::decl(const Operand& dst) { | 1090 void Assembler::decl(const Operand& dst) { |
1047 EnsureSpace ensure_space(this); | 1091 EnsureSpace ensure_space(this); |
| 1092 last_pc_ = pc_; |
1048 emit_optional_rex_32(dst); | 1093 emit_optional_rex_32(dst); |
1049 emit(0xFF); | 1094 emit(0xFF); |
1050 emit_operand(1, dst); | 1095 emit_operand(1, dst); |
1051 } | 1096 } |
1052 | 1097 |
1053 | 1098 |
1054 void Assembler::decb(Register dst) { | 1099 void Assembler::decb(Register dst) { |
1055 EnsureSpace ensure_space(this); | 1100 EnsureSpace ensure_space(this); |
| 1101 last_pc_ = pc_; |
1056 if (dst.code() > 3) { | 1102 if (dst.code() > 3) { |
1057 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 1103 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
1058 emit_rex_32(dst); | 1104 emit_rex_32(dst); |
1059 } | 1105 } |
1060 emit(0xFE); | 1106 emit(0xFE); |
1061 emit_modrm(0x1, dst); | 1107 emit_modrm(0x1, dst); |
1062 } | 1108 } |
1063 | 1109 |
1064 | 1110 |
1065 void Assembler::decb(const Operand& dst) { | 1111 void Assembler::decb(const Operand& dst) { |
1066 EnsureSpace ensure_space(this); | 1112 EnsureSpace ensure_space(this); |
| 1113 last_pc_ = pc_; |
1067 emit_optional_rex_32(dst); | 1114 emit_optional_rex_32(dst); |
1068 emit(0xFE); | 1115 emit(0xFE); |
1069 emit_operand(1, dst); | 1116 emit_operand(1, dst); |
1070 } | 1117 } |
1071 | 1118 |
1072 | 1119 |
1073 void Assembler::enter(Immediate size) { | 1120 void Assembler::enter(Immediate size) { |
1074 EnsureSpace ensure_space(this); | 1121 EnsureSpace ensure_space(this); |
| 1122 last_pc_ = pc_; |
1075 emit(0xC8); | 1123 emit(0xC8); |
1076 emitw(size.value_); // 16 bit operand, always. | 1124 emitw(size.value_); // 16 bit operand, always. |
1077 emit(0); | 1125 emit(0); |
1078 } | 1126 } |
1079 | 1127 |
1080 | 1128 |
1081 void Assembler::hlt() { | 1129 void Assembler::hlt() { |
1082 EnsureSpace ensure_space(this); | 1130 EnsureSpace ensure_space(this); |
| 1131 last_pc_ = pc_; |
1083 emit(0xF4); | 1132 emit(0xF4); |
1084 } | 1133 } |
1085 | 1134 |
1086 | 1135 |
1087 void Assembler::idivq(Register src) { | 1136 void Assembler::idivq(Register src) { |
1088 EnsureSpace ensure_space(this); | 1137 EnsureSpace ensure_space(this); |
| 1138 last_pc_ = pc_; |
1089 emit_rex_64(src); | 1139 emit_rex_64(src); |
1090 emit(0xF7); | 1140 emit(0xF7); |
1091 emit_modrm(0x7, src); | 1141 emit_modrm(0x7, src); |
1092 } | 1142 } |
1093 | 1143 |
1094 | 1144 |
1095 void Assembler::idivl(Register src) { | 1145 void Assembler::idivl(Register src) { |
1096 EnsureSpace ensure_space(this); | 1146 EnsureSpace ensure_space(this); |
| 1147 last_pc_ = pc_; |
1097 emit_optional_rex_32(src); | 1148 emit_optional_rex_32(src); |
1098 emit(0xF7); | 1149 emit(0xF7); |
1099 emit_modrm(0x7, src); | 1150 emit_modrm(0x7, src); |
1100 } | 1151 } |
1101 | 1152 |
1102 | 1153 |
1103 void Assembler::imul(Register src) { | 1154 void Assembler::imul(Register src) { |
1104 EnsureSpace ensure_space(this); | 1155 EnsureSpace ensure_space(this); |
| 1156 last_pc_ = pc_; |
1105 emit_rex_64(src); | 1157 emit_rex_64(src); |
1106 emit(0xF7); | 1158 emit(0xF7); |
1107 emit_modrm(0x5, src); | 1159 emit_modrm(0x5, src); |
1108 } | 1160 } |
1109 | 1161 |
1110 | 1162 |
1111 void Assembler::imul(Register dst, Register src) { | 1163 void Assembler::imul(Register dst, Register src) { |
1112 EnsureSpace ensure_space(this); | 1164 EnsureSpace ensure_space(this); |
| 1165 last_pc_ = pc_; |
1113 emit_rex_64(dst, src); | 1166 emit_rex_64(dst, src); |
1114 emit(0x0F); | 1167 emit(0x0F); |
1115 emit(0xAF); | 1168 emit(0xAF); |
1116 emit_modrm(dst, src); | 1169 emit_modrm(dst, src); |
1117 } | 1170 } |
1118 | 1171 |
1119 | 1172 |
1120 void Assembler::imul(Register dst, const Operand& src) { | 1173 void Assembler::imul(Register dst, const Operand& src) { |
1121 EnsureSpace ensure_space(this); | 1174 EnsureSpace ensure_space(this); |
| 1175 last_pc_ = pc_; |
1122 emit_rex_64(dst, src); | 1176 emit_rex_64(dst, src); |
1123 emit(0x0F); | 1177 emit(0x0F); |
1124 emit(0xAF); | 1178 emit(0xAF); |
1125 emit_operand(dst, src); | 1179 emit_operand(dst, src); |
1126 } | 1180 } |
1127 | 1181 |
1128 | 1182 |
1129 void Assembler::imul(Register dst, Register src, Immediate imm) { | 1183 void Assembler::imul(Register dst, Register src, Immediate imm) { |
1130 EnsureSpace ensure_space(this); | 1184 EnsureSpace ensure_space(this); |
| 1185 last_pc_ = pc_; |
1131 emit_rex_64(dst, src); | 1186 emit_rex_64(dst, src); |
1132 if (is_int8(imm.value_)) { | 1187 if (is_int8(imm.value_)) { |
1133 emit(0x6B); | 1188 emit(0x6B); |
1134 emit_modrm(dst, src); | 1189 emit_modrm(dst, src); |
1135 emit(imm.value_); | 1190 emit(imm.value_); |
1136 } else { | 1191 } else { |
1137 emit(0x69); | 1192 emit(0x69); |
1138 emit_modrm(dst, src); | 1193 emit_modrm(dst, src); |
1139 emitl(imm.value_); | 1194 emitl(imm.value_); |
1140 } | 1195 } |
1141 } | 1196 } |
1142 | 1197 |
1143 | 1198 |
1144 void Assembler::imull(Register dst, Register src) { | 1199 void Assembler::imull(Register dst, Register src) { |
1145 EnsureSpace ensure_space(this); | 1200 EnsureSpace ensure_space(this); |
| 1201 last_pc_ = pc_; |
1146 emit_optional_rex_32(dst, src); | 1202 emit_optional_rex_32(dst, src); |
1147 emit(0x0F); | 1203 emit(0x0F); |
1148 emit(0xAF); | 1204 emit(0xAF); |
1149 emit_modrm(dst, src); | 1205 emit_modrm(dst, src); |
1150 } | 1206 } |
1151 | 1207 |
1152 | 1208 |
1153 void Assembler::imull(Register dst, const Operand& src) { | 1209 void Assembler::imull(Register dst, const Operand& src) { |
1154 EnsureSpace ensure_space(this); | 1210 EnsureSpace ensure_space(this); |
| 1211 last_pc_ = pc_; |
1155 emit_optional_rex_32(dst, src); | 1212 emit_optional_rex_32(dst, src); |
1156 emit(0x0F); | 1213 emit(0x0F); |
1157 emit(0xAF); | 1214 emit(0xAF); |
1158 emit_operand(dst, src); | 1215 emit_operand(dst, src); |
1159 } | 1216 } |
1160 | 1217 |
1161 | 1218 |
1162 void Assembler::imull(Register dst, Register src, Immediate imm) { | 1219 void Assembler::imull(Register dst, Register src, Immediate imm) { |
1163 EnsureSpace ensure_space(this); | 1220 EnsureSpace ensure_space(this); |
| 1221 last_pc_ = pc_; |
1164 emit_optional_rex_32(dst, src); | 1222 emit_optional_rex_32(dst, src); |
1165 if (is_int8(imm.value_)) { | 1223 if (is_int8(imm.value_)) { |
1166 emit(0x6B); | 1224 emit(0x6B); |
1167 emit_modrm(dst, src); | 1225 emit_modrm(dst, src); |
1168 emit(imm.value_); | 1226 emit(imm.value_); |
1169 } else { | 1227 } else { |
1170 emit(0x69); | 1228 emit(0x69); |
1171 emit_modrm(dst, src); | 1229 emit_modrm(dst, src); |
1172 emitl(imm.value_); | 1230 emitl(imm.value_); |
1173 } | 1231 } |
1174 } | 1232 } |
1175 | 1233 |
1176 | 1234 |
1177 void Assembler::incq(Register dst) { | 1235 void Assembler::incq(Register dst) { |
1178 EnsureSpace ensure_space(this); | 1236 EnsureSpace ensure_space(this); |
| 1237 last_pc_ = pc_; |
1179 emit_rex_64(dst); | 1238 emit_rex_64(dst); |
1180 emit(0xFF); | 1239 emit(0xFF); |
1181 emit_modrm(0x0, dst); | 1240 emit_modrm(0x0, dst); |
1182 } | 1241 } |
1183 | 1242 |
1184 | 1243 |
1185 void Assembler::incq(const Operand& dst) { | 1244 void Assembler::incq(const Operand& dst) { |
1186 EnsureSpace ensure_space(this); | 1245 EnsureSpace ensure_space(this); |
| 1246 last_pc_ = pc_; |
1187 emit_rex_64(dst); | 1247 emit_rex_64(dst); |
1188 emit(0xFF); | 1248 emit(0xFF); |
1189 emit_operand(0, dst); | 1249 emit_operand(0, dst); |
1190 } | 1250 } |
1191 | 1251 |
1192 | 1252 |
1193 void Assembler::incl(const Operand& dst) { | 1253 void Assembler::incl(const Operand& dst) { |
1194 EnsureSpace ensure_space(this); | 1254 EnsureSpace ensure_space(this); |
| 1255 last_pc_ = pc_; |
1195 emit_optional_rex_32(dst); | 1256 emit_optional_rex_32(dst); |
1196 emit(0xFF); | 1257 emit(0xFF); |
1197 emit_operand(0, dst); | 1258 emit_operand(0, dst); |
1198 } | 1259 } |
1199 | 1260 |
1200 | 1261 |
1201 void Assembler::incl(Register dst) { | 1262 void Assembler::incl(Register dst) { |
1202 EnsureSpace ensure_space(this); | 1263 EnsureSpace ensure_space(this); |
| 1264 last_pc_ = pc_; |
1203 emit_optional_rex_32(dst); | 1265 emit_optional_rex_32(dst); |
1204 emit(0xFF); | 1266 emit(0xFF); |
1205 emit_modrm(0, dst); | 1267 emit_modrm(0, dst); |
1206 } | 1268 } |
1207 | 1269 |
1208 | 1270 |
1209 void Assembler::int3() { | 1271 void Assembler::int3() { |
1210 EnsureSpace ensure_space(this); | 1272 EnsureSpace ensure_space(this); |
| 1273 last_pc_ = pc_; |
1211 emit(0xCC); | 1274 emit(0xCC); |
1212 } | 1275 } |
1213 | 1276 |
1214 | 1277 |
1215 void Assembler::j(Condition cc, Label* L) { | 1278 void Assembler::j(Condition cc, Label* L) { |
1216 if (cc == always) { | 1279 if (cc == always) { |
1217 jmp(L); | 1280 jmp(L); |
1218 return; | 1281 return; |
1219 } else if (cc == never) { | 1282 } else if (cc == never) { |
1220 return; | 1283 return; |
1221 } | 1284 } |
1222 EnsureSpace ensure_space(this); | 1285 EnsureSpace ensure_space(this); |
| 1286 last_pc_ = pc_; |
1223 ASSERT(is_uint4(cc)); | 1287 ASSERT(is_uint4(cc)); |
1224 if (L->is_bound()) { | 1288 if (L->is_bound()) { |
1225 const int short_size = 2; | 1289 const int short_size = 2; |
1226 const int long_size = 6; | 1290 const int long_size = 6; |
1227 int offs = L->pos() - pc_offset(); | 1291 int offs = L->pos() - pc_offset(); |
1228 ASSERT(offs <= 0); | 1292 ASSERT(offs <= 0); |
1229 if (is_int8(offs - short_size)) { | 1293 if (is_int8(offs - short_size)) { |
1230 // 0111 tttn #8-bit disp. | 1294 // 0111 tttn #8-bit disp. |
1231 emit(0x70 | cc); | 1295 emit(0x70 | cc); |
1232 emit((offs - short_size) & 0xFF); | 1296 emit((offs - short_size) & 0xFF); |
(...skipping 17 matching lines...) Expand all Loading... |
1250 emitl(current); | 1314 emitl(current); |
1251 L->link_to(current); | 1315 L->link_to(current); |
1252 } | 1316 } |
1253 } | 1317 } |
1254 | 1318 |
1255 | 1319 |
1256 void Assembler::j(Condition cc, | 1320 void Assembler::j(Condition cc, |
1257 Handle<Code> target, | 1321 Handle<Code> target, |
1258 RelocInfo::Mode rmode) { | 1322 RelocInfo::Mode rmode) { |
1259 EnsureSpace ensure_space(this); | 1323 EnsureSpace ensure_space(this); |
| 1324 last_pc_ = pc_; |
1260 ASSERT(is_uint4(cc)); | 1325 ASSERT(is_uint4(cc)); |
1261 // 0000 1111 1000 tttn #32-bit disp. | 1326 // 0000 1111 1000 tttn #32-bit disp. |
1262 emit(0x0F); | 1327 emit(0x0F); |
1263 emit(0x80 | cc); | 1328 emit(0x80 | cc); |
1264 emit_code_target(target, rmode); | 1329 emit_code_target(target, rmode); |
1265 } | 1330 } |
1266 | 1331 |
1267 | 1332 |
1268 void Assembler::j(Condition cc, NearLabel* L, Hint hint) { | 1333 void Assembler::j(Condition cc, NearLabel* L, Hint hint) { |
1269 EnsureSpace ensure_space(this); | 1334 EnsureSpace ensure_space(this); |
| 1335 last_pc_ = pc_; |
1270 ASSERT(0 <= cc && cc < 16); | 1336 ASSERT(0 <= cc && cc < 16); |
1271 if (FLAG_emit_branch_hints && hint != no_hint) emit(hint); | 1337 if (FLAG_emit_branch_hints && hint != no_hint) emit(hint); |
1272 if (L->is_bound()) { | 1338 if (L->is_bound()) { |
1273 const int short_size = 2; | 1339 const int short_size = 2; |
1274 int offs = L->pos() - pc_offset(); | 1340 int offs = L->pos() - pc_offset(); |
1275 ASSERT(offs <= 0); | 1341 ASSERT(offs <= 0); |
1276 ASSERT(is_int8(offs - short_size)); | 1342 ASSERT(is_int8(offs - short_size)); |
1277 // 0111 tttn #8-bit disp | 1343 // 0111 tttn #8-bit disp |
1278 emit(0x70 | cc); | 1344 emit(0x70 | cc); |
1279 emit((offs - short_size) & 0xFF); | 1345 emit((offs - short_size) & 0xFF); |
1280 } else { | 1346 } else { |
1281 emit(0x70 | cc); | 1347 emit(0x70 | cc); |
1282 emit(0x00); // The displacement will be resolved later. | 1348 emit(0x00); // The displacement will be resolved later. |
1283 L->link_to(pc_offset()); | 1349 L->link_to(pc_offset()); |
1284 } | 1350 } |
1285 } | 1351 } |
1286 | 1352 |
1287 | 1353 |
1288 void Assembler::jmp(Label* L) { | 1354 void Assembler::jmp(Label* L) { |
1289 EnsureSpace ensure_space(this); | 1355 EnsureSpace ensure_space(this); |
| 1356 last_pc_ = pc_; |
1290 const int short_size = sizeof(int8_t); | 1357 const int short_size = sizeof(int8_t); |
1291 const int long_size = sizeof(int32_t); | 1358 const int long_size = sizeof(int32_t); |
1292 if (L->is_bound()) { | 1359 if (L->is_bound()) { |
1293 int offs = L->pos() - pc_offset() - 1; | 1360 int offs = L->pos() - pc_offset() - 1; |
1294 ASSERT(offs <= 0); | 1361 ASSERT(offs <= 0); |
1295 if (is_int8(offs - short_size)) { | 1362 if (is_int8(offs - short_size)) { |
1296 // 1110 1011 #8-bit disp. | 1363 // 1110 1011 #8-bit disp. |
1297 emit(0xEB); | 1364 emit(0xEB); |
1298 emit((offs - short_size) & 0xFF); | 1365 emit((offs - short_size) & 0xFF); |
1299 } else { | 1366 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
1312 emit(0xE9); | 1379 emit(0xE9); |
1313 int32_t current = pc_offset(); | 1380 int32_t current = pc_offset(); |
1314 emitl(current); | 1381 emitl(current); |
1315 L->link_to(current); | 1382 L->link_to(current); |
1316 } | 1383 } |
1317 } | 1384 } |
1318 | 1385 |
1319 | 1386 |
1320 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { | 1387 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { |
1321 EnsureSpace ensure_space(this); | 1388 EnsureSpace ensure_space(this); |
| 1389 last_pc_ = pc_; |
1322 // 1110 1001 #32-bit disp. | 1390 // 1110 1001 #32-bit disp. |
1323 emit(0xE9); | 1391 emit(0xE9); |
1324 emit_code_target(target, rmode); | 1392 emit_code_target(target, rmode); |
1325 } | 1393 } |
1326 | 1394 |
1327 | 1395 |
1328 void Assembler::jmp(NearLabel* L) { | 1396 void Assembler::jmp(NearLabel* L) { |
1329 EnsureSpace ensure_space(this); | 1397 EnsureSpace ensure_space(this); |
| 1398 last_pc_ = pc_; |
1330 if (L->is_bound()) { | 1399 if (L->is_bound()) { |
1331 const int short_size = sizeof(int8_t); | 1400 const int short_size = sizeof(int8_t); |
1332 int offs = L->pos() - pc_offset(); | 1401 int offs = L->pos() - pc_offset(); |
1333 ASSERT(offs <= 0); | 1402 ASSERT(offs <= 0); |
1334 ASSERT(is_int8(offs - short_size)); | 1403 ASSERT(is_int8(offs - short_size)); |
1335 // 1110 1011 #8-bit disp. | 1404 // 1110 1011 #8-bit disp. |
1336 emit(0xEB); | 1405 emit(0xEB); |
1337 emit((offs - short_size) & 0xFF); | 1406 emit((offs - short_size) & 0xFF); |
1338 } else { | 1407 } else { |
1339 emit(0xEB); | 1408 emit(0xEB); |
1340 emit(0x00); // The displacement will be resolved later. | 1409 emit(0x00); // The displacement will be resolved later. |
1341 L->link_to(pc_offset()); | 1410 L->link_to(pc_offset()); |
1342 } | 1411 } |
1343 } | 1412 } |
1344 | 1413 |
1345 | 1414 |
1346 void Assembler::jmp(Register target) { | 1415 void Assembler::jmp(Register target) { |
1347 EnsureSpace ensure_space(this); | 1416 EnsureSpace ensure_space(this); |
| 1417 last_pc_ = pc_; |
1348 // Opcode FF/4 r64. | 1418 // Opcode FF/4 r64. |
1349 emit_optional_rex_32(target); | 1419 emit_optional_rex_32(target); |
1350 emit(0xFF); | 1420 emit(0xFF); |
1351 emit_modrm(0x4, target); | 1421 emit_modrm(0x4, target); |
1352 } | 1422 } |
1353 | 1423 |
1354 | 1424 |
1355 void Assembler::jmp(const Operand& src) { | 1425 void Assembler::jmp(const Operand& src) { |
1356 EnsureSpace ensure_space(this); | 1426 EnsureSpace ensure_space(this); |
| 1427 last_pc_ = pc_; |
1357 // Opcode FF/4 m64. | 1428 // Opcode FF/4 m64. |
1358 emit_optional_rex_32(src); | 1429 emit_optional_rex_32(src); |
1359 emit(0xFF); | 1430 emit(0xFF); |
1360 emit_operand(0x4, src); | 1431 emit_operand(0x4, src); |
1361 } | 1432 } |
1362 | 1433 |
1363 | 1434 |
1364 void Assembler::lea(Register dst, const Operand& src) { | 1435 void Assembler::lea(Register dst, const Operand& src) { |
1365 EnsureSpace ensure_space(this); | 1436 EnsureSpace ensure_space(this); |
| 1437 last_pc_ = pc_; |
1366 emit_rex_64(dst, src); | 1438 emit_rex_64(dst, src); |
1367 emit(0x8D); | 1439 emit(0x8D); |
1368 emit_operand(dst, src); | 1440 emit_operand(dst, src); |
1369 } | 1441 } |
1370 | 1442 |
1371 | 1443 |
1372 void Assembler::leal(Register dst, const Operand& src) { | 1444 void Assembler::leal(Register dst, const Operand& src) { |
1373 EnsureSpace ensure_space(this); | 1445 EnsureSpace ensure_space(this); |
| 1446 last_pc_ = pc_; |
1374 emit_optional_rex_32(dst, src); | 1447 emit_optional_rex_32(dst, src); |
1375 emit(0x8D); | 1448 emit(0x8D); |
1376 emit_operand(dst, src); | 1449 emit_operand(dst, src); |
1377 } | 1450 } |
1378 | 1451 |
1379 | 1452 |
1380 void Assembler::load_rax(void* value, RelocInfo::Mode mode) { | 1453 void Assembler::load_rax(void* value, RelocInfo::Mode mode) { |
1381 EnsureSpace ensure_space(this); | 1454 EnsureSpace ensure_space(this); |
| 1455 last_pc_ = pc_; |
1382 emit(0x48); // REX.W | 1456 emit(0x48); // REX.W |
1383 emit(0xA1); | 1457 emit(0xA1); |
1384 emitq(reinterpret_cast<uintptr_t>(value), mode); | 1458 emitq(reinterpret_cast<uintptr_t>(value), mode); |
1385 } | 1459 } |
1386 | 1460 |
1387 | 1461 |
1388 void Assembler::load_rax(ExternalReference ref) { | 1462 void Assembler::load_rax(ExternalReference ref) { |
1389 load_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); | 1463 load_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); |
1390 } | 1464 } |
1391 | 1465 |
1392 | 1466 |
1393 void Assembler::leave() { | 1467 void Assembler::leave() { |
1394 EnsureSpace ensure_space(this); | 1468 EnsureSpace ensure_space(this); |
| 1469 last_pc_ = pc_; |
1395 emit(0xC9); | 1470 emit(0xC9); |
1396 } | 1471 } |
1397 | 1472 |
1398 | 1473 |
1399 void Assembler::movb(Register dst, const Operand& src) { | 1474 void Assembler::movb(Register dst, const Operand& src) { |
1400 EnsureSpace ensure_space(this); | 1475 EnsureSpace ensure_space(this); |
| 1476 last_pc_ = pc_; |
1401 emit_rex_32(dst, src); | 1477 emit_rex_32(dst, src); |
1402 emit(0x8A); | 1478 emit(0x8A); |
1403 emit_operand(dst, src); | 1479 emit_operand(dst, src); |
1404 } | 1480 } |
1405 | 1481 |
1406 | 1482 |
1407 void Assembler::movb(Register dst, Immediate imm) { | 1483 void Assembler::movb(Register dst, Immediate imm) { |
1408 EnsureSpace ensure_space(this); | 1484 EnsureSpace ensure_space(this); |
| 1485 last_pc_ = pc_; |
1409 emit_rex_32(dst); | 1486 emit_rex_32(dst); |
1410 emit(0xC6); | 1487 emit(0xC6); |
1411 emit_modrm(0x0, dst); | 1488 emit_modrm(0x0, dst); |
1412 emit(imm.value_); | 1489 emit(imm.value_); |
1413 } | 1490 } |
1414 | 1491 |
1415 | 1492 |
1416 void Assembler::movb(const Operand& dst, Register src) { | 1493 void Assembler::movb(const Operand& dst, Register src) { |
1417 EnsureSpace ensure_space(this); | 1494 EnsureSpace ensure_space(this); |
| 1495 last_pc_ = pc_; |
1418 emit_rex_32(src, dst); | 1496 emit_rex_32(src, dst); |
1419 emit(0x88); | 1497 emit(0x88); |
1420 emit_operand(src, dst); | 1498 emit_operand(src, dst); |
1421 } | 1499 } |
1422 | 1500 |
1423 | 1501 |
1424 void Assembler::movw(const Operand& dst, Register src) { | 1502 void Assembler::movw(const Operand& dst, Register src) { |
1425 EnsureSpace ensure_space(this); | 1503 EnsureSpace ensure_space(this); |
| 1504 last_pc_ = pc_; |
1426 emit(0x66); | 1505 emit(0x66); |
1427 emit_optional_rex_32(src, dst); | 1506 emit_optional_rex_32(src, dst); |
1428 emit(0x89); | 1507 emit(0x89); |
1429 emit_operand(src, dst); | 1508 emit_operand(src, dst); |
1430 } | 1509 } |
1431 | 1510 |
1432 | 1511 |
1433 void Assembler::movl(Register dst, const Operand& src) { | 1512 void Assembler::movl(Register dst, const Operand& src) { |
1434 EnsureSpace ensure_space(this); | 1513 EnsureSpace ensure_space(this); |
| 1514 last_pc_ = pc_; |
1435 emit_optional_rex_32(dst, src); | 1515 emit_optional_rex_32(dst, src); |
1436 emit(0x8B); | 1516 emit(0x8B); |
1437 emit_operand(dst, src); | 1517 emit_operand(dst, src); |
1438 } | 1518 } |
1439 | 1519 |
1440 | 1520 |
1441 void Assembler::movl(Register dst, Register src) { | 1521 void Assembler::movl(Register dst, Register src) { |
1442 EnsureSpace ensure_space(this); | 1522 EnsureSpace ensure_space(this); |
| 1523 last_pc_ = pc_; |
1443 if (src.low_bits() == 4) { | 1524 if (src.low_bits() == 4) { |
1444 emit_optional_rex_32(src, dst); | 1525 emit_optional_rex_32(src, dst); |
1445 emit(0x89); | 1526 emit(0x89); |
1446 emit_modrm(src, dst); | 1527 emit_modrm(src, dst); |
1447 } else { | 1528 } else { |
1448 emit_optional_rex_32(dst, src); | 1529 emit_optional_rex_32(dst, src); |
1449 emit(0x8B); | 1530 emit(0x8B); |
1450 emit_modrm(dst, src); | 1531 emit_modrm(dst, src); |
1451 } | 1532 } |
1452 } | 1533 } |
1453 | 1534 |
1454 | 1535 |
1455 void Assembler::movl(const Operand& dst, Register src) { | 1536 void Assembler::movl(const Operand& dst, Register src) { |
1456 EnsureSpace ensure_space(this); | 1537 EnsureSpace ensure_space(this); |
| 1538 last_pc_ = pc_; |
1457 emit_optional_rex_32(src, dst); | 1539 emit_optional_rex_32(src, dst); |
1458 emit(0x89); | 1540 emit(0x89); |
1459 emit_operand(src, dst); | 1541 emit_operand(src, dst); |
1460 } | 1542 } |
1461 | 1543 |
1462 | 1544 |
1463 void Assembler::movl(const Operand& dst, Immediate value) { | 1545 void Assembler::movl(const Operand& dst, Immediate value) { |
1464 EnsureSpace ensure_space(this); | 1546 EnsureSpace ensure_space(this); |
| 1547 last_pc_ = pc_; |
1465 emit_optional_rex_32(dst); | 1548 emit_optional_rex_32(dst); |
1466 emit(0xC7); | 1549 emit(0xC7); |
1467 emit_operand(0x0, dst); | 1550 emit_operand(0x0, dst); |
1468 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. | 1551 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. |
1469 } | 1552 } |
1470 | 1553 |
1471 | 1554 |
1472 void Assembler::movl(Register dst, Immediate value) { | 1555 void Assembler::movl(Register dst, Immediate value) { |
1473 EnsureSpace ensure_space(this); | 1556 EnsureSpace ensure_space(this); |
| 1557 last_pc_ = pc_; |
1474 emit_optional_rex_32(dst); | 1558 emit_optional_rex_32(dst); |
1475 emit(0xC7); | 1559 emit(0xC7); |
1476 emit_modrm(0x0, dst); | 1560 emit_modrm(0x0, dst); |
1477 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. | 1561 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. |
1478 } | 1562 } |
1479 | 1563 |
1480 | 1564 |
1481 void Assembler::movq(Register dst, const Operand& src) { | 1565 void Assembler::movq(Register dst, const Operand& src) { |
1482 EnsureSpace ensure_space(this); | 1566 EnsureSpace ensure_space(this); |
| 1567 last_pc_ = pc_; |
1483 emit_rex_64(dst, src); | 1568 emit_rex_64(dst, src); |
1484 emit(0x8B); | 1569 emit(0x8B); |
1485 emit_operand(dst, src); | 1570 emit_operand(dst, src); |
1486 } | 1571 } |
1487 | 1572 |
1488 | 1573 |
1489 void Assembler::movq(Register dst, Register src) { | 1574 void Assembler::movq(Register dst, Register src) { |
1490 EnsureSpace ensure_space(this); | 1575 EnsureSpace ensure_space(this); |
| 1576 last_pc_ = pc_; |
1491 if (src.low_bits() == 4) { | 1577 if (src.low_bits() == 4) { |
1492 emit_rex_64(src, dst); | 1578 emit_rex_64(src, dst); |
1493 emit(0x89); | 1579 emit(0x89); |
1494 emit_modrm(src, dst); | 1580 emit_modrm(src, dst); |
1495 } else { | 1581 } else { |
1496 emit_rex_64(dst, src); | 1582 emit_rex_64(dst, src); |
1497 emit(0x8B); | 1583 emit(0x8B); |
1498 emit_modrm(dst, src); | 1584 emit_modrm(dst, src); |
1499 } | 1585 } |
1500 } | 1586 } |
1501 | 1587 |
1502 | 1588 |
1503 void Assembler::movq(Register dst, Immediate value) { | 1589 void Assembler::movq(Register dst, Immediate value) { |
1504 EnsureSpace ensure_space(this); | 1590 EnsureSpace ensure_space(this); |
| 1591 last_pc_ = pc_; |
1505 emit_rex_64(dst); | 1592 emit_rex_64(dst); |
1506 emit(0xC7); | 1593 emit(0xC7); |
1507 emit_modrm(0x0, dst); | 1594 emit_modrm(0x0, dst); |
1508 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. | 1595 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. |
1509 } | 1596 } |
1510 | 1597 |
1511 | 1598 |
1512 void Assembler::movq(const Operand& dst, Register src) { | 1599 void Assembler::movq(const Operand& dst, Register src) { |
1513 EnsureSpace ensure_space(this); | 1600 EnsureSpace ensure_space(this); |
| 1601 last_pc_ = pc_; |
1514 emit_rex_64(src, dst); | 1602 emit_rex_64(src, dst); |
1515 emit(0x89); | 1603 emit(0x89); |
1516 emit_operand(src, dst); | 1604 emit_operand(src, dst); |
1517 } | 1605 } |
1518 | 1606 |
1519 | 1607 |
1520 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { | 1608 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { |
1521 // This method must not be used with heap object references. The stored | 1609 // This method must not be used with heap object references. The stored |
1522 // address is not GC safe. Use the handle version instead. | 1610 // address is not GC safe. Use the handle version instead. |
1523 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); | 1611 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); |
1524 EnsureSpace ensure_space(this); | 1612 EnsureSpace ensure_space(this); |
| 1613 last_pc_ = pc_; |
1525 emit_rex_64(dst); | 1614 emit_rex_64(dst); |
1526 emit(0xB8 | dst.low_bits()); | 1615 emit(0xB8 | dst.low_bits()); |
1527 emitq(reinterpret_cast<uintptr_t>(value), rmode); | 1616 emitq(reinterpret_cast<uintptr_t>(value), rmode); |
1528 } | 1617 } |
1529 | 1618 |
1530 | 1619 |
1531 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) { | 1620 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) { |
1532 // Non-relocatable values might not need a 64-bit representation. | 1621 // Non-relocatable values might not need a 64-bit representation. |
1533 if (rmode == RelocInfo::NONE) { | 1622 if (rmode == RelocInfo::NONE) { |
1534 // Sadly, there is no zero or sign extending move for 8-bit immediates. | 1623 // Sadly, there is no zero or sign extending move for 8-bit immediates. |
1535 if (is_int32(value)) { | 1624 if (is_int32(value)) { |
1536 movq(dst, Immediate(static_cast<int32_t>(value))); | 1625 movq(dst, Immediate(static_cast<int32_t>(value))); |
1537 return; | 1626 return; |
1538 } else if (is_uint32(value)) { | 1627 } else if (is_uint32(value)) { |
1539 movl(dst, Immediate(static_cast<int32_t>(value))); | 1628 movl(dst, Immediate(static_cast<int32_t>(value))); |
1540 return; | 1629 return; |
1541 } | 1630 } |
1542 // Value cannot be represented by 32 bits, so do a full 64 bit immediate | 1631 // Value cannot be represented by 32 bits, so do a full 64 bit immediate |
1543 // value. | 1632 // value. |
1544 } | 1633 } |
1545 EnsureSpace ensure_space(this); | 1634 EnsureSpace ensure_space(this); |
| 1635 last_pc_ = pc_; |
1546 emit_rex_64(dst); | 1636 emit_rex_64(dst); |
1547 emit(0xB8 | dst.low_bits()); | 1637 emit(0xB8 | dst.low_bits()); |
1548 emitq(value, rmode); | 1638 emitq(value, rmode); |
1549 } | 1639 } |
1550 | 1640 |
1551 | 1641 |
1552 void Assembler::movq(Register dst, ExternalReference ref) { | 1642 void Assembler::movq(Register dst, ExternalReference ref) { |
1553 int64_t value = reinterpret_cast<int64_t>(ref.address()); | 1643 int64_t value = reinterpret_cast<int64_t>(ref.address()); |
1554 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE); | 1644 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE); |
1555 } | 1645 } |
1556 | 1646 |
1557 | 1647 |
1558 void Assembler::movq(const Operand& dst, Immediate value) { | 1648 void Assembler::movq(const Operand& dst, Immediate value) { |
1559 EnsureSpace ensure_space(this); | 1649 EnsureSpace ensure_space(this); |
| 1650 last_pc_ = pc_; |
1560 emit_rex_64(dst); | 1651 emit_rex_64(dst); |
1561 emit(0xC7); | 1652 emit(0xC7); |
1562 emit_operand(0, dst); | 1653 emit_operand(0, dst); |
1563 emit(value); | 1654 emit(value); |
1564 } | 1655 } |
1565 | 1656 |
1566 | 1657 |
1567 // Loads the ip-relative location of the src label into the target location | 1658 // Loads the ip-relative location of the src label into the target location |
1568 // (as a 32-bit offset sign extended to 64-bit). | 1659 // (as a 32-bit offset sign extended to 64-bit). |
1569 void Assembler::movl(const Operand& dst, Label* src) { | 1660 void Assembler::movl(const Operand& dst, Label* src) { |
1570 EnsureSpace ensure_space(this); | 1661 EnsureSpace ensure_space(this); |
| 1662 last_pc_ = pc_; |
1571 emit_optional_rex_32(dst); | 1663 emit_optional_rex_32(dst); |
1572 emit(0xC7); | 1664 emit(0xC7); |
1573 emit_operand(0, dst); | 1665 emit_operand(0, dst); |
1574 if (src->is_bound()) { | 1666 if (src->is_bound()) { |
1575 int offset = src->pos() - pc_offset() - sizeof(int32_t); | 1667 int offset = src->pos() - pc_offset() - sizeof(int32_t); |
1576 ASSERT(offset <= 0); | 1668 ASSERT(offset <= 0); |
1577 emitl(offset); | 1669 emitl(offset); |
1578 } else if (src->is_linked()) { | 1670 } else if (src->is_linked()) { |
1579 emitl(src->pos()); | 1671 emitl(src->pos()); |
1580 src->link_to(pc_offset() - sizeof(int32_t)); | 1672 src->link_to(pc_offset() - sizeof(int32_t)); |
1581 } else { | 1673 } else { |
1582 ASSERT(src->is_unused()); | 1674 ASSERT(src->is_unused()); |
1583 int32_t current = pc_offset(); | 1675 int32_t current = pc_offset(); |
1584 emitl(current); | 1676 emitl(current); |
1585 src->link_to(current); | 1677 src->link_to(current); |
1586 } | 1678 } |
1587 } | 1679 } |
1588 | 1680 |
1589 | 1681 |
1590 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { | 1682 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { |
1591 // If there is no relocation info, emit the value of the handle efficiently | 1683 // If there is no relocation info, emit the value of the handle efficiently |
1592 // (possibly using less that 8 bytes for the value). | 1684 // (possibly using less that 8 bytes for the value). |
1593 if (mode == RelocInfo::NONE) { | 1685 if (mode == RelocInfo::NONE) { |
1594 // There is no possible reason to store a heap pointer without relocation | 1686 // There is no possible reason to store a heap pointer without relocation |
1595 // info, so it must be a smi. | 1687 // info, so it must be a smi. |
1596 ASSERT(value->IsSmi()); | 1688 ASSERT(value->IsSmi()); |
1597 movq(dst, reinterpret_cast<int64_t>(*value), RelocInfo::NONE); | 1689 movq(dst, reinterpret_cast<int64_t>(*value), RelocInfo::NONE); |
1598 } else { | 1690 } else { |
1599 EnsureSpace ensure_space(this); | 1691 EnsureSpace ensure_space(this); |
| 1692 last_pc_ = pc_; |
1600 ASSERT(value->IsHeapObject()); | 1693 ASSERT(value->IsHeapObject()); |
1601 ASSERT(!HEAP->InNewSpace(*value)); | 1694 ASSERT(!HEAP->InNewSpace(*value)); |
1602 emit_rex_64(dst); | 1695 emit_rex_64(dst); |
1603 emit(0xB8 | dst.low_bits()); | 1696 emit(0xB8 | dst.low_bits()); |
1604 emitq(reinterpret_cast<uintptr_t>(value.location()), mode); | 1697 emitq(reinterpret_cast<uintptr_t>(value.location()), mode); |
1605 } | 1698 } |
1606 } | 1699 } |
1607 | 1700 |
1608 | 1701 |
1609 void Assembler::movsxbq(Register dst, const Operand& src) { | 1702 void Assembler::movsxbq(Register dst, const Operand& src) { |
1610 EnsureSpace ensure_space(this); | 1703 EnsureSpace ensure_space(this); |
| 1704 last_pc_ = pc_; |
1611 emit_rex_64(dst, src); | 1705 emit_rex_64(dst, src); |
1612 emit(0x0F); | 1706 emit(0x0F); |
1613 emit(0xBE); | 1707 emit(0xBE); |
1614 emit_operand(dst, src); | 1708 emit_operand(dst, src); |
1615 } | 1709 } |
1616 | 1710 |
1617 | 1711 |
1618 void Assembler::movsxwq(Register dst, const Operand& src) { | 1712 void Assembler::movsxwq(Register dst, const Operand& src) { |
1619 EnsureSpace ensure_space(this); | 1713 EnsureSpace ensure_space(this); |
| 1714 last_pc_ = pc_; |
1620 emit_rex_64(dst, src); | 1715 emit_rex_64(dst, src); |
1621 emit(0x0F); | 1716 emit(0x0F); |
1622 emit(0xBF); | 1717 emit(0xBF); |
1623 emit_operand(dst, src); | 1718 emit_operand(dst, src); |
1624 } | 1719 } |
1625 | 1720 |
1626 | 1721 |
1627 void Assembler::movsxlq(Register dst, Register src) { | 1722 void Assembler::movsxlq(Register dst, Register src) { |
1628 EnsureSpace ensure_space(this); | 1723 EnsureSpace ensure_space(this); |
| 1724 last_pc_ = pc_; |
1629 emit_rex_64(dst, src); | 1725 emit_rex_64(dst, src); |
1630 emit(0x63); | 1726 emit(0x63); |
1631 emit_modrm(dst, src); | 1727 emit_modrm(dst, src); |
1632 } | 1728 } |
1633 | 1729 |
1634 | 1730 |
1635 void Assembler::movsxlq(Register dst, const Operand& src) { | 1731 void Assembler::movsxlq(Register dst, const Operand& src) { |
1636 EnsureSpace ensure_space(this); | 1732 EnsureSpace ensure_space(this); |
| 1733 last_pc_ = pc_; |
1637 emit_rex_64(dst, src); | 1734 emit_rex_64(dst, src); |
1638 emit(0x63); | 1735 emit(0x63); |
1639 emit_operand(dst, src); | 1736 emit_operand(dst, src); |
1640 } | 1737 } |
1641 | 1738 |
1642 | 1739 |
1643 void Assembler::movzxbq(Register dst, const Operand& src) { | 1740 void Assembler::movzxbq(Register dst, const Operand& src) { |
1644 EnsureSpace ensure_space(this); | 1741 EnsureSpace ensure_space(this); |
| 1742 last_pc_ = pc_; |
1645 emit_optional_rex_32(dst, src); | 1743 emit_optional_rex_32(dst, src); |
1646 emit(0x0F); | 1744 emit(0x0F); |
1647 emit(0xB6); | 1745 emit(0xB6); |
1648 emit_operand(dst, src); | 1746 emit_operand(dst, src); |
1649 } | 1747 } |
1650 | 1748 |
1651 | 1749 |
1652 void Assembler::movzxbl(Register dst, const Operand& src) { | 1750 void Assembler::movzxbl(Register dst, const Operand& src) { |
1653 EnsureSpace ensure_space(this); | 1751 EnsureSpace ensure_space(this); |
| 1752 last_pc_ = pc_; |
1654 emit_optional_rex_32(dst, src); | 1753 emit_optional_rex_32(dst, src); |
1655 emit(0x0F); | 1754 emit(0x0F); |
1656 emit(0xB6); | 1755 emit(0xB6); |
1657 emit_operand(dst, src); | 1756 emit_operand(dst, src); |
1658 } | 1757 } |
1659 | 1758 |
1660 | 1759 |
1661 void Assembler::movzxwq(Register dst, const Operand& src) { | 1760 void Assembler::movzxwq(Register dst, const Operand& src) { |
1662 EnsureSpace ensure_space(this); | 1761 EnsureSpace ensure_space(this); |
| 1762 last_pc_ = pc_; |
1663 emit_optional_rex_32(dst, src); | 1763 emit_optional_rex_32(dst, src); |
1664 emit(0x0F); | 1764 emit(0x0F); |
1665 emit(0xB7); | 1765 emit(0xB7); |
1666 emit_operand(dst, src); | 1766 emit_operand(dst, src); |
1667 } | 1767 } |
1668 | 1768 |
1669 | 1769 |
1670 void Assembler::movzxwl(Register dst, const Operand& src) { | 1770 void Assembler::movzxwl(Register dst, const Operand& src) { |
1671 EnsureSpace ensure_space(this); | 1771 EnsureSpace ensure_space(this); |
| 1772 last_pc_ = pc_; |
1672 emit_optional_rex_32(dst, src); | 1773 emit_optional_rex_32(dst, src); |
1673 emit(0x0F); | 1774 emit(0x0F); |
1674 emit(0xB7); | 1775 emit(0xB7); |
1675 emit_operand(dst, src); | 1776 emit_operand(dst, src); |
1676 } | 1777 } |
1677 | 1778 |
1678 | 1779 |
1679 void Assembler::repmovsb() { | 1780 void Assembler::repmovsb() { |
1680 EnsureSpace ensure_space(this); | 1781 EnsureSpace ensure_space(this); |
| 1782 last_pc_ = pc_; |
1681 emit(0xF3); | 1783 emit(0xF3); |
1682 emit(0xA4); | 1784 emit(0xA4); |
1683 } | 1785 } |
1684 | 1786 |
1685 | 1787 |
1686 void Assembler::repmovsw() { | 1788 void Assembler::repmovsw() { |
1687 EnsureSpace ensure_space(this); | 1789 EnsureSpace ensure_space(this); |
| 1790 last_pc_ = pc_; |
1688 emit(0x66); // Operand size override. | 1791 emit(0x66); // Operand size override. |
1689 emit(0xF3); | 1792 emit(0xF3); |
1690 emit(0xA4); | 1793 emit(0xA4); |
1691 } | 1794 } |
1692 | 1795 |
1693 | 1796 |
1694 void Assembler::repmovsl() { | 1797 void Assembler::repmovsl() { |
1695 EnsureSpace ensure_space(this); | 1798 EnsureSpace ensure_space(this); |
| 1799 last_pc_ = pc_; |
1696 emit(0xF3); | 1800 emit(0xF3); |
1697 emit(0xA5); | 1801 emit(0xA5); |
1698 } | 1802 } |
1699 | 1803 |
1700 | 1804 |
1701 void Assembler::repmovsq() { | 1805 void Assembler::repmovsq() { |
1702 EnsureSpace ensure_space(this); | 1806 EnsureSpace ensure_space(this); |
| 1807 last_pc_ = pc_; |
1703 emit(0xF3); | 1808 emit(0xF3); |
1704 emit_rex_64(); | 1809 emit_rex_64(); |
1705 emit(0xA5); | 1810 emit(0xA5); |
1706 } | 1811 } |
1707 | 1812 |
1708 | 1813 |
1709 void Assembler::mul(Register src) { | 1814 void Assembler::mul(Register src) { |
1710 EnsureSpace ensure_space(this); | 1815 EnsureSpace ensure_space(this); |
| 1816 last_pc_ = pc_; |
1711 emit_rex_64(src); | 1817 emit_rex_64(src); |
1712 emit(0xF7); | 1818 emit(0xF7); |
1713 emit_modrm(0x4, src); | 1819 emit_modrm(0x4, src); |
1714 } | 1820 } |
1715 | 1821 |
1716 | 1822 |
1717 void Assembler::neg(Register dst) { | 1823 void Assembler::neg(Register dst) { |
1718 EnsureSpace ensure_space(this); | 1824 EnsureSpace ensure_space(this); |
| 1825 last_pc_ = pc_; |
1719 emit_rex_64(dst); | 1826 emit_rex_64(dst); |
1720 emit(0xF7); | 1827 emit(0xF7); |
1721 emit_modrm(0x3, dst); | 1828 emit_modrm(0x3, dst); |
1722 } | 1829 } |
1723 | 1830 |
1724 | 1831 |
1725 void Assembler::negl(Register dst) { | 1832 void Assembler::negl(Register dst) { |
1726 EnsureSpace ensure_space(this); | 1833 EnsureSpace ensure_space(this); |
| 1834 last_pc_ = pc_; |
1727 emit_optional_rex_32(dst); | 1835 emit_optional_rex_32(dst); |
1728 emit(0xF7); | 1836 emit(0xF7); |
1729 emit_modrm(0x3, dst); | 1837 emit_modrm(0x3, dst); |
1730 } | 1838 } |
1731 | 1839 |
1732 | 1840 |
1733 void Assembler::neg(const Operand& dst) { | 1841 void Assembler::neg(const Operand& dst) { |
1734 EnsureSpace ensure_space(this); | 1842 EnsureSpace ensure_space(this); |
| 1843 last_pc_ = pc_; |
1735 emit_rex_64(dst); | 1844 emit_rex_64(dst); |
1736 emit(0xF7); | 1845 emit(0xF7); |
1737 emit_operand(3, dst); | 1846 emit_operand(3, dst); |
1738 } | 1847 } |
1739 | 1848 |
1740 | 1849 |
1741 void Assembler::nop() { | 1850 void Assembler::nop() { |
1742 EnsureSpace ensure_space(this); | 1851 EnsureSpace ensure_space(this); |
| 1852 last_pc_ = pc_; |
1743 emit(0x90); | 1853 emit(0x90); |
1744 } | 1854 } |
1745 | 1855 |
1746 | 1856 |
1747 void Assembler::not_(Register dst) { | 1857 void Assembler::not_(Register dst) { |
1748 EnsureSpace ensure_space(this); | 1858 EnsureSpace ensure_space(this); |
| 1859 last_pc_ = pc_; |
1749 emit_rex_64(dst); | 1860 emit_rex_64(dst); |
1750 emit(0xF7); | 1861 emit(0xF7); |
1751 emit_modrm(0x2, dst); | 1862 emit_modrm(0x2, dst); |
1752 } | 1863 } |
1753 | 1864 |
1754 | 1865 |
1755 void Assembler::not_(const Operand& dst) { | 1866 void Assembler::not_(const Operand& dst) { |
1756 EnsureSpace ensure_space(this); | 1867 EnsureSpace ensure_space(this); |
| 1868 last_pc_ = pc_; |
1757 emit_rex_64(dst); | 1869 emit_rex_64(dst); |
1758 emit(0xF7); | 1870 emit(0xF7); |
1759 emit_operand(2, dst); | 1871 emit_operand(2, dst); |
1760 } | 1872 } |
1761 | 1873 |
1762 | 1874 |
1763 void Assembler::notl(Register dst) { | 1875 void Assembler::notl(Register dst) { |
1764 EnsureSpace ensure_space(this); | 1876 EnsureSpace ensure_space(this); |
| 1877 last_pc_ = pc_; |
1765 emit_optional_rex_32(dst); | 1878 emit_optional_rex_32(dst); |
1766 emit(0xF7); | 1879 emit(0xF7); |
1767 emit_modrm(0x2, dst); | 1880 emit_modrm(0x2, dst); |
1768 } | 1881 } |
1769 | 1882 |
1770 | 1883 |
1771 void Assembler::nop(int n) { | 1884 void Assembler::nop(int n) { |
1772 // The recommended muti-byte sequences of NOP instructions from the Intel 64 | 1885 // The recommended muti-byte sequences of NOP instructions from the Intel 64 |
1773 // and IA-32 Architectures Software Developer's Manual. | 1886 // and IA-32 Architectures Software Developer's Manual. |
1774 // | 1887 // |
1775 // Length Assembly Byte Sequence | 1888 // Length Assembly Byte Sequence |
1776 // 2 bytes 66 NOP 66 90H | 1889 // 2 bytes 66 NOP 66 90H |
1777 // 3 bytes NOP DWORD ptr [EAX] 0F 1F 00H | 1890 // 3 bytes NOP DWORD ptr [EAX] 0F 1F 00H |
1778 // 4 bytes NOP DWORD ptr [EAX + 00H] 0F 1F 40 00H | 1891 // 4 bytes NOP DWORD ptr [EAX + 00H] 0F 1F 40 00H |
1779 // 5 bytes NOP DWORD ptr [EAX + EAX*1 + 00H] 0F 1F 44 00 00H | 1892 // 5 bytes NOP DWORD ptr [EAX + EAX*1 + 00H] 0F 1F 44 00 00H |
1780 // 6 bytes 66 NOP DWORD ptr [EAX + EAX*1 + 00H] 66 0F 1F 44 00 00H | 1893 // 6 bytes 66 NOP DWORD ptr [EAX + EAX*1 + 00H] 66 0F 1F 44 00 00H |
1781 // 7 bytes NOP DWORD ptr [EAX + 00000000H] 0F 1F 80 00 00 00 00H | 1894 // 7 bytes NOP DWORD ptr [EAX + 00000000H] 0F 1F 80 00 00 00 00H |
1782 // 8 bytes NOP DWORD ptr [EAX + EAX*1 + 00000000H] 0F 1F 84 00 00 00 00 00H | 1895 // 8 bytes NOP DWORD ptr [EAX + EAX*1 + 00000000H] 0F 1F 84 00 00 00 00 00H |
1783 // 9 bytes 66 NOP DWORD ptr [EAX + EAX*1 + 66 0F 1F 84 00 00 00 00 | 1896 // 9 bytes 66 NOP DWORD ptr [EAX + EAX*1 + 66 0F 1F 84 00 00 00 00 |
1784 // 00000000H] 00H | 1897 // 00000000H] 00H |
1785 | 1898 |
1786 ASSERT(1 <= n); | 1899 ASSERT(1 <= n); |
1787 ASSERT(n <= 9); | 1900 ASSERT(n <= 9); |
1788 EnsureSpace ensure_space(this); | 1901 EnsureSpace ensure_space(this); |
| 1902 last_pc_ = pc_; |
1789 switch (n) { | 1903 switch (n) { |
1790 case 1: | 1904 case 1: |
1791 emit(0x90); | 1905 emit(0x90); |
1792 return; | 1906 return; |
1793 case 2: | 1907 case 2: |
1794 emit(0x66); | 1908 emit(0x66); |
1795 emit(0x90); | 1909 emit(0x90); |
1796 return; | 1910 return; |
1797 case 3: | 1911 case 3: |
1798 emit(0x0f); | 1912 emit(0x0f); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 emit(0x00); | 1963 emit(0x00); |
1850 emit(0x00); | 1964 emit(0x00); |
1851 emit(0x00); | 1965 emit(0x00); |
1852 return; | 1966 return; |
1853 } | 1967 } |
1854 } | 1968 } |
1855 | 1969 |
1856 | 1970 |
1857 void Assembler::pop(Register dst) { | 1971 void Assembler::pop(Register dst) { |
1858 EnsureSpace ensure_space(this); | 1972 EnsureSpace ensure_space(this); |
| 1973 last_pc_ = pc_; |
1859 emit_optional_rex_32(dst); | 1974 emit_optional_rex_32(dst); |
1860 emit(0x58 | dst.low_bits()); | 1975 emit(0x58 | dst.low_bits()); |
1861 } | 1976 } |
1862 | 1977 |
1863 | 1978 |
1864 void Assembler::pop(const Operand& dst) { | 1979 void Assembler::pop(const Operand& dst) { |
1865 EnsureSpace ensure_space(this); | 1980 EnsureSpace ensure_space(this); |
| 1981 last_pc_ = pc_; |
1866 emit_optional_rex_32(dst); | 1982 emit_optional_rex_32(dst); |
1867 emit(0x8F); | 1983 emit(0x8F); |
1868 emit_operand(0, dst); | 1984 emit_operand(0, dst); |
1869 } | 1985 } |
1870 | 1986 |
1871 | 1987 |
1872 void Assembler::popfq() { | 1988 void Assembler::popfq() { |
1873 EnsureSpace ensure_space(this); | 1989 EnsureSpace ensure_space(this); |
| 1990 last_pc_ = pc_; |
1874 emit(0x9D); | 1991 emit(0x9D); |
1875 } | 1992 } |
1876 | 1993 |
1877 | 1994 |
1878 void Assembler::push(Register src) { | 1995 void Assembler::push(Register src) { |
1879 EnsureSpace ensure_space(this); | 1996 EnsureSpace ensure_space(this); |
| 1997 last_pc_ = pc_; |
1880 emit_optional_rex_32(src); | 1998 emit_optional_rex_32(src); |
1881 emit(0x50 | src.low_bits()); | 1999 emit(0x50 | src.low_bits()); |
1882 } | 2000 } |
1883 | 2001 |
1884 | 2002 |
1885 void Assembler::push(const Operand& src) { | 2003 void Assembler::push(const Operand& src) { |
1886 EnsureSpace ensure_space(this); | 2004 EnsureSpace ensure_space(this); |
| 2005 last_pc_ = pc_; |
1887 emit_optional_rex_32(src); | 2006 emit_optional_rex_32(src); |
1888 emit(0xFF); | 2007 emit(0xFF); |
1889 emit_operand(6, src); | 2008 emit_operand(6, src); |
1890 } | 2009 } |
1891 | 2010 |
1892 | 2011 |
1893 void Assembler::push(Immediate value) { | 2012 void Assembler::push(Immediate value) { |
1894 EnsureSpace ensure_space(this); | 2013 EnsureSpace ensure_space(this); |
| 2014 last_pc_ = pc_; |
1895 if (is_int8(value.value_)) { | 2015 if (is_int8(value.value_)) { |
1896 emit(0x6A); | 2016 emit(0x6A); |
1897 emit(value.value_); // Emit low byte of value. | 2017 emit(value.value_); // Emit low byte of value. |
1898 } else { | 2018 } else { |
1899 emit(0x68); | 2019 emit(0x68); |
1900 emitl(value.value_); | 2020 emitl(value.value_); |
1901 } | 2021 } |
1902 } | 2022 } |
1903 | 2023 |
1904 | 2024 |
1905 void Assembler::push_imm32(int32_t imm32) { | 2025 void Assembler::push_imm32(int32_t imm32) { |
1906 EnsureSpace ensure_space(this); | 2026 EnsureSpace ensure_space(this); |
| 2027 last_pc_ = pc_; |
1907 emit(0x68); | 2028 emit(0x68); |
1908 emitl(imm32); | 2029 emitl(imm32); |
1909 } | 2030 } |
1910 | 2031 |
1911 | 2032 |
1912 void Assembler::pushfq() { | 2033 void Assembler::pushfq() { |
1913 EnsureSpace ensure_space(this); | 2034 EnsureSpace ensure_space(this); |
| 2035 last_pc_ = pc_; |
1914 emit(0x9C); | 2036 emit(0x9C); |
1915 } | 2037 } |
1916 | 2038 |
1917 | 2039 |
1918 void Assembler::rdtsc() { | 2040 void Assembler::rdtsc() { |
1919 EnsureSpace ensure_space(this); | 2041 EnsureSpace ensure_space(this); |
| 2042 last_pc_ = pc_; |
1920 emit(0x0F); | 2043 emit(0x0F); |
1921 emit(0x31); | 2044 emit(0x31); |
1922 } | 2045 } |
1923 | 2046 |
1924 | 2047 |
1925 void Assembler::ret(int imm16) { | 2048 void Assembler::ret(int imm16) { |
1926 EnsureSpace ensure_space(this); | 2049 EnsureSpace ensure_space(this); |
| 2050 last_pc_ = pc_; |
1927 ASSERT(is_uint16(imm16)); | 2051 ASSERT(is_uint16(imm16)); |
1928 if (imm16 == 0) { | 2052 if (imm16 == 0) { |
1929 emit(0xC3); | 2053 emit(0xC3); |
1930 } else { | 2054 } else { |
1931 emit(0xC2); | 2055 emit(0xC2); |
1932 emit(imm16 & 0xFF); | 2056 emit(imm16 & 0xFF); |
1933 emit((imm16 >> 8) & 0xFF); | 2057 emit((imm16 >> 8) & 0xFF); |
1934 } | 2058 } |
1935 } | 2059 } |
1936 | 2060 |
1937 | 2061 |
1938 void Assembler::setcc(Condition cc, Register reg) { | 2062 void Assembler::setcc(Condition cc, Register reg) { |
1939 if (cc > last_condition) { | 2063 if (cc > last_condition) { |
1940 movb(reg, Immediate(cc == always ? 1 : 0)); | 2064 movb(reg, Immediate(cc == always ? 1 : 0)); |
1941 return; | 2065 return; |
1942 } | 2066 } |
1943 EnsureSpace ensure_space(this); | 2067 EnsureSpace ensure_space(this); |
| 2068 last_pc_ = pc_; |
1944 ASSERT(is_uint4(cc)); | 2069 ASSERT(is_uint4(cc)); |
1945 if (reg.code() > 3) { // Use x64 byte registers, where different. | 2070 if (reg.code() > 3) { // Use x64 byte registers, where different. |
1946 emit_rex_32(reg); | 2071 emit_rex_32(reg); |
1947 } | 2072 } |
1948 emit(0x0F); | 2073 emit(0x0F); |
1949 emit(0x90 | cc); | 2074 emit(0x90 | cc); |
1950 emit_modrm(0x0, reg); | 2075 emit_modrm(0x0, reg); |
1951 } | 2076 } |
1952 | 2077 |
1953 | 2078 |
1954 void Assembler::shld(Register dst, Register src) { | 2079 void Assembler::shld(Register dst, Register src) { |
1955 EnsureSpace ensure_space(this); | 2080 EnsureSpace ensure_space(this); |
| 2081 last_pc_ = pc_; |
1956 emit_rex_64(src, dst); | 2082 emit_rex_64(src, dst); |
1957 emit(0x0F); | 2083 emit(0x0F); |
1958 emit(0xA5); | 2084 emit(0xA5); |
1959 emit_modrm(src, dst); | 2085 emit_modrm(src, dst); |
1960 } | 2086 } |
1961 | 2087 |
1962 | 2088 |
1963 void Assembler::shrd(Register dst, Register src) { | 2089 void Assembler::shrd(Register dst, Register src) { |
1964 EnsureSpace ensure_space(this); | 2090 EnsureSpace ensure_space(this); |
| 2091 last_pc_ = pc_; |
1965 emit_rex_64(src, dst); | 2092 emit_rex_64(src, dst); |
1966 emit(0x0F); | 2093 emit(0x0F); |
1967 emit(0xAD); | 2094 emit(0xAD); |
1968 emit_modrm(src, dst); | 2095 emit_modrm(src, dst); |
1969 } | 2096 } |
1970 | 2097 |
1971 | 2098 |
1972 void Assembler::xchg(Register dst, Register src) { | 2099 void Assembler::xchg(Register dst, Register src) { |
1973 EnsureSpace ensure_space(this); | 2100 EnsureSpace ensure_space(this); |
| 2101 last_pc_ = pc_; |
1974 if (src.is(rax) || dst.is(rax)) { // Single-byte encoding | 2102 if (src.is(rax) || dst.is(rax)) { // Single-byte encoding |
1975 Register other = src.is(rax) ? dst : src; | 2103 Register other = src.is(rax) ? dst : src; |
1976 emit_rex_64(other); | 2104 emit_rex_64(other); |
1977 emit(0x90 | other.low_bits()); | 2105 emit(0x90 | other.low_bits()); |
1978 } else if (dst.low_bits() == 4) { | 2106 } else if (dst.low_bits() == 4) { |
1979 emit_rex_64(dst, src); | 2107 emit_rex_64(dst, src); |
1980 emit(0x87); | 2108 emit(0x87); |
1981 emit_modrm(dst, src); | 2109 emit_modrm(dst, src); |
1982 } else { | 2110 } else { |
1983 emit_rex_64(src, dst); | 2111 emit_rex_64(src, dst); |
1984 emit(0x87); | 2112 emit(0x87); |
1985 emit_modrm(src, dst); | 2113 emit_modrm(src, dst); |
1986 } | 2114 } |
1987 } | 2115 } |
1988 | 2116 |
1989 | 2117 |
1990 void Assembler::store_rax(void* dst, RelocInfo::Mode mode) { | 2118 void Assembler::store_rax(void* dst, RelocInfo::Mode mode) { |
1991 EnsureSpace ensure_space(this); | 2119 EnsureSpace ensure_space(this); |
| 2120 last_pc_ = pc_; |
1992 emit(0x48); // REX.W | 2121 emit(0x48); // REX.W |
1993 emit(0xA3); | 2122 emit(0xA3); |
1994 emitq(reinterpret_cast<uintptr_t>(dst), mode); | 2123 emitq(reinterpret_cast<uintptr_t>(dst), mode); |
1995 } | 2124 } |
1996 | 2125 |
1997 | 2126 |
1998 void Assembler::store_rax(ExternalReference ref) { | 2127 void Assembler::store_rax(ExternalReference ref) { |
1999 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); | 2128 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); |
2000 } | 2129 } |
2001 | 2130 |
2002 | 2131 |
2003 void Assembler::testb(Register dst, Register src) { | 2132 void Assembler::testb(Register dst, Register src) { |
2004 EnsureSpace ensure_space(this); | 2133 EnsureSpace ensure_space(this); |
| 2134 last_pc_ = pc_; |
2005 if (src.low_bits() == 4) { | 2135 if (src.low_bits() == 4) { |
2006 emit_rex_32(src, dst); | 2136 emit_rex_32(src, dst); |
2007 emit(0x84); | 2137 emit(0x84); |
2008 emit_modrm(src, dst); | 2138 emit_modrm(src, dst); |
2009 } else { | 2139 } else { |
2010 if (dst.code() > 3 || src.code() > 3) { | 2140 if (dst.code() > 3 || src.code() > 3) { |
2011 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2141 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
2012 emit_rex_32(dst, src); | 2142 emit_rex_32(dst, src); |
2013 } | 2143 } |
2014 emit(0x84); | 2144 emit(0x84); |
2015 emit_modrm(dst, src); | 2145 emit_modrm(dst, src); |
2016 } | 2146 } |
2017 } | 2147 } |
2018 | 2148 |
2019 | 2149 |
2020 void Assembler::testb(Register reg, Immediate mask) { | 2150 void Assembler::testb(Register reg, Immediate mask) { |
2021 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); | 2151 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); |
2022 EnsureSpace ensure_space(this); | 2152 EnsureSpace ensure_space(this); |
| 2153 last_pc_ = pc_; |
2023 if (reg.is(rax)) { | 2154 if (reg.is(rax)) { |
2024 emit(0xA8); | 2155 emit(0xA8); |
2025 emit(mask.value_); // Low byte emitted. | 2156 emit(mask.value_); // Low byte emitted. |
2026 } else { | 2157 } else { |
2027 if (reg.code() > 3) { | 2158 if (reg.code() > 3) { |
2028 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2159 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
2029 emit_rex_32(reg); | 2160 emit_rex_32(reg); |
2030 } | 2161 } |
2031 emit(0xF6); | 2162 emit(0xF6); |
2032 emit_modrm(0x0, reg); | 2163 emit_modrm(0x0, reg); |
2033 emit(mask.value_); // Low byte emitted. | 2164 emit(mask.value_); // Low byte emitted. |
2034 } | 2165 } |
2035 } | 2166 } |
2036 | 2167 |
2037 | 2168 |
2038 void Assembler::testb(const Operand& op, Immediate mask) { | 2169 void Assembler::testb(const Operand& op, Immediate mask) { |
2039 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); | 2170 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); |
2040 EnsureSpace ensure_space(this); | 2171 EnsureSpace ensure_space(this); |
| 2172 last_pc_ = pc_; |
2041 emit_optional_rex_32(rax, op); | 2173 emit_optional_rex_32(rax, op); |
2042 emit(0xF6); | 2174 emit(0xF6); |
2043 emit_operand(rax, op); // Operation code 0 | 2175 emit_operand(rax, op); // Operation code 0 |
2044 emit(mask.value_); // Low byte emitted. | 2176 emit(mask.value_); // Low byte emitted. |
2045 } | 2177 } |
2046 | 2178 |
2047 | 2179 |
2048 void Assembler::testb(const Operand& op, Register reg) { | 2180 void Assembler::testb(const Operand& op, Register reg) { |
2049 EnsureSpace ensure_space(this); | 2181 EnsureSpace ensure_space(this); |
| 2182 last_pc_ = pc_; |
2050 if (reg.code() > 3) { | 2183 if (reg.code() > 3) { |
2051 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2184 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
2052 emit_rex_32(reg, op); | 2185 emit_rex_32(reg, op); |
2053 } else { | 2186 } else { |
2054 emit_optional_rex_32(reg, op); | 2187 emit_optional_rex_32(reg, op); |
2055 } | 2188 } |
2056 emit(0x84); | 2189 emit(0x84); |
2057 emit_operand(reg, op); | 2190 emit_operand(reg, op); |
2058 } | 2191 } |
2059 | 2192 |
2060 | 2193 |
2061 void Assembler::testl(Register dst, Register src) { | 2194 void Assembler::testl(Register dst, Register src) { |
2062 EnsureSpace ensure_space(this); | 2195 EnsureSpace ensure_space(this); |
| 2196 last_pc_ = pc_; |
2063 if (src.low_bits() == 4) { | 2197 if (src.low_bits() == 4) { |
2064 emit_optional_rex_32(src, dst); | 2198 emit_optional_rex_32(src, dst); |
2065 emit(0x85); | 2199 emit(0x85); |
2066 emit_modrm(src, dst); | 2200 emit_modrm(src, dst); |
2067 } else { | 2201 } else { |
2068 emit_optional_rex_32(dst, src); | 2202 emit_optional_rex_32(dst, src); |
2069 emit(0x85); | 2203 emit(0x85); |
2070 emit_modrm(dst, src); | 2204 emit_modrm(dst, src); |
2071 } | 2205 } |
2072 } | 2206 } |
2073 | 2207 |
2074 | 2208 |
2075 void Assembler::testl(Register reg, Immediate mask) { | 2209 void Assembler::testl(Register reg, Immediate mask) { |
2076 // testl with a mask that fits in the low byte is exactly testb. | 2210 // testl with a mask that fits in the low byte is exactly testb. |
2077 if (is_uint8(mask.value_)) { | 2211 if (is_uint8(mask.value_)) { |
2078 testb(reg, mask); | 2212 testb(reg, mask); |
2079 return; | 2213 return; |
2080 } | 2214 } |
2081 EnsureSpace ensure_space(this); | 2215 EnsureSpace ensure_space(this); |
| 2216 last_pc_ = pc_; |
2082 if (reg.is(rax)) { | 2217 if (reg.is(rax)) { |
2083 emit(0xA9); | 2218 emit(0xA9); |
2084 emit(mask); | 2219 emit(mask); |
2085 } else { | 2220 } else { |
2086 emit_optional_rex_32(rax, reg); | 2221 emit_optional_rex_32(rax, reg); |
2087 emit(0xF7); | 2222 emit(0xF7); |
2088 emit_modrm(0x0, reg); | 2223 emit_modrm(0x0, reg); |
2089 emit(mask); | 2224 emit(mask); |
2090 } | 2225 } |
2091 } | 2226 } |
2092 | 2227 |
2093 | 2228 |
2094 void Assembler::testl(const Operand& op, Immediate mask) { | 2229 void Assembler::testl(const Operand& op, Immediate mask) { |
2095 // testl with a mask that fits in the low byte is exactly testb. | 2230 // testl with a mask that fits in the low byte is exactly testb. |
2096 if (is_uint8(mask.value_)) { | 2231 if (is_uint8(mask.value_)) { |
2097 testb(op, mask); | 2232 testb(op, mask); |
2098 return; | 2233 return; |
2099 } | 2234 } |
2100 EnsureSpace ensure_space(this); | 2235 EnsureSpace ensure_space(this); |
| 2236 last_pc_ = pc_; |
2101 emit_optional_rex_32(rax, op); | 2237 emit_optional_rex_32(rax, op); |
2102 emit(0xF7); | 2238 emit(0xF7); |
2103 emit_operand(rax, op); // Operation code 0 | 2239 emit_operand(rax, op); // Operation code 0 |
2104 emit(mask); | 2240 emit(mask); |
2105 } | 2241 } |
2106 | 2242 |
2107 | 2243 |
2108 void Assembler::testq(const Operand& op, Register reg) { | 2244 void Assembler::testq(const Operand& op, Register reg) { |
2109 EnsureSpace ensure_space(this); | 2245 EnsureSpace ensure_space(this); |
| 2246 last_pc_ = pc_; |
2110 emit_rex_64(reg, op); | 2247 emit_rex_64(reg, op); |
2111 emit(0x85); | 2248 emit(0x85); |
2112 emit_operand(reg, op); | 2249 emit_operand(reg, op); |
2113 } | 2250 } |
2114 | 2251 |
2115 | 2252 |
2116 void Assembler::testq(Register dst, Register src) { | 2253 void Assembler::testq(Register dst, Register src) { |
2117 EnsureSpace ensure_space(this); | 2254 EnsureSpace ensure_space(this); |
| 2255 last_pc_ = pc_; |
2118 if (src.low_bits() == 4) { | 2256 if (src.low_bits() == 4) { |
2119 emit_rex_64(src, dst); | 2257 emit_rex_64(src, dst); |
2120 emit(0x85); | 2258 emit(0x85); |
2121 emit_modrm(src, dst); | 2259 emit_modrm(src, dst); |
2122 } else { | 2260 } else { |
2123 emit_rex_64(dst, src); | 2261 emit_rex_64(dst, src); |
2124 emit(0x85); | 2262 emit(0x85); |
2125 emit_modrm(dst, src); | 2263 emit_modrm(dst, src); |
2126 } | 2264 } |
2127 } | 2265 } |
2128 | 2266 |
2129 | 2267 |
2130 void Assembler::testq(Register dst, Immediate mask) { | 2268 void Assembler::testq(Register dst, Immediate mask) { |
2131 EnsureSpace ensure_space(this); | 2269 EnsureSpace ensure_space(this); |
| 2270 last_pc_ = pc_; |
2132 if (dst.is(rax)) { | 2271 if (dst.is(rax)) { |
2133 emit_rex_64(); | 2272 emit_rex_64(); |
2134 emit(0xA9); | 2273 emit(0xA9); |
2135 emit(mask); | 2274 emit(mask); |
2136 } else { | 2275 } else { |
2137 emit_rex_64(dst); | 2276 emit_rex_64(dst); |
2138 emit(0xF7); | 2277 emit(0xF7); |
2139 emit_modrm(0, dst); | 2278 emit_modrm(0, dst); |
2140 emit(mask); | 2279 emit(mask); |
2141 } | 2280 } |
2142 } | 2281 } |
2143 | 2282 |
2144 | 2283 |
2145 // FPU instructions. | 2284 // FPU instructions. |
2146 | 2285 |
2147 | 2286 |
2148 void Assembler::fld(int i) { | 2287 void Assembler::fld(int i) { |
2149 EnsureSpace ensure_space(this); | 2288 EnsureSpace ensure_space(this); |
| 2289 last_pc_ = pc_; |
2150 emit_farith(0xD9, 0xC0, i); | 2290 emit_farith(0xD9, 0xC0, i); |
2151 } | 2291 } |
2152 | 2292 |
2153 | 2293 |
2154 void Assembler::fld1() { | 2294 void Assembler::fld1() { |
2155 EnsureSpace ensure_space(this); | 2295 EnsureSpace ensure_space(this); |
| 2296 last_pc_ = pc_; |
2156 emit(0xD9); | 2297 emit(0xD9); |
2157 emit(0xE8); | 2298 emit(0xE8); |
2158 } | 2299 } |
2159 | 2300 |
2160 | 2301 |
2161 void Assembler::fldz() { | 2302 void Assembler::fldz() { |
2162 EnsureSpace ensure_space(this); | 2303 EnsureSpace ensure_space(this); |
| 2304 last_pc_ = pc_; |
2163 emit(0xD9); | 2305 emit(0xD9); |
2164 emit(0xEE); | 2306 emit(0xEE); |
2165 } | 2307 } |
2166 | 2308 |
2167 | 2309 |
2168 void Assembler::fldpi() { | 2310 void Assembler::fldpi() { |
2169 EnsureSpace ensure_space(this); | 2311 EnsureSpace ensure_space(this); |
| 2312 last_pc_ = pc_; |
2170 emit(0xD9); | 2313 emit(0xD9); |
2171 emit(0xEB); | 2314 emit(0xEB); |
2172 } | 2315 } |
2173 | 2316 |
2174 | 2317 |
2175 void Assembler::fldln2() { | 2318 void Assembler::fldln2() { |
2176 EnsureSpace ensure_space(this); | 2319 EnsureSpace ensure_space(this); |
| 2320 last_pc_ = pc_; |
2177 emit(0xD9); | 2321 emit(0xD9); |
2178 emit(0xED); | 2322 emit(0xED); |
2179 } | 2323 } |
2180 | 2324 |
2181 | 2325 |
2182 void Assembler::fld_s(const Operand& adr) { | 2326 void Assembler::fld_s(const Operand& adr) { |
2183 EnsureSpace ensure_space(this); | 2327 EnsureSpace ensure_space(this); |
| 2328 last_pc_ = pc_; |
2184 emit_optional_rex_32(adr); | 2329 emit_optional_rex_32(adr); |
2185 emit(0xD9); | 2330 emit(0xD9); |
2186 emit_operand(0, adr); | 2331 emit_operand(0, adr); |
2187 } | 2332 } |
2188 | 2333 |
2189 | 2334 |
2190 void Assembler::fld_d(const Operand& adr) { | 2335 void Assembler::fld_d(const Operand& adr) { |
2191 EnsureSpace ensure_space(this); | 2336 EnsureSpace ensure_space(this); |
| 2337 last_pc_ = pc_; |
2192 emit_optional_rex_32(adr); | 2338 emit_optional_rex_32(adr); |
2193 emit(0xDD); | 2339 emit(0xDD); |
2194 emit_operand(0, adr); | 2340 emit_operand(0, adr); |
2195 } | 2341 } |
2196 | 2342 |
2197 | 2343 |
2198 void Assembler::fstp_s(const Operand& adr) { | 2344 void Assembler::fstp_s(const Operand& adr) { |
2199 EnsureSpace ensure_space(this); | 2345 EnsureSpace ensure_space(this); |
| 2346 last_pc_ = pc_; |
2200 emit_optional_rex_32(adr); | 2347 emit_optional_rex_32(adr); |
2201 emit(0xD9); | 2348 emit(0xD9); |
2202 emit_operand(3, adr); | 2349 emit_operand(3, adr); |
2203 } | 2350 } |
2204 | 2351 |
2205 | 2352 |
2206 void Assembler::fstp_d(const Operand& adr) { | 2353 void Assembler::fstp_d(const Operand& adr) { |
2207 EnsureSpace ensure_space(this); | 2354 EnsureSpace ensure_space(this); |
| 2355 last_pc_ = pc_; |
2208 emit_optional_rex_32(adr); | 2356 emit_optional_rex_32(adr); |
2209 emit(0xDD); | 2357 emit(0xDD); |
2210 emit_operand(3, adr); | 2358 emit_operand(3, adr); |
2211 } | 2359 } |
2212 | 2360 |
2213 | 2361 |
2214 void Assembler::fstp(int index) { | 2362 void Assembler::fstp(int index) { |
2215 ASSERT(is_uint3(index)); | 2363 ASSERT(is_uint3(index)); |
2216 EnsureSpace ensure_space(this); | 2364 EnsureSpace ensure_space(this); |
| 2365 last_pc_ = pc_; |
2217 emit_farith(0xDD, 0xD8, index); | 2366 emit_farith(0xDD, 0xD8, index); |
2218 } | 2367 } |
2219 | 2368 |
2220 | 2369 |
2221 void Assembler::fild_s(const Operand& adr) { | 2370 void Assembler::fild_s(const Operand& adr) { |
2222 EnsureSpace ensure_space(this); | 2371 EnsureSpace ensure_space(this); |
| 2372 last_pc_ = pc_; |
2223 emit_optional_rex_32(adr); | 2373 emit_optional_rex_32(adr); |
2224 emit(0xDB); | 2374 emit(0xDB); |
2225 emit_operand(0, adr); | 2375 emit_operand(0, adr); |
2226 } | 2376 } |
2227 | 2377 |
2228 | 2378 |
2229 void Assembler::fild_d(const Operand& adr) { | 2379 void Assembler::fild_d(const Operand& adr) { |
2230 EnsureSpace ensure_space(this); | 2380 EnsureSpace ensure_space(this); |
| 2381 last_pc_ = pc_; |
2231 emit_optional_rex_32(adr); | 2382 emit_optional_rex_32(adr); |
2232 emit(0xDF); | 2383 emit(0xDF); |
2233 emit_operand(5, adr); | 2384 emit_operand(5, adr); |
2234 } | 2385 } |
2235 | 2386 |
2236 | 2387 |
2237 void Assembler::fistp_s(const Operand& adr) { | 2388 void Assembler::fistp_s(const Operand& adr) { |
2238 EnsureSpace ensure_space(this); | 2389 EnsureSpace ensure_space(this); |
| 2390 last_pc_ = pc_; |
2239 emit_optional_rex_32(adr); | 2391 emit_optional_rex_32(adr); |
2240 emit(0xDB); | 2392 emit(0xDB); |
2241 emit_operand(3, adr); | 2393 emit_operand(3, adr); |
2242 } | 2394 } |
2243 | 2395 |
2244 | 2396 |
2245 void Assembler::fisttp_s(const Operand& adr) { | 2397 void Assembler::fisttp_s(const Operand& adr) { |
2246 ASSERT(CpuFeatures::IsEnabled(SSE3)); | 2398 ASSERT(CpuFeatures::IsEnabled(SSE3)); |
2247 EnsureSpace ensure_space(this); | 2399 EnsureSpace ensure_space(this); |
| 2400 last_pc_ = pc_; |
2248 emit_optional_rex_32(adr); | 2401 emit_optional_rex_32(adr); |
2249 emit(0xDB); | 2402 emit(0xDB); |
2250 emit_operand(1, adr); | 2403 emit_operand(1, adr); |
2251 } | 2404 } |
2252 | 2405 |
2253 | 2406 |
2254 void Assembler::fisttp_d(const Operand& adr) { | 2407 void Assembler::fisttp_d(const Operand& adr) { |
2255 ASSERT(CpuFeatures::IsEnabled(SSE3)); | 2408 ASSERT(CpuFeatures::IsEnabled(SSE3)); |
2256 EnsureSpace ensure_space(this); | 2409 EnsureSpace ensure_space(this); |
| 2410 last_pc_ = pc_; |
2257 emit_optional_rex_32(adr); | 2411 emit_optional_rex_32(adr); |
2258 emit(0xDD); | 2412 emit(0xDD); |
2259 emit_operand(1, adr); | 2413 emit_operand(1, adr); |
2260 } | 2414 } |
2261 | 2415 |
2262 | 2416 |
2263 void Assembler::fist_s(const Operand& adr) { | 2417 void Assembler::fist_s(const Operand& adr) { |
2264 EnsureSpace ensure_space(this); | 2418 EnsureSpace ensure_space(this); |
| 2419 last_pc_ = pc_; |
2265 emit_optional_rex_32(adr); | 2420 emit_optional_rex_32(adr); |
2266 emit(0xDB); | 2421 emit(0xDB); |
2267 emit_operand(2, adr); | 2422 emit_operand(2, adr); |
2268 } | 2423 } |
2269 | 2424 |
2270 | 2425 |
2271 void Assembler::fistp_d(const Operand& adr) { | 2426 void Assembler::fistp_d(const Operand& adr) { |
2272 EnsureSpace ensure_space(this); | 2427 EnsureSpace ensure_space(this); |
| 2428 last_pc_ = pc_; |
2273 emit_optional_rex_32(adr); | 2429 emit_optional_rex_32(adr); |
2274 emit(0xDF); | 2430 emit(0xDF); |
2275 emit_operand(7, adr); | 2431 emit_operand(7, adr); |
2276 } | 2432 } |
2277 | 2433 |
2278 | 2434 |
2279 void Assembler::fabs() { | 2435 void Assembler::fabs() { |
2280 EnsureSpace ensure_space(this); | 2436 EnsureSpace ensure_space(this); |
| 2437 last_pc_ = pc_; |
2281 emit(0xD9); | 2438 emit(0xD9); |
2282 emit(0xE1); | 2439 emit(0xE1); |
2283 } | 2440 } |
2284 | 2441 |
2285 | 2442 |
2286 void Assembler::fchs() { | 2443 void Assembler::fchs() { |
2287 EnsureSpace ensure_space(this); | 2444 EnsureSpace ensure_space(this); |
| 2445 last_pc_ = pc_; |
2288 emit(0xD9); | 2446 emit(0xD9); |
2289 emit(0xE0); | 2447 emit(0xE0); |
2290 } | 2448 } |
2291 | 2449 |
2292 | 2450 |
2293 void Assembler::fcos() { | 2451 void Assembler::fcos() { |
2294 EnsureSpace ensure_space(this); | 2452 EnsureSpace ensure_space(this); |
| 2453 last_pc_ = pc_; |
2295 emit(0xD9); | 2454 emit(0xD9); |
2296 emit(0xFF); | 2455 emit(0xFF); |
2297 } | 2456 } |
2298 | 2457 |
2299 | 2458 |
2300 void Assembler::fsin() { | 2459 void Assembler::fsin() { |
2301 EnsureSpace ensure_space(this); | 2460 EnsureSpace ensure_space(this); |
| 2461 last_pc_ = pc_; |
2302 emit(0xD9); | 2462 emit(0xD9); |
2303 emit(0xFE); | 2463 emit(0xFE); |
2304 } | 2464 } |
2305 | 2465 |
2306 | 2466 |
2307 void Assembler::fyl2x() { | 2467 void Assembler::fyl2x() { |
2308 EnsureSpace ensure_space(this); | 2468 EnsureSpace ensure_space(this); |
| 2469 last_pc_ = pc_; |
2309 emit(0xD9); | 2470 emit(0xD9); |
2310 emit(0xF1); | 2471 emit(0xF1); |
2311 } | 2472 } |
2312 | 2473 |
2313 | 2474 |
2314 void Assembler::fadd(int i) { | 2475 void Assembler::fadd(int i) { |
2315 EnsureSpace ensure_space(this); | 2476 EnsureSpace ensure_space(this); |
| 2477 last_pc_ = pc_; |
2316 emit_farith(0xDC, 0xC0, i); | 2478 emit_farith(0xDC, 0xC0, i); |
2317 } | 2479 } |
2318 | 2480 |
2319 | 2481 |
2320 void Assembler::fsub(int i) { | 2482 void Assembler::fsub(int i) { |
2321 EnsureSpace ensure_space(this); | 2483 EnsureSpace ensure_space(this); |
| 2484 last_pc_ = pc_; |
2322 emit_farith(0xDC, 0xE8, i); | 2485 emit_farith(0xDC, 0xE8, i); |
2323 } | 2486 } |
2324 | 2487 |
2325 | 2488 |
2326 void Assembler::fisub_s(const Operand& adr) { | 2489 void Assembler::fisub_s(const Operand& adr) { |
2327 EnsureSpace ensure_space(this); | 2490 EnsureSpace ensure_space(this); |
| 2491 last_pc_ = pc_; |
2328 emit_optional_rex_32(adr); | 2492 emit_optional_rex_32(adr); |
2329 emit(0xDA); | 2493 emit(0xDA); |
2330 emit_operand(4, adr); | 2494 emit_operand(4, adr); |
2331 } | 2495 } |
2332 | 2496 |
2333 | 2497 |
2334 void Assembler::fmul(int i) { | 2498 void Assembler::fmul(int i) { |
2335 EnsureSpace ensure_space(this); | 2499 EnsureSpace ensure_space(this); |
| 2500 last_pc_ = pc_; |
2336 emit_farith(0xDC, 0xC8, i); | 2501 emit_farith(0xDC, 0xC8, i); |
2337 } | 2502 } |
2338 | 2503 |
2339 | 2504 |
2340 void Assembler::fdiv(int i) { | 2505 void Assembler::fdiv(int i) { |
2341 EnsureSpace ensure_space(this); | 2506 EnsureSpace ensure_space(this); |
| 2507 last_pc_ = pc_; |
2342 emit_farith(0xDC, 0xF8, i); | 2508 emit_farith(0xDC, 0xF8, i); |
2343 } | 2509 } |
2344 | 2510 |
2345 | 2511 |
2346 void Assembler::faddp(int i) { | 2512 void Assembler::faddp(int i) { |
2347 EnsureSpace ensure_space(this); | 2513 EnsureSpace ensure_space(this); |
| 2514 last_pc_ = pc_; |
2348 emit_farith(0xDE, 0xC0, i); | 2515 emit_farith(0xDE, 0xC0, i); |
2349 } | 2516 } |
2350 | 2517 |
2351 | 2518 |
2352 void Assembler::fsubp(int i) { | 2519 void Assembler::fsubp(int i) { |
2353 EnsureSpace ensure_space(this); | 2520 EnsureSpace ensure_space(this); |
| 2521 last_pc_ = pc_; |
2354 emit_farith(0xDE, 0xE8, i); | 2522 emit_farith(0xDE, 0xE8, i); |
2355 } | 2523 } |
2356 | 2524 |
2357 | 2525 |
2358 void Assembler::fsubrp(int i) { | 2526 void Assembler::fsubrp(int i) { |
2359 EnsureSpace ensure_space(this); | 2527 EnsureSpace ensure_space(this); |
| 2528 last_pc_ = pc_; |
2360 emit_farith(0xDE, 0xE0, i); | 2529 emit_farith(0xDE, 0xE0, i); |
2361 } | 2530 } |
2362 | 2531 |
2363 | 2532 |
2364 void Assembler::fmulp(int i) { | 2533 void Assembler::fmulp(int i) { |
2365 EnsureSpace ensure_space(this); | 2534 EnsureSpace ensure_space(this); |
| 2535 last_pc_ = pc_; |
2366 emit_farith(0xDE, 0xC8, i); | 2536 emit_farith(0xDE, 0xC8, i); |
2367 } | 2537 } |
2368 | 2538 |
2369 | 2539 |
2370 void Assembler::fdivp(int i) { | 2540 void Assembler::fdivp(int i) { |
2371 EnsureSpace ensure_space(this); | 2541 EnsureSpace ensure_space(this); |
| 2542 last_pc_ = pc_; |
2372 emit_farith(0xDE, 0xF8, i); | 2543 emit_farith(0xDE, 0xF8, i); |
2373 } | 2544 } |
2374 | 2545 |
2375 | 2546 |
2376 void Assembler::fprem() { | 2547 void Assembler::fprem() { |
2377 EnsureSpace ensure_space(this); | 2548 EnsureSpace ensure_space(this); |
| 2549 last_pc_ = pc_; |
2378 emit(0xD9); | 2550 emit(0xD9); |
2379 emit(0xF8); | 2551 emit(0xF8); |
2380 } | 2552 } |
2381 | 2553 |
2382 | 2554 |
2383 void Assembler::fprem1() { | 2555 void Assembler::fprem1() { |
2384 EnsureSpace ensure_space(this); | 2556 EnsureSpace ensure_space(this); |
| 2557 last_pc_ = pc_; |
2385 emit(0xD9); | 2558 emit(0xD9); |
2386 emit(0xF5); | 2559 emit(0xF5); |
2387 } | 2560 } |
2388 | 2561 |
2389 | 2562 |
2390 void Assembler::fxch(int i) { | 2563 void Assembler::fxch(int i) { |
2391 EnsureSpace ensure_space(this); | 2564 EnsureSpace ensure_space(this); |
| 2565 last_pc_ = pc_; |
2392 emit_farith(0xD9, 0xC8, i); | 2566 emit_farith(0xD9, 0xC8, i); |
2393 } | 2567 } |
2394 | 2568 |
2395 | 2569 |
2396 void Assembler::fincstp() { | 2570 void Assembler::fincstp() { |
2397 EnsureSpace ensure_space(this); | 2571 EnsureSpace ensure_space(this); |
| 2572 last_pc_ = pc_; |
2398 emit(0xD9); | 2573 emit(0xD9); |
2399 emit(0xF7); | 2574 emit(0xF7); |
2400 } | 2575 } |
2401 | 2576 |
2402 | 2577 |
2403 void Assembler::ffree(int i) { | 2578 void Assembler::ffree(int i) { |
2404 EnsureSpace ensure_space(this); | 2579 EnsureSpace ensure_space(this); |
| 2580 last_pc_ = pc_; |
2405 emit_farith(0xDD, 0xC0, i); | 2581 emit_farith(0xDD, 0xC0, i); |
2406 } | 2582 } |
2407 | 2583 |
2408 | 2584 |
2409 void Assembler::ftst() { | 2585 void Assembler::ftst() { |
2410 EnsureSpace ensure_space(this); | 2586 EnsureSpace ensure_space(this); |
| 2587 last_pc_ = pc_; |
2411 emit(0xD9); | 2588 emit(0xD9); |
2412 emit(0xE4); | 2589 emit(0xE4); |
2413 } | 2590 } |
2414 | 2591 |
2415 | 2592 |
2416 void Assembler::fucomp(int i) { | 2593 void Assembler::fucomp(int i) { |
2417 EnsureSpace ensure_space(this); | 2594 EnsureSpace ensure_space(this); |
| 2595 last_pc_ = pc_; |
2418 emit_farith(0xDD, 0xE8, i); | 2596 emit_farith(0xDD, 0xE8, i); |
2419 } | 2597 } |
2420 | 2598 |
2421 | 2599 |
2422 void Assembler::fucompp() { | 2600 void Assembler::fucompp() { |
2423 EnsureSpace ensure_space(this); | 2601 EnsureSpace ensure_space(this); |
| 2602 last_pc_ = pc_; |
2424 emit(0xDA); | 2603 emit(0xDA); |
2425 emit(0xE9); | 2604 emit(0xE9); |
2426 } | 2605 } |
2427 | 2606 |
2428 | 2607 |
2429 void Assembler::fucomi(int i) { | 2608 void Assembler::fucomi(int i) { |
2430 EnsureSpace ensure_space(this); | 2609 EnsureSpace ensure_space(this); |
| 2610 last_pc_ = pc_; |
2431 emit(0xDB); | 2611 emit(0xDB); |
2432 emit(0xE8 + i); | 2612 emit(0xE8 + i); |
2433 } | 2613 } |
2434 | 2614 |
2435 | 2615 |
2436 void Assembler::fucomip() { | 2616 void Assembler::fucomip() { |
2437 EnsureSpace ensure_space(this); | 2617 EnsureSpace ensure_space(this); |
| 2618 last_pc_ = pc_; |
2438 emit(0xDF); | 2619 emit(0xDF); |
2439 emit(0xE9); | 2620 emit(0xE9); |
2440 } | 2621 } |
2441 | 2622 |
2442 | 2623 |
2443 void Assembler::fcompp() { | 2624 void Assembler::fcompp() { |
2444 EnsureSpace ensure_space(this); | 2625 EnsureSpace ensure_space(this); |
| 2626 last_pc_ = pc_; |
2445 emit(0xDE); | 2627 emit(0xDE); |
2446 emit(0xD9); | 2628 emit(0xD9); |
2447 } | 2629 } |
2448 | 2630 |
2449 | 2631 |
2450 void Assembler::fnstsw_ax() { | 2632 void Assembler::fnstsw_ax() { |
2451 EnsureSpace ensure_space(this); | 2633 EnsureSpace ensure_space(this); |
| 2634 last_pc_ = pc_; |
2452 emit(0xDF); | 2635 emit(0xDF); |
2453 emit(0xE0); | 2636 emit(0xE0); |
2454 } | 2637 } |
2455 | 2638 |
2456 | 2639 |
2457 void Assembler::fwait() { | 2640 void Assembler::fwait() { |
2458 EnsureSpace ensure_space(this); | 2641 EnsureSpace ensure_space(this); |
| 2642 last_pc_ = pc_; |
2459 emit(0x9B); | 2643 emit(0x9B); |
2460 } | 2644 } |
2461 | 2645 |
2462 | 2646 |
2463 void Assembler::frndint() { | 2647 void Assembler::frndint() { |
2464 EnsureSpace ensure_space(this); | 2648 EnsureSpace ensure_space(this); |
| 2649 last_pc_ = pc_; |
2465 emit(0xD9); | 2650 emit(0xD9); |
2466 emit(0xFC); | 2651 emit(0xFC); |
2467 } | 2652 } |
2468 | 2653 |
2469 | 2654 |
2470 void Assembler::fnclex() { | 2655 void Assembler::fnclex() { |
2471 EnsureSpace ensure_space(this); | 2656 EnsureSpace ensure_space(this); |
| 2657 last_pc_ = pc_; |
2472 emit(0xDB); | 2658 emit(0xDB); |
2473 emit(0xE2); | 2659 emit(0xE2); |
2474 } | 2660 } |
2475 | 2661 |
2476 | 2662 |
2477 void Assembler::sahf() { | 2663 void Assembler::sahf() { |
2478 // TODO(X64): Test for presence. Not all 64-bit intel CPU's have sahf | 2664 // TODO(X64): Test for presence. Not all 64-bit intel CPU's have sahf |
2479 // in 64-bit mode. Test CpuID. | 2665 // in 64-bit mode. Test CpuID. |
2480 EnsureSpace ensure_space(this); | 2666 EnsureSpace ensure_space(this); |
| 2667 last_pc_ = pc_; |
2481 emit(0x9E); | 2668 emit(0x9E); |
2482 } | 2669 } |
2483 | 2670 |
2484 | 2671 |
2485 void Assembler::emit_farith(int b1, int b2, int i) { | 2672 void Assembler::emit_farith(int b1, int b2, int i) { |
2486 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode | 2673 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode |
2487 ASSERT(is_uint3(i)); // illegal stack offset | 2674 ASSERT(is_uint3(i)); // illegal stack offset |
2488 emit(b1); | 2675 emit(b1); |
2489 emit(b2 + i); | 2676 emit(b2 + i); |
2490 } | 2677 } |
2491 | 2678 |
2492 // SSE 2 operations. | 2679 // SSE 2 operations. |
2493 | 2680 |
2494 void Assembler::movd(XMMRegister dst, Register src) { | 2681 void Assembler::movd(XMMRegister dst, Register src) { |
2495 EnsureSpace ensure_space(this); | 2682 EnsureSpace ensure_space(this); |
| 2683 last_pc_ = pc_; |
2496 emit(0x66); | 2684 emit(0x66); |
2497 emit_optional_rex_32(dst, src); | 2685 emit_optional_rex_32(dst, src); |
2498 emit(0x0F); | 2686 emit(0x0F); |
2499 emit(0x6E); | 2687 emit(0x6E); |
2500 emit_sse_operand(dst, src); | 2688 emit_sse_operand(dst, src); |
2501 } | 2689 } |
2502 | 2690 |
2503 | 2691 |
2504 void Assembler::movd(Register dst, XMMRegister src) { | 2692 void Assembler::movd(Register dst, XMMRegister src) { |
2505 EnsureSpace ensure_space(this); | 2693 EnsureSpace ensure_space(this); |
| 2694 last_pc_ = pc_; |
2506 emit(0x66); | 2695 emit(0x66); |
2507 emit_optional_rex_32(src, dst); | 2696 emit_optional_rex_32(src, dst); |
2508 emit(0x0F); | 2697 emit(0x0F); |
2509 emit(0x7E); | 2698 emit(0x7E); |
2510 emit_sse_operand(src, dst); | 2699 emit_sse_operand(src, dst); |
2511 } | 2700 } |
2512 | 2701 |
2513 | 2702 |
2514 void Assembler::movq(XMMRegister dst, Register src) { | 2703 void Assembler::movq(XMMRegister dst, Register src) { |
2515 EnsureSpace ensure_space(this); | 2704 EnsureSpace ensure_space(this); |
| 2705 last_pc_ = pc_; |
2516 emit(0x66); | 2706 emit(0x66); |
2517 emit_rex_64(dst, src); | 2707 emit_rex_64(dst, src); |
2518 emit(0x0F); | 2708 emit(0x0F); |
2519 emit(0x6E); | 2709 emit(0x6E); |
2520 emit_sse_operand(dst, src); | 2710 emit_sse_operand(dst, src); |
2521 } | 2711 } |
2522 | 2712 |
2523 | 2713 |
2524 void Assembler::movq(Register dst, XMMRegister src) { | 2714 void Assembler::movq(Register dst, XMMRegister src) { |
2525 EnsureSpace ensure_space(this); | 2715 EnsureSpace ensure_space(this); |
| 2716 last_pc_ = pc_; |
2526 emit(0x66); | 2717 emit(0x66); |
2527 emit_rex_64(src, dst); | 2718 emit_rex_64(src, dst); |
2528 emit(0x0F); | 2719 emit(0x0F); |
2529 emit(0x7E); | 2720 emit(0x7E); |
2530 emit_sse_operand(src, dst); | 2721 emit_sse_operand(src, dst); |
2531 } | 2722 } |
2532 | 2723 |
2533 | 2724 |
2534 void Assembler::movdqa(const Operand& dst, XMMRegister src) { | 2725 void Assembler::movdqa(const Operand& dst, XMMRegister src) { |
| 2726 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2535 EnsureSpace ensure_space(this); | 2727 EnsureSpace ensure_space(this); |
| 2728 last_pc_ = pc_; |
2536 emit(0x66); | 2729 emit(0x66); |
2537 emit_rex_64(src, dst); | 2730 emit_rex_64(src, dst); |
2538 emit(0x0F); | 2731 emit(0x0F); |
2539 emit(0x7F); | 2732 emit(0x7F); |
2540 emit_sse_operand(src, dst); | 2733 emit_sse_operand(src, dst); |
2541 } | 2734 } |
2542 | 2735 |
2543 | 2736 |
2544 void Assembler::movdqa(XMMRegister dst, const Operand& src) { | 2737 void Assembler::movdqa(XMMRegister dst, const Operand& src) { |
| 2738 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2545 EnsureSpace ensure_space(this); | 2739 EnsureSpace ensure_space(this); |
| 2740 last_pc_ = pc_; |
2546 emit(0x66); | 2741 emit(0x66); |
2547 emit_rex_64(dst, src); | 2742 emit_rex_64(dst, src); |
2548 emit(0x0F); | 2743 emit(0x0F); |
2549 emit(0x6F); | 2744 emit(0x6F); |
2550 emit_sse_operand(dst, src); | 2745 emit_sse_operand(dst, src); |
2551 } | 2746 } |
2552 | 2747 |
2553 | 2748 |
2554 void Assembler::extractps(Register dst, XMMRegister src, byte imm8) { | 2749 void Assembler::extractps(Register dst, XMMRegister src, byte imm8) { |
2555 ASSERT(is_uint2(imm8)); | 2750 ASSERT(is_uint2(imm8)); |
2556 EnsureSpace ensure_space(this); | 2751 EnsureSpace ensure_space(this); |
| 2752 last_pc_ = pc_; |
2557 emit(0x66); | 2753 emit(0x66); |
2558 emit_optional_rex_32(dst, src); | 2754 emit_optional_rex_32(dst, src); |
2559 emit(0x0F); | 2755 emit(0x0F); |
2560 emit(0x3A); | 2756 emit(0x3A); |
2561 emit(0x17); | 2757 emit(0x17); |
2562 emit_sse_operand(dst, src); | 2758 emit_sse_operand(dst, src); |
2563 emit(imm8); | 2759 emit(imm8); |
2564 } | 2760 } |
2565 | 2761 |
2566 | 2762 |
2567 void Assembler::movsd(const Operand& dst, XMMRegister src) { | 2763 void Assembler::movsd(const Operand& dst, XMMRegister src) { |
2568 EnsureSpace ensure_space(this); | 2764 EnsureSpace ensure_space(this); |
| 2765 last_pc_ = pc_; |
2569 emit(0xF2); // double | 2766 emit(0xF2); // double |
2570 emit_optional_rex_32(src, dst); | 2767 emit_optional_rex_32(src, dst); |
2571 emit(0x0F); | 2768 emit(0x0F); |
2572 emit(0x11); // store | 2769 emit(0x11); // store |
2573 emit_sse_operand(src, dst); | 2770 emit_sse_operand(src, dst); |
2574 } | 2771 } |
2575 | 2772 |
2576 | 2773 |
2577 void Assembler::movsd(XMMRegister dst, XMMRegister src) { | 2774 void Assembler::movsd(XMMRegister dst, XMMRegister src) { |
2578 EnsureSpace ensure_space(this); | 2775 EnsureSpace ensure_space(this); |
| 2776 last_pc_ = pc_; |
2579 emit(0xF2); // double | 2777 emit(0xF2); // double |
2580 emit_optional_rex_32(dst, src); | 2778 emit_optional_rex_32(dst, src); |
2581 emit(0x0F); | 2779 emit(0x0F); |
2582 emit(0x10); // load | 2780 emit(0x10); // load |
2583 emit_sse_operand(dst, src); | 2781 emit_sse_operand(dst, src); |
2584 } | 2782 } |
2585 | 2783 |
2586 | 2784 |
2587 void Assembler::movsd(XMMRegister dst, const Operand& src) { | 2785 void Assembler::movsd(XMMRegister dst, const Operand& src) { |
2588 EnsureSpace ensure_space(this); | 2786 EnsureSpace ensure_space(this); |
| 2787 last_pc_ = pc_; |
2589 emit(0xF2); // double | 2788 emit(0xF2); // double |
2590 emit_optional_rex_32(dst, src); | 2789 emit_optional_rex_32(dst, src); |
2591 emit(0x0F); | 2790 emit(0x0F); |
2592 emit(0x10); // load | 2791 emit(0x10); // load |
2593 emit_sse_operand(dst, src); | 2792 emit_sse_operand(dst, src); |
2594 } | 2793 } |
2595 | 2794 |
2596 | 2795 |
2597 void Assembler::movss(XMMRegister dst, const Operand& src) { | 2796 void Assembler::movss(XMMRegister dst, const Operand& src) { |
2598 EnsureSpace ensure_space(this); | 2797 EnsureSpace ensure_space(this); |
| 2798 last_pc_ = pc_; |
2599 emit(0xF3); // single | 2799 emit(0xF3); // single |
2600 emit_optional_rex_32(dst, src); | 2800 emit_optional_rex_32(dst, src); |
2601 emit(0x0F); | 2801 emit(0x0F); |
2602 emit(0x10); // load | 2802 emit(0x10); // load |
2603 emit_sse_operand(dst, src); | 2803 emit_sse_operand(dst, src); |
2604 } | 2804 } |
2605 | 2805 |
2606 | 2806 |
2607 void Assembler::movss(const Operand& src, XMMRegister dst) { | 2807 void Assembler::movss(const Operand& src, XMMRegister dst) { |
2608 EnsureSpace ensure_space(this); | 2808 EnsureSpace ensure_space(this); |
| 2809 last_pc_ = pc_; |
2609 emit(0xF3); // single | 2810 emit(0xF3); // single |
2610 emit_optional_rex_32(dst, src); | 2811 emit_optional_rex_32(dst, src); |
2611 emit(0x0F); | 2812 emit(0x0F); |
2612 emit(0x11); // store | 2813 emit(0x11); // store |
2613 emit_sse_operand(dst, src); | 2814 emit_sse_operand(dst, src); |
2614 } | 2815 } |
2615 | 2816 |
2616 | 2817 |
2617 void Assembler::cvttss2si(Register dst, const Operand& src) { | 2818 void Assembler::cvttss2si(Register dst, const Operand& src) { |
2618 EnsureSpace ensure_space(this); | 2819 EnsureSpace ensure_space(this); |
| 2820 last_pc_ = pc_; |
2619 emit(0xF3); | 2821 emit(0xF3); |
2620 emit_optional_rex_32(dst, src); | 2822 emit_optional_rex_32(dst, src); |
2621 emit(0x0F); | 2823 emit(0x0F); |
2622 emit(0x2C); | 2824 emit(0x2C); |
2623 emit_operand(dst, src); | 2825 emit_operand(dst, src); |
2624 } | 2826 } |
2625 | 2827 |
2626 | 2828 |
2627 void Assembler::cvttss2si(Register dst, XMMRegister src) { | 2829 void Assembler::cvttss2si(Register dst, XMMRegister src) { |
2628 EnsureSpace ensure_space(this); | 2830 EnsureSpace ensure_space(this); |
| 2831 last_pc_ = pc_; |
2629 emit(0xF3); | 2832 emit(0xF3); |
2630 emit_optional_rex_32(dst, src); | 2833 emit_optional_rex_32(dst, src); |
2631 emit(0x0F); | 2834 emit(0x0F); |
2632 emit(0x2C); | 2835 emit(0x2C); |
2633 emit_sse_operand(dst, src); | 2836 emit_sse_operand(dst, src); |
2634 } | 2837 } |
2635 | 2838 |
2636 | 2839 |
2637 void Assembler::cvttsd2si(Register dst, const Operand& src) { | 2840 void Assembler::cvttsd2si(Register dst, const Operand& src) { |
2638 EnsureSpace ensure_space(this); | 2841 EnsureSpace ensure_space(this); |
| 2842 last_pc_ = pc_; |
2639 emit(0xF2); | 2843 emit(0xF2); |
2640 emit_optional_rex_32(dst, src); | 2844 emit_optional_rex_32(dst, src); |
2641 emit(0x0F); | 2845 emit(0x0F); |
2642 emit(0x2C); | 2846 emit(0x2C); |
2643 emit_operand(dst, src); | 2847 emit_operand(dst, src); |
2644 } | 2848 } |
2645 | 2849 |
2646 | 2850 |
2647 void Assembler::cvttsd2si(Register dst, XMMRegister src) { | 2851 void Assembler::cvttsd2si(Register dst, XMMRegister src) { |
2648 EnsureSpace ensure_space(this); | 2852 EnsureSpace ensure_space(this); |
| 2853 last_pc_ = pc_; |
2649 emit(0xF2); | 2854 emit(0xF2); |
2650 emit_optional_rex_32(dst, src); | 2855 emit_optional_rex_32(dst, src); |
2651 emit(0x0F); | 2856 emit(0x0F); |
2652 emit(0x2C); | 2857 emit(0x2C); |
2653 emit_sse_operand(dst, src); | 2858 emit_sse_operand(dst, src); |
2654 } | 2859 } |
2655 | 2860 |
2656 | 2861 |
2657 void Assembler::cvttsd2siq(Register dst, XMMRegister src) { | 2862 void Assembler::cvttsd2siq(Register dst, XMMRegister src) { |
2658 EnsureSpace ensure_space(this); | 2863 EnsureSpace ensure_space(this); |
| 2864 last_pc_ = pc_; |
2659 emit(0xF2); | 2865 emit(0xF2); |
2660 emit_rex_64(dst, src); | 2866 emit_rex_64(dst, src); |
2661 emit(0x0F); | 2867 emit(0x0F); |
2662 emit(0x2C); | 2868 emit(0x2C); |
2663 emit_sse_operand(dst, src); | 2869 emit_sse_operand(dst, src); |
2664 } | 2870 } |
2665 | 2871 |
2666 | 2872 |
2667 void Assembler::cvtlsi2sd(XMMRegister dst, const Operand& src) { | 2873 void Assembler::cvtlsi2sd(XMMRegister dst, const Operand& src) { |
2668 EnsureSpace ensure_space(this); | 2874 EnsureSpace ensure_space(this); |
| 2875 last_pc_ = pc_; |
2669 emit(0xF2); | 2876 emit(0xF2); |
2670 emit_optional_rex_32(dst, src); | 2877 emit_optional_rex_32(dst, src); |
2671 emit(0x0F); | 2878 emit(0x0F); |
2672 emit(0x2A); | 2879 emit(0x2A); |
2673 emit_sse_operand(dst, src); | 2880 emit_sse_operand(dst, src); |
2674 } | 2881 } |
2675 | 2882 |
2676 | 2883 |
2677 void Assembler::cvtlsi2sd(XMMRegister dst, Register src) { | 2884 void Assembler::cvtlsi2sd(XMMRegister dst, Register src) { |
2678 EnsureSpace ensure_space(this); | 2885 EnsureSpace ensure_space(this); |
| 2886 last_pc_ = pc_; |
2679 emit(0xF2); | 2887 emit(0xF2); |
2680 emit_optional_rex_32(dst, src); | 2888 emit_optional_rex_32(dst, src); |
2681 emit(0x0F); | 2889 emit(0x0F); |
2682 emit(0x2A); | 2890 emit(0x2A); |
2683 emit_sse_operand(dst, src); | 2891 emit_sse_operand(dst, src); |
2684 } | 2892 } |
2685 | 2893 |
2686 | 2894 |
2687 void Assembler::cvtlsi2ss(XMMRegister dst, Register src) { | 2895 void Assembler::cvtlsi2ss(XMMRegister dst, Register src) { |
2688 EnsureSpace ensure_space(this); | 2896 EnsureSpace ensure_space(this); |
| 2897 last_pc_ = pc_; |
2689 emit(0xF3); | 2898 emit(0xF3); |
2690 emit_optional_rex_32(dst, src); | 2899 emit_optional_rex_32(dst, src); |
2691 emit(0x0F); | 2900 emit(0x0F); |
2692 emit(0x2A); | 2901 emit(0x2A); |
2693 emit_sse_operand(dst, src); | 2902 emit_sse_operand(dst, src); |
2694 } | 2903 } |
2695 | 2904 |
2696 | 2905 |
2697 void Assembler::cvtqsi2sd(XMMRegister dst, Register src) { | 2906 void Assembler::cvtqsi2sd(XMMRegister dst, Register src) { |
2698 EnsureSpace ensure_space(this); | 2907 EnsureSpace ensure_space(this); |
| 2908 last_pc_ = pc_; |
2699 emit(0xF2); | 2909 emit(0xF2); |
2700 emit_rex_64(dst, src); | 2910 emit_rex_64(dst, src); |
2701 emit(0x0F); | 2911 emit(0x0F); |
2702 emit(0x2A); | 2912 emit(0x2A); |
2703 emit_sse_operand(dst, src); | 2913 emit_sse_operand(dst, src); |
2704 } | 2914 } |
2705 | 2915 |
2706 | 2916 |
2707 void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { | 2917 void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { |
2708 EnsureSpace ensure_space(this); | 2918 EnsureSpace ensure_space(this); |
| 2919 last_pc_ = pc_; |
2709 emit(0xF3); | 2920 emit(0xF3); |
2710 emit_optional_rex_32(dst, src); | 2921 emit_optional_rex_32(dst, src); |
2711 emit(0x0F); | 2922 emit(0x0F); |
2712 emit(0x5A); | 2923 emit(0x5A); |
2713 emit_sse_operand(dst, src); | 2924 emit_sse_operand(dst, src); |
2714 } | 2925 } |
2715 | 2926 |
2716 | 2927 |
2717 void Assembler::cvtss2sd(XMMRegister dst, const Operand& src) { | 2928 void Assembler::cvtss2sd(XMMRegister dst, const Operand& src) { |
2718 EnsureSpace ensure_space(this); | 2929 EnsureSpace ensure_space(this); |
| 2930 last_pc_ = pc_; |
2719 emit(0xF3); | 2931 emit(0xF3); |
2720 emit_optional_rex_32(dst, src); | 2932 emit_optional_rex_32(dst, src); |
2721 emit(0x0F); | 2933 emit(0x0F); |
2722 emit(0x5A); | 2934 emit(0x5A); |
2723 emit_sse_operand(dst, src); | 2935 emit_sse_operand(dst, src); |
2724 } | 2936 } |
2725 | 2937 |
2726 | 2938 |
2727 void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { | 2939 void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { |
2728 EnsureSpace ensure_space(this); | 2940 EnsureSpace ensure_space(this); |
| 2941 last_pc_ = pc_; |
2729 emit(0xF2); | 2942 emit(0xF2); |
2730 emit_optional_rex_32(dst, src); | 2943 emit_optional_rex_32(dst, src); |
2731 emit(0x0F); | 2944 emit(0x0F); |
2732 emit(0x5A); | 2945 emit(0x5A); |
2733 emit_sse_operand(dst, src); | 2946 emit_sse_operand(dst, src); |
2734 } | 2947 } |
2735 | 2948 |
2736 | 2949 |
2737 void Assembler::cvtsd2si(Register dst, XMMRegister src) { | 2950 void Assembler::cvtsd2si(Register dst, XMMRegister src) { |
2738 EnsureSpace ensure_space(this); | 2951 EnsureSpace ensure_space(this); |
| 2952 last_pc_ = pc_; |
2739 emit(0xF2); | 2953 emit(0xF2); |
2740 emit_optional_rex_32(dst, src); | 2954 emit_optional_rex_32(dst, src); |
2741 emit(0x0F); | 2955 emit(0x0F); |
2742 emit(0x2D); | 2956 emit(0x2D); |
2743 emit_sse_operand(dst, src); | 2957 emit_sse_operand(dst, src); |
2744 } | 2958 } |
2745 | 2959 |
2746 | 2960 |
2747 void Assembler::cvtsd2siq(Register dst, XMMRegister src) { | 2961 void Assembler::cvtsd2siq(Register dst, XMMRegister src) { |
2748 EnsureSpace ensure_space(this); | 2962 EnsureSpace ensure_space(this); |
| 2963 last_pc_ = pc_; |
2749 emit(0xF2); | 2964 emit(0xF2); |
2750 emit_rex_64(dst, src); | 2965 emit_rex_64(dst, src); |
2751 emit(0x0F); | 2966 emit(0x0F); |
2752 emit(0x2D); | 2967 emit(0x2D); |
2753 emit_sse_operand(dst, src); | 2968 emit_sse_operand(dst, src); |
2754 } | 2969 } |
2755 | 2970 |
2756 | 2971 |
2757 void Assembler::addsd(XMMRegister dst, XMMRegister src) { | 2972 void Assembler::addsd(XMMRegister dst, XMMRegister src) { |
2758 EnsureSpace ensure_space(this); | 2973 EnsureSpace ensure_space(this); |
| 2974 last_pc_ = pc_; |
2759 emit(0xF2); | 2975 emit(0xF2); |
2760 emit_optional_rex_32(dst, src); | 2976 emit_optional_rex_32(dst, src); |
2761 emit(0x0F); | 2977 emit(0x0F); |
2762 emit(0x58); | 2978 emit(0x58); |
2763 emit_sse_operand(dst, src); | 2979 emit_sse_operand(dst, src); |
2764 } | 2980 } |
2765 | 2981 |
2766 | 2982 |
2767 void Assembler::mulsd(XMMRegister dst, XMMRegister src) { | 2983 void Assembler::mulsd(XMMRegister dst, XMMRegister src) { |
2768 EnsureSpace ensure_space(this); | 2984 EnsureSpace ensure_space(this); |
| 2985 last_pc_ = pc_; |
2769 emit(0xF2); | 2986 emit(0xF2); |
2770 emit_optional_rex_32(dst, src); | 2987 emit_optional_rex_32(dst, src); |
2771 emit(0x0F); | 2988 emit(0x0F); |
2772 emit(0x59); | 2989 emit(0x59); |
2773 emit_sse_operand(dst, src); | 2990 emit_sse_operand(dst, src); |
2774 } | 2991 } |
2775 | 2992 |
2776 | 2993 |
2777 void Assembler::subsd(XMMRegister dst, XMMRegister src) { | 2994 void Assembler::subsd(XMMRegister dst, XMMRegister src) { |
2778 EnsureSpace ensure_space(this); | 2995 EnsureSpace ensure_space(this); |
| 2996 last_pc_ = pc_; |
2779 emit(0xF2); | 2997 emit(0xF2); |
2780 emit_optional_rex_32(dst, src); | 2998 emit_optional_rex_32(dst, src); |
2781 emit(0x0F); | 2999 emit(0x0F); |
2782 emit(0x5C); | 3000 emit(0x5C); |
2783 emit_sse_operand(dst, src); | 3001 emit_sse_operand(dst, src); |
2784 } | 3002 } |
2785 | 3003 |
2786 | 3004 |
2787 void Assembler::divsd(XMMRegister dst, XMMRegister src) { | 3005 void Assembler::divsd(XMMRegister dst, XMMRegister src) { |
2788 EnsureSpace ensure_space(this); | 3006 EnsureSpace ensure_space(this); |
| 3007 last_pc_ = pc_; |
2789 emit(0xF2); | 3008 emit(0xF2); |
2790 emit_optional_rex_32(dst, src); | 3009 emit_optional_rex_32(dst, src); |
2791 emit(0x0F); | 3010 emit(0x0F); |
2792 emit(0x5E); | 3011 emit(0x5E); |
2793 emit_sse_operand(dst, src); | 3012 emit_sse_operand(dst, src); |
2794 } | 3013 } |
2795 | 3014 |
2796 | 3015 |
2797 void Assembler::andpd(XMMRegister dst, XMMRegister src) { | 3016 void Assembler::andpd(XMMRegister dst, XMMRegister src) { |
2798 EnsureSpace ensure_space(this); | 3017 EnsureSpace ensure_space(this); |
| 3018 last_pc_ = pc_; |
2799 emit(0x66); | 3019 emit(0x66); |
2800 emit_optional_rex_32(dst, src); | 3020 emit_optional_rex_32(dst, src); |
2801 emit(0x0F); | 3021 emit(0x0F); |
2802 emit(0x54); | 3022 emit(0x54); |
2803 emit_sse_operand(dst, src); | 3023 emit_sse_operand(dst, src); |
2804 } | 3024 } |
2805 | 3025 |
2806 | 3026 |
2807 void Assembler::orpd(XMMRegister dst, XMMRegister src) { | 3027 void Assembler::orpd(XMMRegister dst, XMMRegister src) { |
2808 EnsureSpace ensure_space(this); | 3028 EnsureSpace ensure_space(this); |
| 3029 last_pc_ = pc_; |
2809 emit(0x66); | 3030 emit(0x66); |
2810 emit_optional_rex_32(dst, src); | 3031 emit_optional_rex_32(dst, src); |
2811 emit(0x0F); | 3032 emit(0x0F); |
2812 emit(0x56); | 3033 emit(0x56); |
2813 emit_sse_operand(dst, src); | 3034 emit_sse_operand(dst, src); |
2814 } | 3035 } |
2815 | 3036 |
2816 | 3037 |
2817 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { | 3038 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { |
2818 EnsureSpace ensure_space(this); | 3039 EnsureSpace ensure_space(this); |
| 3040 last_pc_ = pc_; |
2819 emit(0x66); | 3041 emit(0x66); |
2820 emit_optional_rex_32(dst, src); | 3042 emit_optional_rex_32(dst, src); |
2821 emit(0x0F); | 3043 emit(0x0F); |
2822 emit(0x57); | 3044 emit(0x57); |
2823 emit_sse_operand(dst, src); | 3045 emit_sse_operand(dst, src); |
2824 } | 3046 } |
2825 | 3047 |
2826 | 3048 |
2827 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { | 3049 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { |
2828 EnsureSpace ensure_space(this); | 3050 EnsureSpace ensure_space(this); |
| 3051 last_pc_ = pc_; |
2829 emit(0xF2); | 3052 emit(0xF2); |
2830 emit_optional_rex_32(dst, src); | 3053 emit_optional_rex_32(dst, src); |
2831 emit(0x0F); | 3054 emit(0x0F); |
2832 emit(0x51); | 3055 emit(0x51); |
2833 emit_sse_operand(dst, src); | 3056 emit_sse_operand(dst, src); |
2834 } | 3057 } |
2835 | 3058 |
2836 | 3059 |
2837 void Assembler::ucomisd(XMMRegister dst, XMMRegister src) { | 3060 void Assembler::ucomisd(XMMRegister dst, XMMRegister src) { |
2838 EnsureSpace ensure_space(this); | 3061 EnsureSpace ensure_space(this); |
| 3062 last_pc_ = pc_; |
2839 emit(0x66); | 3063 emit(0x66); |
2840 emit_optional_rex_32(dst, src); | 3064 emit_optional_rex_32(dst, src); |
2841 emit(0x0f); | 3065 emit(0x0f); |
2842 emit(0x2e); | 3066 emit(0x2e); |
2843 emit_sse_operand(dst, src); | 3067 emit_sse_operand(dst, src); |
2844 } | 3068 } |
2845 | 3069 |
2846 | 3070 |
2847 void Assembler::ucomisd(XMMRegister dst, const Operand& src) { | 3071 void Assembler::ucomisd(XMMRegister dst, const Operand& src) { |
2848 EnsureSpace ensure_space(this); | 3072 EnsureSpace ensure_space(this); |
| 3073 last_pc_ = pc_; |
2849 emit(0x66); | 3074 emit(0x66); |
2850 emit_optional_rex_32(dst, src); | 3075 emit_optional_rex_32(dst, src); |
2851 emit(0x0f); | 3076 emit(0x0f); |
2852 emit(0x2e); | 3077 emit(0x2e); |
2853 emit_sse_operand(dst, src); | 3078 emit_sse_operand(dst, src); |
2854 } | 3079 } |
2855 | 3080 |
2856 | 3081 |
2857 void Assembler::movmskpd(Register dst, XMMRegister src) { | 3082 void Assembler::movmskpd(Register dst, XMMRegister src) { |
2858 EnsureSpace ensure_space(this); | 3083 EnsureSpace ensure_space(this); |
| 3084 last_pc_ = pc_; |
2859 emit(0x66); | 3085 emit(0x66); |
2860 emit_optional_rex_32(dst, src); | 3086 emit_optional_rex_32(dst, src); |
2861 emit(0x0f); | 3087 emit(0x0f); |
2862 emit(0x50); | 3088 emit(0x50); |
2863 emit_sse_operand(dst, src); | 3089 emit_sse_operand(dst, src); |
2864 } | 3090 } |
2865 | 3091 |
2866 | 3092 |
2867 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { | 3093 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { |
2868 Register ireg = { reg.code() }; | 3094 Register ireg = { reg.code() }; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2945 // specially coded on x64 means that it is a relative 32 bit address, as used | 3171 // specially coded on x64 means that it is a relative 32 bit address, as used |
2946 // by branch instructions. | 3172 // by branch instructions. |
2947 return (1 << rmode_) & kApplyMask; | 3173 return (1 << rmode_) & kApplyMask; |
2948 } | 3174 } |
2949 | 3175 |
2950 | 3176 |
2951 | 3177 |
2952 } } // namespace v8::internal | 3178 } } // namespace v8::internal |
2953 | 3179 |
2954 #endif // V8_TARGET_ARCH_X64 | 3180 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |