| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 | 59 |
| 60 void CpuFeatures::PrintTarget() { } | 60 void CpuFeatures::PrintTarget() { } |
| 61 void CpuFeatures::PrintFeatures() { } | 61 void CpuFeatures::PrintFeatures() { } |
| 62 | 62 |
| 63 | 63 |
| 64 // ----------------------------------------------------------------------------- | 64 // ----------------------------------------------------------------------------- |
| 65 // Implementation of Displacement | 65 // Implementation of Displacement |
| 66 | 66 |
| 67 void Displacement::init(Label* L, Type type) { | 67 void Displacement::init(Label* L, Type type) { |
| 68 ASSERT(!L->is_bound()); | 68 DCHECK(!L->is_bound()); |
| 69 int next = 0; | 69 int next = 0; |
| 70 if (L->is_linked()) { | 70 if (L->is_linked()) { |
| 71 next = L->pos(); | 71 next = L->pos(); |
| 72 ASSERT(next > 0); // Displacements must be at positions > 0 | 72 DCHECK(next > 0); // Displacements must be at positions > 0 |
| 73 } | 73 } |
| 74 // Ensure that we _never_ overflow the next field. | 74 // Ensure that we _never_ overflow the next field. |
| 75 ASSERT(NextField::is_valid(Assembler::kMaximalBufferSize)); | 75 DCHECK(NextField::is_valid(Assembler::kMaximalBufferSize)); |
| 76 data_ = NextField::encode(next) | TypeField::encode(type); | 76 data_ = NextField::encode(next) | TypeField::encode(type); |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 // ----------------------------------------------------------------------------- | 80 // ----------------------------------------------------------------------------- |
| 81 // Implementation of RelocInfo | 81 // Implementation of RelocInfo |
| 82 | 82 |
| 83 | 83 |
| 84 const int RelocInfo::kApplyMask = | 84 const int RelocInfo::kApplyMask = |
| 85 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY | | 85 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY | |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Add a label for checking the size of the code used for returning. | 125 // Add a label for checking the size of the code used for returning. |
| 126 #ifdef DEBUG | 126 #ifdef DEBUG |
| 127 Label check_codesize; | 127 Label check_codesize; |
| 128 patcher.masm()->bind(&check_codesize); | 128 patcher.masm()->bind(&check_codesize); |
| 129 #endif | 129 #endif |
| 130 | 130 |
| 131 // Patch the code. | 131 // Patch the code. |
| 132 patcher.masm()->call(target, RelocInfo::NONE32); | 132 patcher.masm()->call(target, RelocInfo::NONE32); |
| 133 | 133 |
| 134 // Check that the size of the code generated is as expected. | 134 // Check that the size of the code generated is as expected. |
| 135 ASSERT_EQ(kCallCodeSize, | 135 DCHECK_EQ(kCallCodeSize, |
| 136 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); | 136 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); |
| 137 | 137 |
| 138 // Add the requested number of int3 instructions after the call. | 138 // Add the requested number of int3 instructions after the call. |
| 139 ASSERT_GE(guard_bytes, 0); | 139 DCHECK_GE(guard_bytes, 0); |
| 140 for (int i = 0; i < guard_bytes; i++) { | 140 for (int i = 0; i < guard_bytes; i++) { |
| 141 patcher.masm()->int3(); | 141 patcher.masm()->int3(); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 // ----------------------------------------------------------------------------- | 146 // ----------------------------------------------------------------------------- |
| 147 // Implementation of Operand | 147 // Implementation of Operand |
| 148 | 148 |
| 149 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { | 149 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 164 set_dispr(disp, rmode); | 164 set_dispr(disp, rmode); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| 169 Operand::Operand(Register base, | 169 Operand::Operand(Register base, |
| 170 Register index, | 170 Register index, |
| 171 ScaleFactor scale, | 171 ScaleFactor scale, |
| 172 int32_t disp, | 172 int32_t disp, |
| 173 RelocInfo::Mode rmode) { | 173 RelocInfo::Mode rmode) { |
| 174 ASSERT(!index.is(esp)); // illegal addressing mode | 174 DCHECK(!index.is(esp)); // illegal addressing mode |
| 175 // [base + index*scale + disp/r] | 175 // [base + index*scale + disp/r] |
| 176 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { | 176 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { |
| 177 // [base + index*scale] | 177 // [base + index*scale] |
| 178 set_modrm(0, esp); | 178 set_modrm(0, esp); |
| 179 set_sib(scale, index, base); | 179 set_sib(scale, index, base); |
| 180 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { | 180 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { |
| 181 // [base + index*scale + disp8] | 181 // [base + index*scale + disp8] |
| 182 set_modrm(1, esp); | 182 set_modrm(1, esp); |
| 183 set_sib(scale, index, base); | 183 set_sib(scale, index, base); |
| 184 set_disp8(disp); | 184 set_disp8(disp); |
| 185 } else { | 185 } else { |
| 186 // [base + index*scale + disp/r] | 186 // [base + index*scale + disp/r] |
| 187 set_modrm(2, esp); | 187 set_modrm(2, esp); |
| 188 set_sib(scale, index, base); | 188 set_sib(scale, index, base); |
| 189 set_dispr(disp, rmode); | 189 set_dispr(disp, rmode); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 | 193 |
| 194 Operand::Operand(Register index, | 194 Operand::Operand(Register index, |
| 195 ScaleFactor scale, | 195 ScaleFactor scale, |
| 196 int32_t disp, | 196 int32_t disp, |
| 197 RelocInfo::Mode rmode) { | 197 RelocInfo::Mode rmode) { |
| 198 ASSERT(!index.is(esp)); // illegal addressing mode | 198 DCHECK(!index.is(esp)); // illegal addressing mode |
| 199 // [index*scale + disp/r] | 199 // [index*scale + disp/r] |
| 200 set_modrm(0, esp); | 200 set_modrm(0, esp); |
| 201 set_sib(scale, index, ebp); | 201 set_sib(scale, index, ebp); |
| 202 set_dispr(disp, rmode); | 202 set_dispr(disp, rmode); |
| 203 } | 203 } |
| 204 | 204 |
| 205 | 205 |
| 206 bool Operand::is_reg(Register reg) const { | 206 bool Operand::is_reg(Register reg) const { |
| 207 return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only. | 207 return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only. |
| 208 && ((buf_[0] & 0x07) == reg.code()); // register codes match. | 208 && ((buf_[0] & 0x07) == reg.code()); // register codes match. |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 bool Operand::is_reg_only() const { | 212 bool Operand::is_reg_only() const { |
| 213 return (buf_[0] & 0xF8) == 0xC0; // Addressing mode is register only. | 213 return (buf_[0] & 0xF8) == 0xC0; // Addressing mode is register only. |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 Register Operand::reg() const { | 217 Register Operand::reg() const { |
| 218 ASSERT(is_reg_only()); | 218 DCHECK(is_reg_only()); |
| 219 return Register::from_code(buf_[0] & 0x07); | 219 return Register::from_code(buf_[0] & 0x07); |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 // ----------------------------------------------------------------------------- | 223 // ----------------------------------------------------------------------------- |
| 224 // Implementation of Assembler. | 224 // Implementation of Assembler. |
| 225 | 225 |
| 226 // Emit a single byte. Must always be inlined. | 226 // Emit a single byte. Must always be inlined. |
| 227 #define EMIT(x) \ | 227 #define EMIT(x) \ |
| 228 *pc_++ = (x) | 228 *pc_++ = (x) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 248 | 248 |
| 249 #ifdef GENERATED_CODE_COVERAGE | 249 #ifdef GENERATED_CODE_COVERAGE |
| 250 InitCoverageLog(); | 250 InitCoverageLog(); |
| 251 #endif | 251 #endif |
| 252 } | 252 } |
| 253 | 253 |
| 254 | 254 |
| 255 void Assembler::GetCode(CodeDesc* desc) { | 255 void Assembler::GetCode(CodeDesc* desc) { |
| 256 // Finalize code (at this point overflow() may be true, but the gap ensures | 256 // Finalize code (at this point overflow() may be true, but the gap ensures |
| 257 // that we are still not overlapping instructions and relocation info). | 257 // that we are still not overlapping instructions and relocation info). |
| 258 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. | 258 DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. |
| 259 // Set up code descriptor. | 259 // Set up code descriptor. |
| 260 desc->buffer = buffer_; | 260 desc->buffer = buffer_; |
| 261 desc->buffer_size = buffer_size_; | 261 desc->buffer_size = buffer_size_; |
| 262 desc->instr_size = pc_offset(); | 262 desc->instr_size = pc_offset(); |
| 263 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 263 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
| 264 desc->origin = this; | 264 desc->origin = this; |
| 265 } | 265 } |
| 266 | 266 |
| 267 | 267 |
| 268 void Assembler::Align(int m) { | 268 void Assembler::Align(int m) { |
| 269 ASSERT(IsPowerOf2(m)); | 269 DCHECK(IsPowerOf2(m)); |
| 270 int mask = m - 1; | 270 int mask = m - 1; |
| 271 int addr = pc_offset(); | 271 int addr = pc_offset(); |
| 272 Nop((m - (addr & mask)) & mask); | 272 Nop((m - (addr & mask)) & mask); |
| 273 } | 273 } |
| 274 | 274 |
| 275 | 275 |
| 276 bool Assembler::IsNop(Address addr) { | 276 bool Assembler::IsNop(Address addr) { |
| 277 Address a = addr; | 277 Address a = addr; |
| 278 while (*a == 0x66) a++; | 278 while (*a == 0x66) a++; |
| 279 if (*a == 0x90) return true; | 279 if (*a == 0x90) return true; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 356 |
| 357 | 357 |
| 358 void Assembler::push(const Operand& src) { | 358 void Assembler::push(const Operand& src) { |
| 359 EnsureSpace ensure_space(this); | 359 EnsureSpace ensure_space(this); |
| 360 EMIT(0xFF); | 360 EMIT(0xFF); |
| 361 emit_operand(esi, src); | 361 emit_operand(esi, src); |
| 362 } | 362 } |
| 363 | 363 |
| 364 | 364 |
| 365 void Assembler::pop(Register dst) { | 365 void Assembler::pop(Register dst) { |
| 366 ASSERT(reloc_info_writer.last_pc() != NULL); | 366 DCHECK(reloc_info_writer.last_pc() != NULL); |
| 367 EnsureSpace ensure_space(this); | 367 EnsureSpace ensure_space(this); |
| 368 EMIT(0x58 | dst.code()); | 368 EMIT(0x58 | dst.code()); |
| 369 } | 369 } |
| 370 | 370 |
| 371 | 371 |
| 372 void Assembler::pop(const Operand& dst) { | 372 void Assembler::pop(const Operand& dst) { |
| 373 EnsureSpace ensure_space(this); | 373 EnsureSpace ensure_space(this); |
| 374 EMIT(0x8F); | 374 EMIT(0x8F); |
| 375 emit_operand(eax, dst); | 375 emit_operand(eax, dst); |
| 376 } | 376 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 | 596 |
| 597 void Assembler::add(const Operand& dst, Register src) { | 597 void Assembler::add(const Operand& dst, Register src) { |
| 598 EnsureSpace ensure_space(this); | 598 EnsureSpace ensure_space(this); |
| 599 EMIT(0x01); | 599 EMIT(0x01); |
| 600 emit_operand(src, dst); | 600 emit_operand(src, dst); |
| 601 } | 601 } |
| 602 | 602 |
| 603 | 603 |
| 604 void Assembler::add(const Operand& dst, const Immediate& x) { | 604 void Assembler::add(const Operand& dst, const Immediate& x) { |
| 605 ASSERT(reloc_info_writer.last_pc() != NULL); | 605 DCHECK(reloc_info_writer.last_pc() != NULL); |
| 606 EnsureSpace ensure_space(this); | 606 EnsureSpace ensure_space(this); |
| 607 emit_arith(0, dst, x); | 607 emit_arith(0, dst, x); |
| 608 } | 608 } |
| 609 | 609 |
| 610 | 610 |
| 611 void Assembler::and_(Register dst, int32_t imm32) { | 611 void Assembler::and_(Register dst, int32_t imm32) { |
| 612 and_(dst, Immediate(imm32)); | 612 and_(dst, Immediate(imm32)); |
| 613 } | 613 } |
| 614 | 614 |
| 615 | 615 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 661 |
| 662 void Assembler::cmpb(Register reg, const Operand& op) { | 662 void Assembler::cmpb(Register reg, const Operand& op) { |
| 663 CHECK(reg.is_byte_register()); | 663 CHECK(reg.is_byte_register()); |
| 664 EnsureSpace ensure_space(this); | 664 EnsureSpace ensure_space(this); |
| 665 EMIT(0x3A); | 665 EMIT(0x3A); |
| 666 emit_operand(reg, op); | 666 emit_operand(reg, op); |
| 667 } | 667 } |
| 668 | 668 |
| 669 | 669 |
| 670 void Assembler::cmpw(const Operand& op, Immediate imm16) { | 670 void Assembler::cmpw(const Operand& op, Immediate imm16) { |
| 671 ASSERT(imm16.is_int16()); | 671 DCHECK(imm16.is_int16()); |
| 672 EnsureSpace ensure_space(this); | 672 EnsureSpace ensure_space(this); |
| 673 EMIT(0x66); | 673 EMIT(0x66); |
| 674 EMIT(0x81); | 674 EMIT(0x81); |
| 675 emit_operand(edi, op); | 675 emit_operand(edi, op); |
| 676 emit_w(imm16); | 676 emit_w(imm16); |
| 677 } | 677 } |
| 678 | 678 |
| 679 | 679 |
| 680 void Assembler::cmp(Register reg, int32_t imm32) { | 680 void Assembler::cmp(Register reg, int32_t imm32) { |
| 681 EnsureSpace ensure_space(this); | 681 EnsureSpace ensure_space(this); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 | 881 |
| 882 void Assembler::or_(const Operand& dst, Register src) { | 882 void Assembler::or_(const Operand& dst, Register src) { |
| 883 EnsureSpace ensure_space(this); | 883 EnsureSpace ensure_space(this); |
| 884 EMIT(0x09); | 884 EMIT(0x09); |
| 885 emit_operand(src, dst); | 885 emit_operand(src, dst); |
| 886 } | 886 } |
| 887 | 887 |
| 888 | 888 |
| 889 void Assembler::rcl(Register dst, uint8_t imm8) { | 889 void Assembler::rcl(Register dst, uint8_t imm8) { |
| 890 EnsureSpace ensure_space(this); | 890 EnsureSpace ensure_space(this); |
| 891 ASSERT(is_uint5(imm8)); // illegal shift count | 891 DCHECK(is_uint5(imm8)); // illegal shift count |
| 892 if (imm8 == 1) { | 892 if (imm8 == 1) { |
| 893 EMIT(0xD1); | 893 EMIT(0xD1); |
| 894 EMIT(0xD0 | dst.code()); | 894 EMIT(0xD0 | dst.code()); |
| 895 } else { | 895 } else { |
| 896 EMIT(0xC1); | 896 EMIT(0xC1); |
| 897 EMIT(0xD0 | dst.code()); | 897 EMIT(0xD0 | dst.code()); |
| 898 EMIT(imm8); | 898 EMIT(imm8); |
| 899 } | 899 } |
| 900 } | 900 } |
| 901 | 901 |
| 902 | 902 |
| 903 void Assembler::rcr(Register dst, uint8_t imm8) { | 903 void Assembler::rcr(Register dst, uint8_t imm8) { |
| 904 EnsureSpace ensure_space(this); | 904 EnsureSpace ensure_space(this); |
| 905 ASSERT(is_uint5(imm8)); // illegal shift count | 905 DCHECK(is_uint5(imm8)); // illegal shift count |
| 906 if (imm8 == 1) { | 906 if (imm8 == 1) { |
| 907 EMIT(0xD1); | 907 EMIT(0xD1); |
| 908 EMIT(0xD8 | dst.code()); | 908 EMIT(0xD8 | dst.code()); |
| 909 } else { | 909 } else { |
| 910 EMIT(0xC1); | 910 EMIT(0xC1); |
| 911 EMIT(0xD8 | dst.code()); | 911 EMIT(0xD8 | dst.code()); |
| 912 EMIT(imm8); | 912 EMIT(imm8); |
| 913 } | 913 } |
| 914 } | 914 } |
| 915 | 915 |
| 916 | 916 |
| 917 void Assembler::ror(Register dst, uint8_t imm8) { | 917 void Assembler::ror(Register dst, uint8_t imm8) { |
| 918 EnsureSpace ensure_space(this); | 918 EnsureSpace ensure_space(this); |
| 919 ASSERT(is_uint5(imm8)); // illegal shift count | 919 DCHECK(is_uint5(imm8)); // illegal shift count |
| 920 if (imm8 == 1) { | 920 if (imm8 == 1) { |
| 921 EMIT(0xD1); | 921 EMIT(0xD1); |
| 922 EMIT(0xC8 | dst.code()); | 922 EMIT(0xC8 | dst.code()); |
| 923 } else { | 923 } else { |
| 924 EMIT(0xC1); | 924 EMIT(0xC1); |
| 925 EMIT(0xC8 | dst.code()); | 925 EMIT(0xC8 | dst.code()); |
| 926 EMIT(imm8); | 926 EMIT(imm8); |
| 927 } | 927 } |
| 928 } | 928 } |
| 929 | 929 |
| 930 | 930 |
| 931 void Assembler::ror_cl(Register dst) { | 931 void Assembler::ror_cl(Register dst) { |
| 932 EnsureSpace ensure_space(this); | 932 EnsureSpace ensure_space(this); |
| 933 EMIT(0xD3); | 933 EMIT(0xD3); |
| 934 EMIT(0xC8 | dst.code()); | 934 EMIT(0xC8 | dst.code()); |
| 935 } | 935 } |
| 936 | 936 |
| 937 | 937 |
| 938 void Assembler::sar(const Operand& dst, uint8_t imm8) { | 938 void Assembler::sar(const Operand& dst, uint8_t imm8) { |
| 939 EnsureSpace ensure_space(this); | 939 EnsureSpace ensure_space(this); |
| 940 ASSERT(is_uint5(imm8)); // illegal shift count | 940 DCHECK(is_uint5(imm8)); // illegal shift count |
| 941 if (imm8 == 1) { | 941 if (imm8 == 1) { |
| 942 EMIT(0xD1); | 942 EMIT(0xD1); |
| 943 emit_operand(edi, dst); | 943 emit_operand(edi, dst); |
| 944 } else { | 944 } else { |
| 945 EMIT(0xC1); | 945 EMIT(0xC1); |
| 946 emit_operand(edi, dst); | 946 emit_operand(edi, dst); |
| 947 EMIT(imm8); | 947 EMIT(imm8); |
| 948 } | 948 } |
| 949 } | 949 } |
| 950 | 950 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 966 void Assembler::shld(Register dst, const Operand& src) { | 966 void Assembler::shld(Register dst, const Operand& src) { |
| 967 EnsureSpace ensure_space(this); | 967 EnsureSpace ensure_space(this); |
| 968 EMIT(0x0F); | 968 EMIT(0x0F); |
| 969 EMIT(0xA5); | 969 EMIT(0xA5); |
| 970 emit_operand(dst, src); | 970 emit_operand(dst, src); |
| 971 } | 971 } |
| 972 | 972 |
| 973 | 973 |
| 974 void Assembler::shl(const Operand& dst, uint8_t imm8) { | 974 void Assembler::shl(const Operand& dst, uint8_t imm8) { |
| 975 EnsureSpace ensure_space(this); | 975 EnsureSpace ensure_space(this); |
| 976 ASSERT(is_uint5(imm8)); // illegal shift count | 976 DCHECK(is_uint5(imm8)); // illegal shift count |
| 977 if (imm8 == 1) { | 977 if (imm8 == 1) { |
| 978 EMIT(0xD1); | 978 EMIT(0xD1); |
| 979 emit_operand(esp, dst); | 979 emit_operand(esp, dst); |
| 980 } else { | 980 } else { |
| 981 EMIT(0xC1); | 981 EMIT(0xC1); |
| 982 emit_operand(esp, dst); | 982 emit_operand(esp, dst); |
| 983 EMIT(imm8); | 983 EMIT(imm8); |
| 984 } | 984 } |
| 985 } | 985 } |
| 986 | 986 |
| 987 | 987 |
| 988 void Assembler::shl_cl(const Operand& dst) { | 988 void Assembler::shl_cl(const Operand& dst) { |
| 989 EnsureSpace ensure_space(this); | 989 EnsureSpace ensure_space(this); |
| 990 EMIT(0xD3); | 990 EMIT(0xD3); |
| 991 emit_operand(esp, dst); | 991 emit_operand(esp, dst); |
| 992 } | 992 } |
| 993 | 993 |
| 994 | 994 |
| 995 void Assembler::shrd(Register dst, const Operand& src) { | 995 void Assembler::shrd(Register dst, const Operand& src) { |
| 996 EnsureSpace ensure_space(this); | 996 EnsureSpace ensure_space(this); |
| 997 EMIT(0x0F); | 997 EMIT(0x0F); |
| 998 EMIT(0xAD); | 998 EMIT(0xAD); |
| 999 emit_operand(dst, src); | 999 emit_operand(dst, src); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 | 1002 |
| 1003 void Assembler::shr(const Operand& dst, uint8_t imm8) { | 1003 void Assembler::shr(const Operand& dst, uint8_t imm8) { |
| 1004 EnsureSpace ensure_space(this); | 1004 EnsureSpace ensure_space(this); |
| 1005 ASSERT(is_uint5(imm8)); // illegal shift count | 1005 DCHECK(is_uint5(imm8)); // illegal shift count |
| 1006 if (imm8 == 1) { | 1006 if (imm8 == 1) { |
| 1007 EMIT(0xD1); | 1007 EMIT(0xD1); |
| 1008 emit_operand(ebp, dst); | 1008 emit_operand(ebp, dst); |
| 1009 } else { | 1009 } else { |
| 1010 EMIT(0xC1); | 1010 EMIT(0xC1); |
| 1011 emit_operand(ebp, dst); | 1011 emit_operand(ebp, dst); |
| 1012 EMIT(imm8); | 1012 EMIT(imm8); |
| 1013 } | 1013 } |
| 1014 } | 1014 } |
| 1015 | 1015 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 | 1182 |
| 1183 | 1183 |
| 1184 void Assembler::nop() { | 1184 void Assembler::nop() { |
| 1185 EnsureSpace ensure_space(this); | 1185 EnsureSpace ensure_space(this); |
| 1186 EMIT(0x90); | 1186 EMIT(0x90); |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 | 1189 |
| 1190 void Assembler::ret(int imm16) { | 1190 void Assembler::ret(int imm16) { |
| 1191 EnsureSpace ensure_space(this); | 1191 EnsureSpace ensure_space(this); |
| 1192 ASSERT(is_uint16(imm16)); | 1192 DCHECK(is_uint16(imm16)); |
| 1193 if (imm16 == 0) { | 1193 if (imm16 == 0) { |
| 1194 EMIT(0xC3); | 1194 EMIT(0xC3); |
| 1195 } else { | 1195 } else { |
| 1196 EMIT(0xC2); | 1196 EMIT(0xC2); |
| 1197 EMIT(imm16 & 0xFF); | 1197 EMIT(imm16 & 0xFF); |
| 1198 EMIT((imm16 >> 8) & 0xFF); | 1198 EMIT((imm16 >> 8) & 0xFF); |
| 1199 } | 1199 } |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 | 1202 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1227 disp.next(&l); | 1227 disp.next(&l); |
| 1228 } | 1228 } |
| 1229 } else { | 1229 } else { |
| 1230 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); | 1230 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); |
| 1231 } | 1231 } |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 | 1234 |
| 1235 void Assembler::bind_to(Label* L, int pos) { | 1235 void Assembler::bind_to(Label* L, int pos) { |
| 1236 EnsureSpace ensure_space(this); | 1236 EnsureSpace ensure_space(this); |
| 1237 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position | 1237 DCHECK(0 <= pos && pos <= pc_offset()); // must have a valid binding position |
| 1238 while (L->is_linked()) { | 1238 while (L->is_linked()) { |
| 1239 Displacement disp = disp_at(L); | 1239 Displacement disp = disp_at(L); |
| 1240 int fixup_pos = L->pos(); | 1240 int fixup_pos = L->pos(); |
| 1241 if (disp.type() == Displacement::CODE_RELATIVE) { | 1241 if (disp.type() == Displacement::CODE_RELATIVE) { |
| 1242 // Relative to Code* heap object pointer. | 1242 // Relative to Code* heap object pointer. |
| 1243 long_at_put(fixup_pos, pos + Code::kHeaderSize - kHeapObjectTag); | 1243 long_at_put(fixup_pos, pos + Code::kHeaderSize - kHeapObjectTag); |
| 1244 } else { | 1244 } else { |
| 1245 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { | 1245 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { |
| 1246 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected | 1246 DCHECK(byte_at(fixup_pos - 1) == 0xE9); // jmp expected |
| 1247 } | 1247 } |
| 1248 // Relative address, relative to point after address. | 1248 // Relative address, relative to point after address. |
| 1249 int imm32 = pos - (fixup_pos + sizeof(int32_t)); | 1249 int imm32 = pos - (fixup_pos + sizeof(int32_t)); |
| 1250 long_at_put(fixup_pos, imm32); | 1250 long_at_put(fixup_pos, imm32); |
| 1251 } | 1251 } |
| 1252 disp.next(L); | 1252 disp.next(L); |
| 1253 } | 1253 } |
| 1254 while (L->is_near_linked()) { | 1254 while (L->is_near_linked()) { |
| 1255 int fixup_pos = L->near_link_pos(); | 1255 int fixup_pos = L->near_link_pos(); |
| 1256 int offset_to_next = | 1256 int offset_to_next = |
| 1257 static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos))); | 1257 static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos))); |
| 1258 ASSERT(offset_to_next <= 0); | 1258 DCHECK(offset_to_next <= 0); |
| 1259 // Relative address, relative to point after address. | 1259 // Relative address, relative to point after address. |
| 1260 int disp = pos - fixup_pos - sizeof(int8_t); | 1260 int disp = pos - fixup_pos - sizeof(int8_t); |
| 1261 CHECK(0 <= disp && disp <= 127); | 1261 CHECK(0 <= disp && disp <= 127); |
| 1262 set_byte_at(fixup_pos, disp); | 1262 set_byte_at(fixup_pos, disp); |
| 1263 if (offset_to_next < 0) { | 1263 if (offset_to_next < 0) { |
| 1264 L->link_to(fixup_pos + offset_to_next, Label::kNear); | 1264 L->link_to(fixup_pos + offset_to_next, Label::kNear); |
| 1265 } else { | 1265 } else { |
| 1266 L->UnuseNear(); | 1266 L->UnuseNear(); |
| 1267 } | 1267 } |
| 1268 } | 1268 } |
| 1269 L->bind_to(pos); | 1269 L->bind_to(pos); |
| 1270 } | 1270 } |
| 1271 | 1271 |
| 1272 | 1272 |
| 1273 void Assembler::bind(Label* L) { | 1273 void Assembler::bind(Label* L) { |
| 1274 EnsureSpace ensure_space(this); | 1274 EnsureSpace ensure_space(this); |
| 1275 ASSERT(!L->is_bound()); // label can only be bound once | 1275 DCHECK(!L->is_bound()); // label can only be bound once |
| 1276 bind_to(L, pc_offset()); | 1276 bind_to(L, pc_offset()); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 | 1279 |
| 1280 void Assembler::call(Label* L) { | 1280 void Assembler::call(Label* L) { |
| 1281 positions_recorder()->WriteRecordedPositions(); | 1281 positions_recorder()->WriteRecordedPositions(); |
| 1282 EnsureSpace ensure_space(this); | 1282 EnsureSpace ensure_space(this); |
| 1283 if (L->is_bound()) { | 1283 if (L->is_bound()) { |
| 1284 const int long_size = 5; | 1284 const int long_size = 5; |
| 1285 int offs = L->pos() - pc_offset(); | 1285 int offs = L->pos() - pc_offset(); |
| 1286 ASSERT(offs <= 0); | 1286 DCHECK(offs <= 0); |
| 1287 // 1110 1000 #32-bit disp. | 1287 // 1110 1000 #32-bit disp. |
| 1288 EMIT(0xE8); | 1288 EMIT(0xE8); |
| 1289 emit(offs - long_size); | 1289 emit(offs - long_size); |
| 1290 } else { | 1290 } else { |
| 1291 // 1110 1000 #32-bit disp. | 1291 // 1110 1000 #32-bit disp. |
| 1292 EMIT(0xE8); | 1292 EMIT(0xE8); |
| 1293 emit_disp(L, Displacement::OTHER); | 1293 emit_disp(L, Displacement::OTHER); |
| 1294 } | 1294 } |
| 1295 } | 1295 } |
| 1296 | 1296 |
| 1297 | 1297 |
| 1298 void Assembler::call(byte* entry, RelocInfo::Mode rmode) { | 1298 void Assembler::call(byte* entry, RelocInfo::Mode rmode) { |
| 1299 positions_recorder()->WriteRecordedPositions(); | 1299 positions_recorder()->WriteRecordedPositions(); |
| 1300 EnsureSpace ensure_space(this); | 1300 EnsureSpace ensure_space(this); |
| 1301 ASSERT(!RelocInfo::IsCodeTarget(rmode)); | 1301 DCHECK(!RelocInfo::IsCodeTarget(rmode)); |
| 1302 EMIT(0xE8); | 1302 EMIT(0xE8); |
| 1303 if (RelocInfo::IsRuntimeEntry(rmode)) { | 1303 if (RelocInfo::IsRuntimeEntry(rmode)) { |
| 1304 emit(reinterpret_cast<uint32_t>(entry), rmode); | 1304 emit(reinterpret_cast<uint32_t>(entry), rmode); |
| 1305 } else { | 1305 } else { |
| 1306 emit(entry - (pc_ + sizeof(int32_t)), rmode); | 1306 emit(entry - (pc_ + sizeof(int32_t)), rmode); |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 | 1310 |
| 1311 int Assembler::CallSize(const Operand& adr) { | 1311 int Assembler::CallSize(const Operand& adr) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1325 int Assembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode) { | 1325 int Assembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode) { |
| 1326 return 1 /* EMIT */ + sizeof(uint32_t) /* emit */; | 1326 return 1 /* EMIT */ + sizeof(uint32_t) /* emit */; |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 | 1329 |
| 1330 void Assembler::call(Handle<Code> code, | 1330 void Assembler::call(Handle<Code> code, |
| 1331 RelocInfo::Mode rmode, | 1331 RelocInfo::Mode rmode, |
| 1332 TypeFeedbackId ast_id) { | 1332 TypeFeedbackId ast_id) { |
| 1333 positions_recorder()->WriteRecordedPositions(); | 1333 positions_recorder()->WriteRecordedPositions(); |
| 1334 EnsureSpace ensure_space(this); | 1334 EnsureSpace ensure_space(this); |
| 1335 ASSERT(RelocInfo::IsCodeTarget(rmode) | 1335 DCHECK(RelocInfo::IsCodeTarget(rmode) |
| 1336 || rmode == RelocInfo::CODE_AGE_SEQUENCE); | 1336 || rmode == RelocInfo::CODE_AGE_SEQUENCE); |
| 1337 EMIT(0xE8); | 1337 EMIT(0xE8); |
| 1338 emit(code, rmode, ast_id); | 1338 emit(code, rmode, ast_id); |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 | 1341 |
| 1342 void Assembler::jmp(Label* L, Label::Distance distance) { | 1342 void Assembler::jmp(Label* L, Label::Distance distance) { |
| 1343 EnsureSpace ensure_space(this); | 1343 EnsureSpace ensure_space(this); |
| 1344 if (L->is_bound()) { | 1344 if (L->is_bound()) { |
| 1345 const int short_size = 2; | 1345 const int short_size = 2; |
| 1346 const int long_size = 5; | 1346 const int long_size = 5; |
| 1347 int offs = L->pos() - pc_offset(); | 1347 int offs = L->pos() - pc_offset(); |
| 1348 ASSERT(offs <= 0); | 1348 DCHECK(offs <= 0); |
| 1349 if (is_int8(offs - short_size)) { | 1349 if (is_int8(offs - short_size)) { |
| 1350 // 1110 1011 #8-bit disp. | 1350 // 1110 1011 #8-bit disp. |
| 1351 EMIT(0xEB); | 1351 EMIT(0xEB); |
| 1352 EMIT((offs - short_size) & 0xFF); | 1352 EMIT((offs - short_size) & 0xFF); |
| 1353 } else { | 1353 } else { |
| 1354 // 1110 1001 #32-bit disp. | 1354 // 1110 1001 #32-bit disp. |
| 1355 EMIT(0xE9); | 1355 EMIT(0xE9); |
| 1356 emit(offs - long_size); | 1356 emit(offs - long_size); |
| 1357 } | 1357 } |
| 1358 } else if (distance == Label::kNear) { | 1358 } else if (distance == Label::kNear) { |
| 1359 EMIT(0xEB); | 1359 EMIT(0xEB); |
| 1360 emit_near_disp(L); | 1360 emit_near_disp(L); |
| 1361 } else { | 1361 } else { |
| 1362 // 1110 1001 #32-bit disp. | 1362 // 1110 1001 #32-bit disp. |
| 1363 EMIT(0xE9); | 1363 EMIT(0xE9); |
| 1364 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); | 1364 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); |
| 1365 } | 1365 } |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 | 1368 |
| 1369 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { | 1369 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { |
| 1370 EnsureSpace ensure_space(this); | 1370 EnsureSpace ensure_space(this); |
| 1371 ASSERT(!RelocInfo::IsCodeTarget(rmode)); | 1371 DCHECK(!RelocInfo::IsCodeTarget(rmode)); |
| 1372 EMIT(0xE9); | 1372 EMIT(0xE9); |
| 1373 if (RelocInfo::IsRuntimeEntry(rmode)) { | 1373 if (RelocInfo::IsRuntimeEntry(rmode)) { |
| 1374 emit(reinterpret_cast<uint32_t>(entry), rmode); | 1374 emit(reinterpret_cast<uint32_t>(entry), rmode); |
| 1375 } else { | 1375 } else { |
| 1376 emit(entry - (pc_ + sizeof(int32_t)), rmode); | 1376 emit(entry - (pc_ + sizeof(int32_t)), rmode); |
| 1377 } | 1377 } |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 | 1380 |
| 1381 void Assembler::jmp(const Operand& adr) { | 1381 void Assembler::jmp(const Operand& adr) { |
| 1382 EnsureSpace ensure_space(this); | 1382 EnsureSpace ensure_space(this); |
| 1383 EMIT(0xFF); | 1383 EMIT(0xFF); |
| 1384 emit_operand(esp, adr); | 1384 emit_operand(esp, adr); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 | 1387 |
| 1388 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { | 1388 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { |
| 1389 EnsureSpace ensure_space(this); | 1389 EnsureSpace ensure_space(this); |
| 1390 ASSERT(RelocInfo::IsCodeTarget(rmode)); | 1390 DCHECK(RelocInfo::IsCodeTarget(rmode)); |
| 1391 EMIT(0xE9); | 1391 EMIT(0xE9); |
| 1392 emit(code, rmode); | 1392 emit(code, rmode); |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 | 1395 |
| 1396 void Assembler::j(Condition cc, Label* L, Label::Distance distance) { | 1396 void Assembler::j(Condition cc, Label* L, Label::Distance distance) { |
| 1397 EnsureSpace ensure_space(this); | 1397 EnsureSpace ensure_space(this); |
| 1398 ASSERT(0 <= cc && static_cast<int>(cc) < 16); | 1398 DCHECK(0 <= cc && static_cast<int>(cc) < 16); |
| 1399 if (L->is_bound()) { | 1399 if (L->is_bound()) { |
| 1400 const int short_size = 2; | 1400 const int short_size = 2; |
| 1401 const int long_size = 6; | 1401 const int long_size = 6; |
| 1402 int offs = L->pos() - pc_offset(); | 1402 int offs = L->pos() - pc_offset(); |
| 1403 ASSERT(offs <= 0); | 1403 DCHECK(offs <= 0); |
| 1404 if (is_int8(offs - short_size)) { | 1404 if (is_int8(offs - short_size)) { |
| 1405 // 0111 tttn #8-bit disp | 1405 // 0111 tttn #8-bit disp |
| 1406 EMIT(0x70 | cc); | 1406 EMIT(0x70 | cc); |
| 1407 EMIT((offs - short_size) & 0xFF); | 1407 EMIT((offs - short_size) & 0xFF); |
| 1408 } else { | 1408 } else { |
| 1409 // 0000 1111 1000 tttn #32-bit disp | 1409 // 0000 1111 1000 tttn #32-bit disp |
| 1410 EMIT(0x0F); | 1410 EMIT(0x0F); |
| 1411 EMIT(0x80 | cc); | 1411 EMIT(0x80 | cc); |
| 1412 emit(offs - long_size); | 1412 emit(offs - long_size); |
| 1413 } | 1413 } |
| 1414 } else if (distance == Label::kNear) { | 1414 } else if (distance == Label::kNear) { |
| 1415 EMIT(0x70 | cc); | 1415 EMIT(0x70 | cc); |
| 1416 emit_near_disp(L); | 1416 emit_near_disp(L); |
| 1417 } else { | 1417 } else { |
| 1418 // 0000 1111 1000 tttn #32-bit disp | 1418 // 0000 1111 1000 tttn #32-bit disp |
| 1419 // Note: could eliminate cond. jumps to this jump if condition | 1419 // Note: could eliminate cond. jumps to this jump if condition |
| 1420 // is the same however, seems to be rather unlikely case. | 1420 // is the same however, seems to be rather unlikely case. |
| 1421 EMIT(0x0F); | 1421 EMIT(0x0F); |
| 1422 EMIT(0x80 | cc); | 1422 EMIT(0x80 | cc); |
| 1423 emit_disp(L, Displacement::OTHER); | 1423 emit_disp(L, Displacement::OTHER); |
| 1424 } | 1424 } |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 | 1427 |
| 1428 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode) { | 1428 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode) { |
| 1429 EnsureSpace ensure_space(this); | 1429 EnsureSpace ensure_space(this); |
| 1430 ASSERT((0 <= cc) && (static_cast<int>(cc) < 16)); | 1430 DCHECK((0 <= cc) && (static_cast<int>(cc) < 16)); |
| 1431 // 0000 1111 1000 tttn #32-bit disp. | 1431 // 0000 1111 1000 tttn #32-bit disp. |
| 1432 EMIT(0x0F); | 1432 EMIT(0x0F); |
| 1433 EMIT(0x80 | cc); | 1433 EMIT(0x80 | cc); |
| 1434 if (RelocInfo::IsRuntimeEntry(rmode)) { | 1434 if (RelocInfo::IsRuntimeEntry(rmode)) { |
| 1435 emit(reinterpret_cast<uint32_t>(entry), rmode); | 1435 emit(reinterpret_cast<uint32_t>(entry), rmode); |
| 1436 } else { | 1436 } else { |
| 1437 emit(entry - (pc_ + sizeof(int32_t)), rmode); | 1437 emit(entry - (pc_ + sizeof(int32_t)), rmode); |
| 1438 } | 1438 } |
| 1439 } | 1439 } |
| 1440 | 1440 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 | 1547 |
| 1548 | 1548 |
| 1549 void Assembler::fistp_s(const Operand& adr) { | 1549 void Assembler::fistp_s(const Operand& adr) { |
| 1550 EnsureSpace ensure_space(this); | 1550 EnsureSpace ensure_space(this); |
| 1551 EMIT(0xDB); | 1551 EMIT(0xDB); |
| 1552 emit_operand(ebx, adr); | 1552 emit_operand(ebx, adr); |
| 1553 } | 1553 } |
| 1554 | 1554 |
| 1555 | 1555 |
| 1556 void Assembler::fisttp_s(const Operand& adr) { | 1556 void Assembler::fisttp_s(const Operand& adr) { |
| 1557 ASSERT(IsEnabled(SSE3)); | 1557 DCHECK(IsEnabled(SSE3)); |
| 1558 EnsureSpace ensure_space(this); | 1558 EnsureSpace ensure_space(this); |
| 1559 EMIT(0xDB); | 1559 EMIT(0xDB); |
| 1560 emit_operand(ecx, adr); | 1560 emit_operand(ecx, adr); |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 | 1563 |
| 1564 void Assembler::fisttp_d(const Operand& adr) { | 1564 void Assembler::fisttp_d(const Operand& adr) { |
| 1565 ASSERT(IsEnabled(SSE3)); | 1565 DCHECK(IsEnabled(SSE3)); |
| 1566 EnsureSpace ensure_space(this); | 1566 EnsureSpace ensure_space(this); |
| 1567 EMIT(0xDD); | 1567 EMIT(0xDD); |
| 1568 emit_operand(ecx, adr); | 1568 emit_operand(ecx, adr); |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 | 1571 |
| 1572 void Assembler::fist_s(const Operand& adr) { | 1572 void Assembler::fist_s(const Operand& adr) { |
| 1573 EnsureSpace ensure_space(this); | 1573 EnsureSpace ensure_space(this); |
| 1574 EMIT(0xDB); | 1574 EMIT(0xDB); |
| 1575 emit_operand(edx, adr); | 1575 emit_operand(edx, adr); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 } | 1832 } |
| 1833 | 1833 |
| 1834 | 1834 |
| 1835 void Assembler::sahf() { | 1835 void Assembler::sahf() { |
| 1836 EnsureSpace ensure_space(this); | 1836 EnsureSpace ensure_space(this); |
| 1837 EMIT(0x9E); | 1837 EMIT(0x9E); |
| 1838 } | 1838 } |
| 1839 | 1839 |
| 1840 | 1840 |
| 1841 void Assembler::setcc(Condition cc, Register reg) { | 1841 void Assembler::setcc(Condition cc, Register reg) { |
| 1842 ASSERT(reg.is_byte_register()); | 1842 DCHECK(reg.is_byte_register()); |
| 1843 EnsureSpace ensure_space(this); | 1843 EnsureSpace ensure_space(this); |
| 1844 EMIT(0x0F); | 1844 EMIT(0x0F); |
| 1845 EMIT(0x90 | cc); | 1845 EMIT(0x90 | cc); |
| 1846 EMIT(0xC0 | reg.code()); | 1846 EMIT(0xC0 | reg.code()); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 | 1849 |
| 1850 void Assembler::Print() { | 1850 void Assembler::Print() { |
| 1851 Disassembler::Decode(isolate(), stdout, buffer_, pc_); | 1851 Disassembler::Decode(isolate(), stdout, buffer_, pc_); |
| 1852 } | 1852 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1868 | 1868 |
| 1869 void Assembler::RecordComment(const char* msg, bool force) { | 1869 void Assembler::RecordComment(const char* msg, bool force) { |
| 1870 if (FLAG_code_comments || force) { | 1870 if (FLAG_code_comments || force) { |
| 1871 EnsureSpace ensure_space(this); | 1871 EnsureSpace ensure_space(this); |
| 1872 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 1872 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |
| 1873 } | 1873 } |
| 1874 } | 1874 } |
| 1875 | 1875 |
| 1876 | 1876 |
| 1877 void Assembler::GrowBuffer() { | 1877 void Assembler::GrowBuffer() { |
| 1878 ASSERT(buffer_overflow()); | 1878 DCHECK(buffer_overflow()); |
| 1879 if (!own_buffer_) FATAL("external code buffer is too small"); | 1879 if (!own_buffer_) FATAL("external code buffer is too small"); |
| 1880 | 1880 |
| 1881 // Compute new buffer size. | 1881 // Compute new buffer size. |
| 1882 CodeDesc desc; // the new buffer | 1882 CodeDesc desc; // the new buffer |
| 1883 if (buffer_size_ < 4*KB) { | 1883 if (buffer_size_ < 4*KB) { |
| 1884 desc.buffer_size = 4*KB; | 1884 desc.buffer_size = 4*KB; |
| 1885 } else { | 1885 } else { |
| 1886 desc.buffer_size = 2*buffer_size_; | 1886 desc.buffer_size = 2*buffer_size_; |
| 1887 } | 1887 } |
| 1888 // Some internal data structures overflow for very large buffers, | 1888 // Some internal data structures overflow for very large buffers, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 for (RelocIterator it(desc); !it.done(); it.next()) { | 1927 for (RelocIterator it(desc); !it.done(); it.next()) { |
| 1928 RelocInfo::Mode rmode = it.rinfo()->rmode(); | 1928 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
| 1929 if (rmode == RelocInfo::INTERNAL_REFERENCE) { | 1929 if (rmode == RelocInfo::INTERNAL_REFERENCE) { |
| 1930 int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc()); | 1930 int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc()); |
| 1931 if (*p != 0) { // 0 means uninitialized. | 1931 if (*p != 0) { // 0 means uninitialized. |
| 1932 *p += pc_delta; | 1932 *p += pc_delta; |
| 1933 } | 1933 } |
| 1934 } | 1934 } |
| 1935 } | 1935 } |
| 1936 | 1936 |
| 1937 ASSERT(!buffer_overflow()); | 1937 DCHECK(!buffer_overflow()); |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 | 1940 |
| 1941 void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) { | 1941 void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) { |
| 1942 ASSERT(is_uint8(op1) && is_uint8(op2)); // wrong opcode | 1942 DCHECK(is_uint8(op1) && is_uint8(op2)); // wrong opcode |
| 1943 ASSERT(is_uint8(imm8)); | 1943 DCHECK(is_uint8(imm8)); |
| 1944 ASSERT((op1 & 0x01) == 0); // should be 8bit operation | 1944 DCHECK((op1 & 0x01) == 0); // should be 8bit operation |
| 1945 EMIT(op1); | 1945 EMIT(op1); |
| 1946 EMIT(op2 | dst.code()); | 1946 EMIT(op2 | dst.code()); |
| 1947 EMIT(imm8); | 1947 EMIT(imm8); |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 | 1950 |
| 1951 void Assembler::emit_arith(int sel, Operand dst, const Immediate& x) { | 1951 void Assembler::emit_arith(int sel, Operand dst, const Immediate& x) { |
| 1952 ASSERT((0 <= sel) && (sel <= 7)); | 1952 DCHECK((0 <= sel) && (sel <= 7)); |
| 1953 Register ireg = { sel }; | 1953 Register ireg = { sel }; |
| 1954 if (x.is_int8()) { | 1954 if (x.is_int8()) { |
| 1955 EMIT(0x83); // using a sign-extended 8-bit immediate. | 1955 EMIT(0x83); // using a sign-extended 8-bit immediate. |
| 1956 emit_operand(ireg, dst); | 1956 emit_operand(ireg, dst); |
| 1957 EMIT(x.x_ & 0xFF); | 1957 EMIT(x.x_ & 0xFF); |
| 1958 } else if (dst.is_reg(eax)) { | 1958 } else if (dst.is_reg(eax)) { |
| 1959 EMIT((sel << 3) | 0x05); // short form if the destination is eax. | 1959 EMIT((sel << 3) | 0x05); // short form if the destination is eax. |
| 1960 emit(x); | 1960 emit(x); |
| 1961 } else { | 1961 } else { |
| 1962 EMIT(0x81); // using a literal 32-bit immediate. | 1962 EMIT(0x81); // using a literal 32-bit immediate. |
| 1963 emit_operand(ireg, dst); | 1963 emit_operand(ireg, dst); |
| 1964 emit(x); | 1964 emit(x); |
| 1965 } | 1965 } |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 | 1968 |
| 1969 void Assembler::emit_operand(Register reg, const Operand& adr) { | 1969 void Assembler::emit_operand(Register reg, const Operand& adr) { |
| 1970 const unsigned length = adr.len_; | 1970 const unsigned length = adr.len_; |
| 1971 ASSERT(length > 0); | 1971 DCHECK(length > 0); |
| 1972 | 1972 |
| 1973 // Emit updated ModRM byte containing the given register. | 1973 // Emit updated ModRM byte containing the given register. |
| 1974 pc_[0] = (adr.buf_[0] & ~0x38) | (reg.code() << 3); | 1974 pc_[0] = (adr.buf_[0] & ~0x38) | (reg.code() << 3); |
| 1975 | 1975 |
| 1976 // Emit the rest of the encoded operand. | 1976 // Emit the rest of the encoded operand. |
| 1977 for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i]; | 1977 for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i]; |
| 1978 pc_ += length; | 1978 pc_ += length; |
| 1979 | 1979 |
| 1980 // Emit relocation information if necessary. | 1980 // Emit relocation information if necessary. |
| 1981 if (length >= sizeof(int32_t) && !RelocInfo::IsNone(adr.rmode_)) { | 1981 if (length >= sizeof(int32_t) && !RelocInfo::IsNone(adr.rmode_)) { |
| 1982 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32 | 1982 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32 |
| 1983 RecordRelocInfo(adr.rmode_); | 1983 RecordRelocInfo(adr.rmode_); |
| 1984 pc_ += sizeof(int32_t); | 1984 pc_ += sizeof(int32_t); |
| 1985 } | 1985 } |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 | 1988 |
| 1989 void Assembler::emit_farith(int b1, int b2, int i) { | 1989 void Assembler::emit_farith(int b1, int b2, int i) { |
| 1990 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode | 1990 DCHECK(is_uint8(b1) && is_uint8(b2)); // wrong opcode |
| 1991 ASSERT(0 <= i && i < 8); // illegal stack offset | 1991 DCHECK(0 <= i && i < 8); // illegal stack offset |
| 1992 EMIT(b1); | 1992 EMIT(b1); |
| 1993 EMIT(b2 + i); | 1993 EMIT(b2 + i); |
| 1994 } | 1994 } |
| 1995 | 1995 |
| 1996 | 1996 |
| 1997 void Assembler::db(uint8_t data) { | 1997 void Assembler::db(uint8_t data) { |
| 1998 EnsureSpace ensure_space(this); | 1998 EnsureSpace ensure_space(this); |
| 1999 EMIT(data); | 1999 EMIT(data); |
| 2000 } | 2000 } |
| 2001 | 2001 |
| 2002 | 2002 |
| 2003 void Assembler::dd(uint32_t data) { | 2003 void Assembler::dd(uint32_t data) { |
| 2004 EnsureSpace ensure_space(this); | 2004 EnsureSpace ensure_space(this); |
| 2005 emit(data); | 2005 emit(data); |
| 2006 } | 2006 } |
| 2007 | 2007 |
| 2008 | 2008 |
| 2009 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { | 2009 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { |
| 2010 ASSERT(!RelocInfo::IsNone(rmode)); | 2010 DCHECK(!RelocInfo::IsNone(rmode)); |
| 2011 // Don't record external references unless the heap will be serialized. | 2011 // Don't record external references unless the heap will be serialized. |
| 2012 if (rmode == RelocInfo::EXTERNAL_REFERENCE && | 2012 if (rmode == RelocInfo::EXTERNAL_REFERENCE && |
| 2013 !serializer_enabled() && !emit_debug_code()) { | 2013 !serializer_enabled() && !emit_debug_code()) { |
| 2014 return; | 2014 return; |
| 2015 } | 2015 } |
| 2016 RelocInfo rinfo(pc_, rmode, data, NULL); | 2016 RelocInfo rinfo(pc_, rmode, data, NULL); |
| 2017 reloc_info_writer.Write(&rinfo); | 2017 reloc_info_writer.Write(&rinfo); |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 | 2020 |
| 2021 Handle<ConstantPoolArray> Assembler::NewConstantPool(Isolate* isolate) { | 2021 Handle<ConstantPoolArray> Assembler::NewConstantPool(Isolate* isolate) { |
| 2022 // No out-of-line constant pool support. | 2022 // No out-of-line constant pool support. |
| 2023 ASSERT(!FLAG_enable_ool_constant_pool); | 2023 DCHECK(!FLAG_enable_ool_constant_pool); |
| 2024 return isolate->factory()->empty_constant_pool_array(); | 2024 return isolate->factory()->empty_constant_pool_array(); |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 | 2027 |
| 2028 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) { | 2028 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) { |
| 2029 // No out-of-line constant pool support. | 2029 // No out-of-line constant pool support. |
| 2030 ASSERT(!FLAG_enable_ool_constant_pool); | 2030 DCHECK(!FLAG_enable_ool_constant_pool); |
| 2031 return; | 2031 return; |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 | 2034 |
| 2035 #ifdef GENERATED_CODE_COVERAGE | 2035 #ifdef GENERATED_CODE_COVERAGE |
| 2036 static FILE* coverage_log = NULL; | 2036 static FILE* coverage_log = NULL; |
| 2037 | 2037 |
| 2038 | 2038 |
| 2039 static void InitCoverageLog() { | 2039 static void InitCoverageLog() { |
| 2040 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG"); | 2040 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2053 fprintf(coverage_log, "%s\n", file_line); | 2053 fprintf(coverage_log, "%s\n", file_line); |
| 2054 fflush(coverage_log); | 2054 fflush(coverage_log); |
| 2055 } | 2055 } |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 #endif | 2058 #endif |
| 2059 | 2059 |
| 2060 } } // namespace v8::internal | 2060 } } // namespace v8::internal |
| 2061 | 2061 |
| 2062 #endif // V8_TARGET_ARCH_X87 | 2062 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |