| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 emit_operand(Register::toRegister(subcode), dst); | 444 emit_operand(Register::toRegister(subcode), dst); |
| 445 emit(src.value_); | 445 emit(src.value_); |
| 446 } else { | 446 } else { |
| 447 emit(0x81); | 447 emit(0x81); |
| 448 emit_operand(Register::toRegister(subcode), dst); | 448 emit_operand(Register::toRegister(subcode), dst); |
| 449 emitl(src.value_); | 449 emitl(src.value_); |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 | 452 |
| 453 | 453 |
| 454 void Assembler::immediate_arithmetic_op_32(byte subcode, |
| 455 const Operand& dst, |
| 456 Immediate src) { |
| 457 EnsureSpace ensure_space(this); |
| 458 last_pc_ = pc_; |
| 459 emit_optional_rex_32(dst); |
| 460 if (is_int8(src.value_)) { |
| 461 emit(0x83); |
| 462 emit_operand(Register::toRegister(subcode), dst); |
| 463 emit(src.value_); |
| 464 } else { |
| 465 emit(0x81); |
| 466 emit_operand(Register::toRegister(subcode), dst); |
| 467 emitl(src.value_); |
| 468 } |
| 469 } |
| 470 |
| 471 |
| 454 void Assembler::shift(Register dst, Immediate shift_amount, int subcode) { | 472 void Assembler::shift(Register dst, Immediate shift_amount, int subcode) { |
| 455 EnsureSpace ensure_space(this); | 473 EnsureSpace ensure_space(this); |
| 456 last_pc_ = pc_; | 474 last_pc_ = pc_; |
| 457 ASSERT(is_uint6(shift_amount.value_)); // illegal shift count | 475 ASSERT(is_uint6(shift_amount.value_)); // illegal shift count |
| 458 if (shift_amount.value_ == 1) { | 476 if (shift_amount.value_ == 1) { |
| 459 emit_rex_64(dst); | 477 emit_rex_64(dst); |
| 460 emit(0xD1); | 478 emit(0xD1); |
| 461 emit_modrm(subcode, dst); | 479 emit_modrm(subcode, dst); |
| 462 } else { | 480 } else { |
| 463 emit_rex_64(dst); | 481 emit_rex_64(dst); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 last_pc_ = pc_; | 541 last_pc_ = pc_; |
| 524 // Opcode: FF /2 r64 | 542 // Opcode: FF /2 r64 |
| 525 if (adr.code() > 7) { | 543 if (adr.code() > 7) { |
| 526 emit_rex_64(adr); | 544 emit_rex_64(adr); |
| 527 } | 545 } |
| 528 emit(0xFF); | 546 emit(0xFF); |
| 529 emit_modrm(0x2, adr); | 547 emit_modrm(0x2, adr); |
| 530 } | 548 } |
| 531 | 549 |
| 532 | 550 |
| 533 void Assembler::cpuid() { | |
| 534 ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID)); | |
| 535 EnsureSpace ensure_space(this); | |
| 536 last_pc_ = pc_; | |
| 537 emit(0x0F); | |
| 538 emit(0xA2); | |
| 539 } | |
| 540 | |
| 541 | |
| 542 void Assembler::call(const Operand& op) { | 551 void Assembler::call(const Operand& op) { |
| 543 EnsureSpace ensure_space(this); | 552 EnsureSpace ensure_space(this); |
| 544 last_pc_ = pc_; | 553 last_pc_ = pc_; |
| 545 // Opcode: FF /2 m64 | 554 // Opcode: FF /2 m64 |
| 546 emit_rex_64(op); | 555 emit_rex_64(op); |
| 547 emit(0xFF); | 556 emit(0xFF); |
| 548 emit_operand(2, op); | 557 emit_operand(2, op); |
| 549 } | 558 } |
| 550 | 559 |
| 551 | 560 |
| 561 void Assembler::cpuid() { |
| 562 ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID)); |
| 563 EnsureSpace ensure_space(this); |
| 564 last_pc_ = pc_; |
| 565 emit(0x0F); |
| 566 emit(0xA2); |
| 567 } |
| 568 |
| 569 |
| 552 void Assembler::cqo() { | 570 void Assembler::cqo() { |
| 553 EnsureSpace ensure_space(this); | 571 EnsureSpace ensure_space(this); |
| 554 last_pc_ = pc_; | 572 last_pc_ = pc_; |
| 555 emit_rex_64(); | 573 emit_rex_64(); |
| 556 emit(0x99); | 574 emit(0x99); |
| 557 } | 575 } |
| 558 | 576 |
| 559 | 577 |
| 560 void Assembler::dec(Register dst) { | 578 void Assembler::decq(Register dst) { |
| 561 EnsureSpace ensure_space(this); | 579 EnsureSpace ensure_space(this); |
| 562 last_pc_ = pc_; | 580 last_pc_ = pc_; |
| 563 emit_rex_64(dst); | 581 emit_rex_64(dst); |
| 564 emit(0xFF); | 582 emit(0xFF); |
| 565 emit_modrm(0x1, dst); | 583 emit_modrm(0x1, dst); |
| 566 } | 584 } |
| 567 | 585 |
| 568 | 586 |
| 569 void Assembler::dec(const Operand& dst) { | 587 void Assembler::decq(const Operand& dst) { |
| 570 EnsureSpace ensure_space(this); | 588 EnsureSpace ensure_space(this); |
| 571 last_pc_ = pc_; | 589 last_pc_ = pc_; |
| 572 emit_rex_64(dst); | 590 emit_rex_64(dst); |
| 573 emit(0xFF); | 591 emit(0xFF); |
| 574 emit_operand(1, dst); | 592 emit_operand(1, dst); |
| 575 } | 593 } |
| 576 | 594 |
| 577 | 595 |
| 596 void Assembler::decl(const Operand& dst) { |
| 597 EnsureSpace ensure_space(this); |
| 598 last_pc_ = pc_; |
| 599 emit_optional_rex_32(dst); |
| 600 emit(0xFF); |
| 601 emit_operand(1, dst); |
| 602 } |
| 603 |
| 604 |
| 578 void Assembler::enter(Immediate size) { | 605 void Assembler::enter(Immediate size) { |
| 579 EnsureSpace ensure_space(this); | 606 EnsureSpace ensure_space(this); |
| 580 last_pc_ = pc_; | 607 last_pc_ = pc_; |
| 581 emit(0xC8); | 608 emit(0xC8); |
| 582 emitw(size.value_); // 16 bit operand, always. | 609 emitw(size.value_); // 16 bit operand, always. |
| 583 emit(0); | 610 emit(0); |
| 584 } | 611 } |
| 585 | 612 |
| 586 | 613 |
| 587 void Assembler::hlt() { | 614 void Assembler::hlt() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 emit_modrm(dst, src); | 646 emit_modrm(dst, src); |
| 620 emit(imm.value_); | 647 emit(imm.value_); |
| 621 } else { | 648 } else { |
| 622 emit(0x69); | 649 emit(0x69); |
| 623 emit_modrm(dst, src); | 650 emit_modrm(dst, src); |
| 624 emitl(imm.value_); | 651 emitl(imm.value_); |
| 625 } | 652 } |
| 626 } | 653 } |
| 627 | 654 |
| 628 | 655 |
| 629 void Assembler::inc(Register dst) { | 656 void Assembler::incq(Register dst) { |
| 630 EnsureSpace ensure_space(this); | 657 EnsureSpace ensure_space(this); |
| 631 last_pc_ = pc_; | 658 last_pc_ = pc_; |
| 632 emit_rex_64(dst); | 659 emit_rex_64(dst); |
| 633 emit(0xFF); | 660 emit(0xFF); |
| 634 emit_modrm(0x0, dst); | 661 emit_modrm(0x0, dst); |
| 635 } | 662 } |
| 636 | 663 |
| 637 | 664 |
| 638 void Assembler::inc(const Operand& dst) { | 665 void Assembler::incq(const Operand& dst) { |
| 639 EnsureSpace ensure_space(this); | 666 EnsureSpace ensure_space(this); |
| 640 last_pc_ = pc_; | 667 last_pc_ = pc_; |
| 641 emit_rex_64(dst); | 668 emit_rex_64(dst); |
| 642 emit(0xFF); | 669 emit(0xFF); |
| 643 emit_operand(0, dst); | 670 emit_operand(0, dst); |
| 644 } | 671 } |
| 645 | 672 |
| 646 | 673 |
| 674 void Assembler::incl(const Operand& dst) { |
| 675 EnsureSpace ensure_space(this); |
| 676 last_pc_ = pc_; |
| 677 emit_optional_rex_32(dst); |
| 678 emit(0xFF); |
| 679 emit_operand(0, dst); |
| 680 } |
| 681 |
| 682 |
| 647 void Assembler::int3() { | 683 void Assembler::int3() { |
| 648 EnsureSpace ensure_space(this); | 684 EnsureSpace ensure_space(this); |
| 649 last_pc_ = pc_; | 685 last_pc_ = pc_; |
| 650 emit(0xCC); | 686 emit(0xCC); |
| 651 } | 687 } |
| 652 | 688 |
| 653 | 689 |
| 654 void Assembler::j(Condition cc, Label* L) { | 690 void Assembler::j(Condition cc, Label* L) { |
| 655 EnsureSpace ensure_space(this); | 691 EnsureSpace ensure_space(this); |
| 656 last_pc_ = pc_; | 692 last_pc_ = pc_; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 | 841 |
| 806 void Assembler::movl(const Operand& dst, Register src) { | 842 void Assembler::movl(const Operand& dst, Register src) { |
| 807 EnsureSpace ensure_space(this); | 843 EnsureSpace ensure_space(this); |
| 808 last_pc_ = pc_; | 844 last_pc_ = pc_; |
| 809 emit_optional_rex_32(src, dst); | 845 emit_optional_rex_32(src, dst); |
| 810 emit(0x89); | 846 emit(0x89); |
| 811 emit_operand(src, dst); | 847 emit_operand(src, dst); |
| 812 } | 848 } |
| 813 | 849 |
| 814 | 850 |
| 851 void Assembler::movl(const Operand& dst, Immediate value) { |
| 852 EnsureSpace ensure_space(this); |
| 853 last_pc_ = pc_; |
| 854 emit_optional_rex_32(dst); |
| 855 emit(0xC7); |
| 856 emit_operand(0x0, dst); |
| 857 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. |
| 858 } |
| 859 |
| 860 |
| 815 void Assembler::movl(Register dst, Immediate value) { | 861 void Assembler::movl(Register dst, Immediate value) { |
| 816 EnsureSpace ensure_space(this); | 862 EnsureSpace ensure_space(this); |
| 817 last_pc_ = pc_; | 863 last_pc_ = pc_; |
| 818 emit_optional_rex_32(dst); | 864 emit_optional_rex_32(dst); |
| 819 emit(0xC7); | 865 emit(0xC7); |
| 820 emit_modrm(0x0, dst); | 866 emit_modrm(0x0, dst); |
| 821 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. | 867 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. |
| 822 } | 868 } |
| 823 | 869 |
| 824 | 870 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 emit(0xD1); | 1171 emit(0xD1); |
| 1126 emit_modrm(0x2, dst); | 1172 emit_modrm(0x2, dst); |
| 1127 } else { | 1173 } else { |
| 1128 emit_rex_64(dst); | 1174 emit_rex_64(dst); |
| 1129 emit(0xC1); | 1175 emit(0xC1); |
| 1130 emit_modrm(0x2, dst); | 1176 emit_modrm(0x2, dst); |
| 1131 emit(imm8); | 1177 emit(imm8); |
| 1132 } | 1178 } |
| 1133 } | 1179 } |
| 1134 | 1180 |
| 1181 void Assembler::rdtsc() { |
| 1182 EnsureSpace ensure_space(this); |
| 1183 last_pc_ = pc_; |
| 1184 emit(0x0F); |
| 1185 emit(0x31); |
| 1186 } |
| 1187 |
| 1135 | 1188 |
| 1136 void Assembler::ret(int imm16) { | 1189 void Assembler::ret(int imm16) { |
| 1137 EnsureSpace ensure_space(this); | 1190 EnsureSpace ensure_space(this); |
| 1138 last_pc_ = pc_; | 1191 last_pc_ = pc_; |
| 1139 ASSERT(is_uint16(imm16)); | 1192 ASSERT(is_uint16(imm16)); |
| 1140 if (imm16 == 0) { | 1193 if (imm16 == 0) { |
| 1141 emit(0xC3); | 1194 emit(0xC3); |
| 1142 } else { | 1195 } else { |
| 1143 emit(0xC2); | 1196 emit(0xC2); |
| 1144 emit(imm16 & 0xFF); | 1197 emit(imm16 & 0xFF); |
| 1145 emit((imm16 >> 8) & 0xFF); | 1198 emit((imm16 >> 8) & 0xFF); |
| 1146 } | 1199 } |
| 1147 } | 1200 } |
| 1148 | 1201 |
| 1149 | 1202 |
| 1203 void Assembler::setcc(Condition cc, Register reg) { |
| 1204 EnsureSpace ensure_space(this); |
| 1205 last_pc_ = pc_; |
| 1206 ASSERT(0 <= cc && cc < 16); |
| 1207 if (reg.code() > 3) { // Use x64 byte registers, where different. |
| 1208 emit_rex_32(reg); |
| 1209 } |
| 1210 emit(0x0F); |
| 1211 emit(0x90 | cc); |
| 1212 emit_modrm(0x0, reg); |
| 1213 } |
| 1214 |
| 1215 |
| 1150 void Assembler::shld(Register dst, Register src) { | 1216 void Assembler::shld(Register dst, Register src) { |
| 1151 EnsureSpace ensure_space(this); | 1217 EnsureSpace ensure_space(this); |
| 1152 last_pc_ = pc_; | 1218 last_pc_ = pc_; |
| 1153 emit_rex_64(src, dst); | 1219 emit_rex_64(src, dst); |
| 1154 emit(0x0F); | 1220 emit(0x0F); |
| 1155 emit(0xA5); | 1221 emit(0xA5); |
| 1156 emit_modrm(src, dst); | 1222 emit_modrm(src, dst); |
| 1157 } | 1223 } |
| 1158 | 1224 |
| 1159 | 1225 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 UNIMPLEMENTED(); | 1691 UNIMPLEMENTED(); |
| 1626 return NULL; | 1692 return NULL; |
| 1627 } | 1693 } |
| 1628 | 1694 |
| 1629 byte* JavaScriptFrame::GetCallerStackPointer() const { | 1695 byte* JavaScriptFrame::GetCallerStackPointer() const { |
| 1630 UNIMPLEMENTED(); | 1696 UNIMPLEMENTED(); |
| 1631 return NULL; | 1697 return NULL; |
| 1632 } | 1698 } |
| 1633 | 1699 |
| 1634 } } // namespace v8::internal | 1700 } } // namespace v8::internal |
| OLD | NEW |