| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 desc->reloc_size = | 369 desc->reloc_size = |
| 370 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); | 370 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); |
| 371 desc->origin = this; | 371 desc->origin = this; |
| 372 | 372 |
| 373 Counters::reloc_info_size.Increment(desc->reloc_size); | 373 Counters::reloc_info_size.Increment(desc->reloc_size); |
| 374 } | 374 } |
| 375 | 375 |
| 376 | 376 |
| 377 void Assembler::Align(int m) { | 377 void Assembler::Align(int m) { |
| 378 ASSERT(IsPowerOf2(m)); | 378 ASSERT(IsPowerOf2(m)); |
| 379 while ((pc_offset() & (m - 1)) != 0) { | 379 int delta = (m - (pc_offset() & (m - 1))) & (m - 1); |
| 380 nop(); | 380 while (delta >= 9) { |
| 381 nop(9); |
| 382 delta -= 9; |
| 383 } |
| 384 if (delta > 0) { |
| 385 nop(delta); |
| 381 } | 386 } |
| 382 } | 387 } |
| 383 | 388 |
| 384 | 389 |
| 385 void Assembler::CodeTargetAlign() { | 390 void Assembler::CodeTargetAlign() { |
| 386 Align(16); // Preferred alignment of jump targets on x64. | 391 Align(16); // Preferred alignment of jump targets on x64. |
| 387 } | 392 } |
| 388 | 393 |
| 389 | 394 |
| 390 void Assembler::bind_to(Label* L, int pos) { | 395 void Assembler::bind_to(Label* L, int pos) { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // 1110 1000 #32-bit disp. | 835 // 1110 1000 #32-bit disp. |
| 831 emit(0xE8); | 836 emit(0xE8); |
| 832 emit_code_target(target, rmode); | 837 emit_code_target(target, rmode); |
| 833 } | 838 } |
| 834 | 839 |
| 835 | 840 |
| 836 void Assembler::call(Register adr) { | 841 void Assembler::call(Register adr) { |
| 837 EnsureSpace ensure_space(this); | 842 EnsureSpace ensure_space(this); |
| 838 last_pc_ = pc_; | 843 last_pc_ = pc_; |
| 839 // Opcode: FF /2 r64. | 844 // Opcode: FF /2 r64. |
| 840 if (adr.high_bit()) { | 845 emit_optional_rex_32(adr); |
| 841 emit_rex_64(adr); | |
| 842 } | |
| 843 emit(0xFF); | 846 emit(0xFF); |
| 844 emit_modrm(0x2, adr); | 847 emit_modrm(0x2, adr); |
| 845 } | 848 } |
| 846 | 849 |
| 847 | 850 |
| 848 void Assembler::call(const Operand& op) { | 851 void Assembler::call(const Operand& op) { |
| 849 EnsureSpace ensure_space(this); | 852 EnsureSpace ensure_space(this); |
| 850 last_pc_ = pc_; | 853 last_pc_ = pc_; |
| 851 // Opcode: FF /2 m64. | 854 // Opcode: FF /2 m64. |
| 852 emit_rex_64(op); | 855 emit_optional_rex_32(op); |
| 853 emit(0xFF); | 856 emit(0xFF); |
| 854 emit_operand(2, op); | 857 emit_operand(0x2, op); |
| 855 } | 858 } |
| 856 | 859 |
| 857 | 860 |
| 858 void Assembler::clc() { | 861 void Assembler::clc() { |
| 859 EnsureSpace ensure_space(this); | 862 EnsureSpace ensure_space(this); |
| 860 last_pc_ = pc_; | 863 last_pc_ = pc_; |
| 861 emit(0xF8); | 864 emit(0xF8); |
| 862 } | 865 } |
| 863 | 866 |
| 864 void Assembler::cdq() { | 867 void Assembler::cdq() { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 // 1110 1001 #32-bit disp. | 1266 // 1110 1001 #32-bit disp. |
| 1264 emit(0xE9); | 1267 emit(0xE9); |
| 1265 emit_code_target(target, rmode); | 1268 emit_code_target(target, rmode); |
| 1266 } | 1269 } |
| 1267 | 1270 |
| 1268 | 1271 |
| 1269 void Assembler::jmp(Register target) { | 1272 void Assembler::jmp(Register target) { |
| 1270 EnsureSpace ensure_space(this); | 1273 EnsureSpace ensure_space(this); |
| 1271 last_pc_ = pc_; | 1274 last_pc_ = pc_; |
| 1272 // Opcode FF/4 r64. | 1275 // Opcode FF/4 r64. |
| 1273 if (target.high_bit()) { | 1276 emit_optional_rex_32(target); |
| 1274 emit_rex_64(target); | |
| 1275 } | |
| 1276 emit(0xFF); | 1277 emit(0xFF); |
| 1277 emit_modrm(0x4, target); | 1278 emit_modrm(0x4, target); |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 | 1281 |
| 1281 void Assembler::jmp(const Operand& src) { | 1282 void Assembler::jmp(const Operand& src) { |
| 1282 EnsureSpace ensure_space(this); | 1283 EnsureSpace ensure_space(this); |
| 1283 last_pc_ = pc_; | 1284 last_pc_ = pc_; |
| 1284 // Opcode FF/4 m64. | 1285 // Opcode FF/4 m64. |
| 1285 emit_optional_rex_32(src); | 1286 emit_optional_rex_32(src); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 emit(0x00); | 1825 emit(0x00); |
| 1825 emit(0x00); | 1826 emit(0x00); |
| 1826 return; | 1827 return; |
| 1827 } | 1828 } |
| 1828 } | 1829 } |
| 1829 | 1830 |
| 1830 | 1831 |
| 1831 void Assembler::pop(Register dst) { | 1832 void Assembler::pop(Register dst) { |
| 1832 EnsureSpace ensure_space(this); | 1833 EnsureSpace ensure_space(this); |
| 1833 last_pc_ = pc_; | 1834 last_pc_ = pc_; |
| 1834 if (dst.high_bit()) { | 1835 emit_optional_rex_32(dst); |
| 1835 emit_rex_64(dst); | |
| 1836 } | |
| 1837 emit(0x58 | dst.low_bits()); | 1836 emit(0x58 | dst.low_bits()); |
| 1838 } | 1837 } |
| 1839 | 1838 |
| 1840 | 1839 |
| 1841 void Assembler::pop(const Operand& dst) { | 1840 void Assembler::pop(const Operand& dst) { |
| 1842 EnsureSpace ensure_space(this); | 1841 EnsureSpace ensure_space(this); |
| 1843 last_pc_ = pc_; | 1842 last_pc_ = pc_; |
| 1844 emit_rex_64(dst); // Could be omitted in some cases. | 1843 emit_optional_rex_32(dst); |
| 1845 emit(0x8F); | 1844 emit(0x8F); |
| 1846 emit_operand(0, dst); | 1845 emit_operand(0, dst); |
| 1847 } | 1846 } |
| 1848 | 1847 |
| 1849 | 1848 |
| 1850 void Assembler::popfq() { | 1849 void Assembler::popfq() { |
| 1851 EnsureSpace ensure_space(this); | 1850 EnsureSpace ensure_space(this); |
| 1852 last_pc_ = pc_; | 1851 last_pc_ = pc_; |
| 1853 emit(0x9D); | 1852 emit(0x9D); |
| 1854 } | 1853 } |
| 1855 | 1854 |
| 1856 | 1855 |
| 1857 void Assembler::push(Register src) { | 1856 void Assembler::push(Register src) { |
| 1858 EnsureSpace ensure_space(this); | 1857 EnsureSpace ensure_space(this); |
| 1859 last_pc_ = pc_; | 1858 last_pc_ = pc_; |
| 1860 if (src.high_bit()) { | 1859 emit_optional_rex_32(src); |
| 1861 emit_rex_64(src); | |
| 1862 } | |
| 1863 emit(0x50 | src.low_bits()); | 1860 emit(0x50 | src.low_bits()); |
| 1864 } | 1861 } |
| 1865 | 1862 |
| 1866 | 1863 |
| 1867 void Assembler::push(const Operand& src) { | 1864 void Assembler::push(const Operand& src) { |
| 1868 EnsureSpace ensure_space(this); | 1865 EnsureSpace ensure_space(this); |
| 1869 last_pc_ = pc_; | 1866 last_pc_ = pc_; |
| 1870 emit_rex_64(src); // Could be omitted in some cases. | 1867 emit_optional_rex_32(src); |
| 1871 emit(0xFF); | 1868 emit(0xFF); |
| 1872 emit_operand(6, src); | 1869 emit_operand(6, src); |
| 1873 } | 1870 } |
| 1874 | 1871 |
| 1875 | 1872 |
| 1876 void Assembler::push(Immediate value) { | 1873 void Assembler::push(Immediate value) { |
| 1877 EnsureSpace ensure_space(this); | 1874 EnsureSpace ensure_space(this); |
| 1878 last_pc_ = pc_; | 1875 last_pc_ = pc_; |
| 1879 if (is_int8(value.value_)) { | 1876 if (is_int8(value.value_)) { |
| 1880 emit(0x6A); | 1877 emit(0x6A); |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2869 // specially coded on x64 means that it is a relative 32 bit address, as used | 2866 // specially coded on x64 means that it is a relative 32 bit address, as used |
| 2870 // by branch instructions. | 2867 // by branch instructions. |
| 2871 return (1 << rmode_) & kApplyMask; | 2868 return (1 << rmode_) & kApplyMask; |
| 2872 } | 2869 } |
| 2873 | 2870 |
| 2874 | 2871 |
| 2875 | 2872 |
| 2876 } } // namespace v8::internal | 2873 } } // namespace v8::internal |
| 2877 | 2874 |
| 2878 #endif // V8_TARGET_ARCH_X64 | 2875 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |