| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 31 // OF THE POSSIBILITY OF SUCH DAMAGE. | 31 // OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | 32 |
| 33 // The original source code covered by the above license above has been modified | 33 // The original source code covered by the above license above has been modified |
| 34 // significantly by Google Inc. | 34 // significantly by Google Inc. |
| 35 // Copyright 2011 the V8 project authors. All rights reserved. | 35 // Copyright 2012 the V8 project authors. All rights reserved. |
| 36 | 36 |
| 37 #include "v8.h" | 37 #include "v8.h" |
| 38 | 38 |
| 39 #if defined(V8_TARGET_ARCH_IA32) | 39 #if defined(V8_TARGET_ARCH_IA32) |
| 40 | 40 |
| 41 #include "disassembler.h" | 41 #include "disassembler.h" |
| 42 #include "macro-assembler.h" | 42 #include "macro-assembler.h" |
| 43 #include "serialize.h" | 43 #include "serialize.h" |
| 44 | 44 |
| 45 namespace v8 { | 45 namespace v8 { |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 492 } |
| 493 | 493 |
| 494 | 494 |
| 495 void Assembler::leave() { | 495 void Assembler::leave() { |
| 496 EnsureSpace ensure_space(this); | 496 EnsureSpace ensure_space(this); |
| 497 EMIT(0xC9); | 497 EMIT(0xC9); |
| 498 } | 498 } |
| 499 | 499 |
| 500 | 500 |
| 501 void Assembler::mov_b(Register dst, const Operand& src) { | 501 void Assembler::mov_b(Register dst, const Operand& src) { |
| 502 ASSERT(dst.code() < 4); | 502 CHECK(dst.is_byte_register()); |
| 503 EnsureSpace ensure_space(this); | 503 EnsureSpace ensure_space(this); |
| 504 EMIT(0x8A); | 504 EMIT(0x8A); |
| 505 emit_operand(dst, src); | 505 emit_operand(dst, src); |
| 506 } | 506 } |
| 507 | 507 |
| 508 | 508 |
| 509 void Assembler::mov_b(const Operand& dst, int8_t imm8) { | 509 void Assembler::mov_b(const Operand& dst, int8_t imm8) { |
| 510 EnsureSpace ensure_space(this); | 510 EnsureSpace ensure_space(this); |
| 511 EMIT(0xC6); | 511 EMIT(0xC6); |
| 512 emit_operand(eax, dst); | 512 emit_operand(eax, dst); |
| 513 EMIT(imm8); | 513 EMIT(imm8); |
| 514 } | 514 } |
| 515 | 515 |
| 516 | 516 |
| 517 void Assembler::mov_b(const Operand& dst, Register src) { | 517 void Assembler::mov_b(const Operand& dst, Register src) { |
| 518 ASSERT(src.code() < 4); | 518 CHECK(src.is_byte_register()); |
| 519 EnsureSpace ensure_space(this); | 519 EnsureSpace ensure_space(this); |
| 520 EMIT(0x88); | 520 EMIT(0x88); |
| 521 emit_operand(src, dst); | 521 emit_operand(src, dst); |
| 522 } | 522 } |
| 523 | 523 |
| 524 | 524 |
| 525 void Assembler::mov_w(Register dst, const Operand& src) { | 525 void Assembler::mov_w(Register dst, const Operand& src) { |
| 526 EnsureSpace ensure_space(this); | 526 EnsureSpace ensure_space(this); |
| 527 EMIT(0x66); | 527 EMIT(0x66); |
| 528 EMIT(0x8B); | 528 EMIT(0x8B); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 EMIT(0x3C); | 746 EMIT(0x3C); |
| 747 } else { | 747 } else { |
| 748 EMIT(0x80); | 748 EMIT(0x80); |
| 749 emit_operand(edi, op); // edi == 7 | 749 emit_operand(edi, op); // edi == 7 |
| 750 } | 750 } |
| 751 EMIT(imm8); | 751 EMIT(imm8); |
| 752 } | 752 } |
| 753 | 753 |
| 754 | 754 |
| 755 void Assembler::cmpb(const Operand& op, Register reg) { | 755 void Assembler::cmpb(const Operand& op, Register reg) { |
| 756 ASSERT(reg.is_byte_register()); | 756 CHECK(reg.is_byte_register()); |
| 757 EnsureSpace ensure_space(this); | 757 EnsureSpace ensure_space(this); |
| 758 EMIT(0x38); | 758 EMIT(0x38); |
| 759 emit_operand(reg, op); | 759 emit_operand(reg, op); |
| 760 } | 760 } |
| 761 | 761 |
| 762 | 762 |
| 763 void Assembler::cmpb(Register reg, const Operand& op) { | 763 void Assembler::cmpb(Register reg, const Operand& op) { |
| 764 ASSERT(reg.is_byte_register()); | 764 CHECK(reg.is_byte_register()); |
| 765 EnsureSpace ensure_space(this); | 765 EnsureSpace ensure_space(this); |
| 766 EMIT(0x3A); | 766 EMIT(0x3A); |
| 767 emit_operand(reg, op); | 767 emit_operand(reg, op); |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 void Assembler::cmpw(const Operand& op, Immediate imm16) { | 771 void Assembler::cmpw(const Operand& op, Immediate imm16) { |
| 772 ASSERT(imm16.is_int16()); | 772 ASSERT(imm16.is_int16()); |
| 773 EnsureSpace ensure_space(this); | 773 EnsureSpace ensure_space(this); |
| 774 EMIT(0x66); | 774 EMIT(0x66); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 818 |
| 819 void Assembler::cmpw_ax(const Operand& op) { | 819 void Assembler::cmpw_ax(const Operand& op) { |
| 820 EnsureSpace ensure_space(this); | 820 EnsureSpace ensure_space(this); |
| 821 EMIT(0x66); | 821 EMIT(0x66); |
| 822 EMIT(0x39); // CMP r/m16, r16 | 822 EMIT(0x39); // CMP r/m16, r16 |
| 823 emit_operand(eax, op); // eax has same code as register ax. | 823 emit_operand(eax, op); // eax has same code as register ax. |
| 824 } | 824 } |
| 825 | 825 |
| 826 | 826 |
| 827 void Assembler::dec_b(Register dst) { | 827 void Assembler::dec_b(Register dst) { |
| 828 CHECK(dst.is_byte_register()); |
| 828 EnsureSpace ensure_space(this); | 829 EnsureSpace ensure_space(this); |
| 829 EMIT(0xFE); | 830 EMIT(0xFE); |
| 830 EMIT(0xC8 | dst.code()); | 831 EMIT(0xC8 | dst.code()); |
| 831 } | 832 } |
| 832 | 833 |
| 833 | 834 |
| 834 void Assembler::dec_b(const Operand& dst) { | 835 void Assembler::dec_b(const Operand& dst) { |
| 835 EnsureSpace ensure_space(this); | 836 EnsureSpace ensure_space(this); |
| 836 EMIT(0xFE); | 837 EMIT(0xFE); |
| 837 emit_operand(ecx, dst); | 838 emit_operand(ecx, dst); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 EnsureSpace ensure_space(this); | 1092 EnsureSpace ensure_space(this); |
| 1092 EMIT(0x29); | 1093 EMIT(0x29); |
| 1093 emit_operand(src, dst); | 1094 emit_operand(src, dst); |
| 1094 } | 1095 } |
| 1095 | 1096 |
| 1096 | 1097 |
| 1097 void Assembler::test(Register reg, const Immediate& imm) { | 1098 void Assembler::test(Register reg, const Immediate& imm) { |
| 1098 EnsureSpace ensure_space(this); | 1099 EnsureSpace ensure_space(this); |
| 1099 // Only use test against byte for registers that have a byte | 1100 // Only use test against byte for registers that have a byte |
| 1100 // variant: eax, ebx, ecx, and edx. | 1101 // variant: eax, ebx, ecx, and edx. |
| 1101 if (imm.rmode_ == RelocInfo::NONE && is_uint8(imm.x_) && reg.code() < 4) { | 1102 if (imm.rmode_ == RelocInfo::NONE && |
| 1103 is_uint8(imm.x_) && |
| 1104 reg.is_byte_register()) { |
| 1102 uint8_t imm8 = imm.x_; | 1105 uint8_t imm8 = imm.x_; |
| 1103 if (reg.is(eax)) { | 1106 if (reg.is(eax)) { |
| 1104 EMIT(0xA8); | 1107 EMIT(0xA8); |
| 1105 EMIT(imm8); | 1108 EMIT(imm8); |
| 1106 } else { | 1109 } else { |
| 1107 emit_arith_b(0xF6, 0xC0, reg, imm8); | 1110 emit_arith_b(0xF6, 0xC0, reg, imm8); |
| 1108 } | 1111 } |
| 1109 } else { | 1112 } else { |
| 1110 // This is not using emit_arith because test doesn't support | 1113 // This is not using emit_arith because test doesn't support |
| 1111 // sign-extension of 8-bit operands. | 1114 // sign-extension of 8-bit operands. |
| 1112 if (reg.is(eax)) { | 1115 if (reg.is(eax)) { |
| 1113 EMIT(0xA9); | 1116 EMIT(0xA9); |
| 1114 } else { | 1117 } else { |
| 1115 EMIT(0xF7); | 1118 EMIT(0xF7); |
| 1116 EMIT(0xC0 | reg.code()); | 1119 EMIT(0xC0 | reg.code()); |
| 1117 } | 1120 } |
| 1118 emit(imm); | 1121 emit(imm); |
| 1119 } | 1122 } |
| 1120 } | 1123 } |
| 1121 | 1124 |
| 1122 | 1125 |
| 1123 void Assembler::test(Register reg, const Operand& op) { | 1126 void Assembler::test(Register reg, const Operand& op) { |
| 1124 EnsureSpace ensure_space(this); | 1127 EnsureSpace ensure_space(this); |
| 1125 EMIT(0x85); | 1128 EMIT(0x85); |
| 1126 emit_operand(reg, op); | 1129 emit_operand(reg, op); |
| 1127 } | 1130 } |
| 1128 | 1131 |
| 1129 | 1132 |
| 1130 void Assembler::test_b(Register reg, const Operand& op) { | 1133 void Assembler::test_b(Register reg, const Operand& op) { |
| 1134 CHECK(reg.is_byte_register()); |
| 1131 EnsureSpace ensure_space(this); | 1135 EnsureSpace ensure_space(this); |
| 1132 EMIT(0x84); | 1136 EMIT(0x84); |
| 1133 emit_operand(reg, op); | 1137 emit_operand(reg, op); |
| 1134 } | 1138 } |
| 1135 | 1139 |
| 1136 | 1140 |
| 1137 void Assembler::test(const Operand& op, const Immediate& imm) { | 1141 void Assembler::test(const Operand& op, const Immediate& imm) { |
| 1138 EnsureSpace ensure_space(this); | 1142 EnsureSpace ensure_space(this); |
| 1139 EMIT(0xF7); | 1143 EMIT(0xF7); |
| 1140 emit_operand(eax, op); | 1144 emit_operand(eax, op); |
| 1141 emit(imm); | 1145 emit(imm); |
| 1142 } | 1146 } |
| 1143 | 1147 |
| 1144 | 1148 |
| 1145 void Assembler::test_b(const Operand& op, uint8_t imm8) { | 1149 void Assembler::test_b(const Operand& op, uint8_t imm8) { |
| 1146 if (op.is_reg_only() && op.reg().code() >= 4) { | 1150 if (op.is_reg_only() && !op.reg().is_byte_register()) { |
| 1147 test(op, Immediate(imm8)); | 1151 test(op, Immediate(imm8)); |
| 1148 return; | 1152 return; |
| 1149 } | 1153 } |
| 1150 EnsureSpace ensure_space(this); | 1154 EnsureSpace ensure_space(this); |
| 1151 EMIT(0xF6); | 1155 EMIT(0xF6); |
| 1152 emit_operand(eax, op); | 1156 emit_operand(eax, op); |
| 1153 EMIT(imm8); | 1157 EMIT(imm8); |
| 1154 } | 1158 } |
| 1155 | 1159 |
| 1156 | 1160 |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 fprintf(coverage_log, "%s\n", file_line); | 2497 fprintf(coverage_log, "%s\n", file_line); |
| 2494 fflush(coverage_log); | 2498 fflush(coverage_log); |
| 2495 } | 2499 } |
| 2496 } | 2500 } |
| 2497 | 2501 |
| 2498 #endif | 2502 #endif |
| 2499 | 2503 |
| 2500 } } // namespace v8::internal | 2504 } } // namespace v8::internal |
| 2501 | 2505 |
| 2502 #endif // V8_TARGET_ARCH_IA32 | 2506 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |