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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 XMMRegister xmm7 = { 7 }; | 65 XMMRegister xmm7 = { 7 }; |
66 XMMRegister xmm8 = { 8 }; | 66 XMMRegister xmm8 = { 8 }; |
67 XMMRegister xmm9 = { 9 }; | 67 XMMRegister xmm9 = { 9 }; |
68 XMMRegister xmm10 = { 10 }; | 68 XMMRegister xmm10 = { 10 }; |
69 XMMRegister xmm11 = { 11 }; | 69 XMMRegister xmm11 = { 11 }; |
70 XMMRegister xmm12 = { 12 }; | 70 XMMRegister xmm12 = { 12 }; |
71 XMMRegister xmm13 = { 13 }; | 71 XMMRegister xmm13 = { 13 }; |
72 XMMRegister xmm14 = { 14 }; | 72 XMMRegister xmm14 = { 14 }; |
73 XMMRegister xmm15 = { 15 }; | 73 XMMRegister xmm15 = { 15 }; |
74 | 74 |
75 | |
76 Operand::Operand(Register base, int32_t disp) { | |
77 len_ = 1; | |
78 if (base.is(rsp) || base.is(r12)) { | |
79 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). | |
80 set_sib(kTimes1, rsp, base); | |
81 } | |
82 | |
83 if (disp == 0 && !base.is(rbp) && !base.is(r13)) { | |
84 set_modrm(0, rsp); | |
85 } else if (is_int8(disp)) { | |
86 set_modrm(1, base); | |
87 set_disp8(disp); | |
88 } else { | |
89 set_modrm(2, base); | |
90 set_disp32(disp); | |
91 } | |
92 } | |
93 | |
94 | |
95 Operand::Operand(Register base, | |
96 Register index, | |
97 ScaleFactor scale, | |
98 int32_t disp) { | |
99 ASSERT(!index.is(rsp) && !index.is(r12)); | |
100 len_ = 1; | |
101 set_sib(scale, index, base); | |
102 if (disp == 0 && !base.is(rbp) && !base.is(r13)) { | |
103 // The call to set_modrm doesn't overwrite the REX.B bit possibly set | |
104 // by set_sib. | |
105 set_modrm(0, rsp); | |
106 } else if (is_int8(disp)) { | |
107 set_modrm(1, rsp); | |
108 set_disp8(disp); | |
109 } else { | |
110 set_modrm(2, rsp); | |
111 set_disp32(disp); | |
112 } | |
113 } | |
114 | |
115 | |
75 // Safe default is no features. | 116 // Safe default is no features. |
117 // TODO(X64): Safe defaults include SSE2 for X64. | |
76 uint64_t CpuFeatures::supported_ = 0; | 118 uint64_t CpuFeatures::supported_ = 0; |
77 uint64_t CpuFeatures::enabled_ = 0; | 119 uint64_t CpuFeatures::enabled_ = 0; |
78 | 120 |
79 void CpuFeatures::Probe() { | 121 void CpuFeatures::Probe() { |
80 ASSERT(Heap::HasBeenSetup()); | 122 ASSERT(Heap::HasBeenSetup()); |
81 ASSERT(supported_ == 0); | 123 ASSERT(supported_ == 0); |
82 if (Serializer::enabled()) return; // No features if we might serialize. | 124 if (Serializer::enabled()) return; // No features if we might serialize. |
83 | 125 |
84 Assembler assm(NULL, 0); | 126 Assembler assm(NULL, 0); |
85 Label cpuid, done; | 127 Label cpuid, done; |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 EnsureSpace ensure_space(this); | 521 EnsureSpace ensure_space(this); |
480 last_pc_ = pc_; | 522 last_pc_ = pc_; |
481 // Opcode: FF /2 r64 | 523 // Opcode: FF /2 r64 |
482 if (adr.code() > 7) { | 524 if (adr.code() > 7) { |
483 emit_rex_64(adr); | 525 emit_rex_64(adr); |
484 } | 526 } |
485 emit(0xFF); | 527 emit(0xFF); |
486 emit_modrm(0x2, adr); | 528 emit_modrm(0x2, adr); |
487 } | 529 } |
488 | 530 |
531 | |
489 void Assembler::cpuid() { | 532 void Assembler::cpuid() { |
490 ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID)); | 533 ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID)); |
491 EnsureSpace ensure_space(this); | 534 EnsureSpace ensure_space(this); |
492 last_pc_ = pc_; | 535 last_pc_ = pc_; |
493 emit(0x0F); | 536 emit(0x0F); |
494 emit(0xA2); | 537 emit(0xA2); |
495 } | 538 } |
496 | 539 |
497 | 540 |
498 void Assembler::call(const Operand& op) { | 541 void Assembler::call(const Operand& op) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 void Assembler::movq(Register dst, ExternalReference ref) { | 879 void Assembler::movq(Register dst, ExternalReference ref) { |
837 EnsureSpace ensure_space(this); | 880 EnsureSpace ensure_space(this); |
838 last_pc_ = pc_; | 881 last_pc_ = pc_; |
839 emit_rex_64(dst); | 882 emit_rex_64(dst); |
840 emit(0xB8 | (dst.code() & 0x7)); | 883 emit(0xB8 | (dst.code() & 0x7)); |
841 emitq(reinterpret_cast<uintptr_t>(ref.address()), | 884 emitq(reinterpret_cast<uintptr_t>(ref.address()), |
842 RelocInfo::EXTERNAL_REFERENCE); | 885 RelocInfo::EXTERNAL_REFERENCE); |
843 } | 886 } |
844 | 887 |
845 | 888 |
889 void Assembler::movq(const Operand& dst, Immediate value) { | |
890 EnsureSpace ensure_space(this); | |
891 last_pc_ = pc_; | |
892 emit_rex_64(dst); | |
893 emit(0xC7); | |
894 emit_operand(0, dst); | |
895 emit(value); | |
896 } | |
897 | |
898 | |
899 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { | |
900 EnsureSpace ensure_space(this); | |
901 last_pc_ = pc_; | |
902 ASSERT(!Heap::InNewSpace(*value)); | |
William Hesse
2009/06/10 08:09:09
Is this from the ia32 code? I didn't know this.
| |
903 emit_rex_64(dst); | |
904 emit(0xB8 | dst.code() & 0x7); | |
905 if (value->IsHeapObject()) { | |
906 emitq(reinterpret_cast<uintptr_t>(value.location()), mode); | |
907 } else { | |
908 ASSERT_EQ(RelocInfo::NONE, mode); | |
909 emitq(reinterpret_cast<uintptr_t>(*value), RelocInfo::NONE); | |
910 } | |
911 } | |
912 | |
913 | |
846 void Assembler::mul(Register src) { | 914 void Assembler::mul(Register src) { |
847 EnsureSpace ensure_space(this); | 915 EnsureSpace ensure_space(this); |
848 last_pc_ = pc_; | 916 last_pc_ = pc_; |
849 emit_rex_64(src); | 917 emit_rex_64(src); |
850 emit(0xF7); | 918 emit(0xF7); |
851 emit_modrm(0x4, src); | 919 emit_modrm(0x4, src); |
852 } | 920 } |
853 | 921 |
854 | 922 |
855 void Assembler::neg(Register dst) { | 923 void Assembler::neg(Register dst) { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1121 emitq(reinterpret_cast<uintptr_t>(dst), mode); | 1189 emitq(reinterpret_cast<uintptr_t>(dst), mode); |
1122 } | 1190 } |
1123 | 1191 |
1124 | 1192 |
1125 void Assembler::store_rax(ExternalReference ref) { | 1193 void Assembler::store_rax(ExternalReference ref) { |
1126 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); | 1194 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); |
1127 } | 1195 } |
1128 | 1196 |
1129 | 1197 |
1130 void Assembler::testb(Register reg, Immediate mask) { | 1198 void Assembler::testb(Register reg, Immediate mask) { |
1199 ASSERT(is_int8(mask.value_)); | |
1131 EnsureSpace ensure_space(this); | 1200 EnsureSpace ensure_space(this); |
1132 last_pc_ = pc_; | 1201 last_pc_ = pc_; |
1133 if (reg.is(rax)) { | 1202 if (reg.is(rax)) { |
1134 emit(0xA8); | 1203 emit(0xA8); |
1135 emit(mask); | 1204 emit(mask); |
1136 } else { | 1205 } else { |
1137 if (reg.code() > 3) { | 1206 if (reg.code() > 3) { |
1138 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 1207 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
1139 emit_rex_32(reg); | 1208 emit_rex_32(reg); |
1140 } | 1209 } |
1141 emit(0xF6); | 1210 emit(0xF6); |
1142 emit_modrm(0x0, reg); | 1211 emit_modrm(0x0, reg); |
1143 emit(mask.value_); // Low byte emitted. | 1212 emit(mask.value_); // Low byte emitted. |
1144 } | 1213 } |
1145 } | 1214 } |
1146 | 1215 |
1147 | 1216 |
1148 void Assembler::testb(const Operand& op, Immediate mask) { | 1217 void Assembler::testb(const Operand& op, Immediate mask) { |
1218 ASSERT(is_int8(mask.value_)); | |
1149 EnsureSpace ensure_space(this); | 1219 EnsureSpace ensure_space(this); |
1150 last_pc_ = pc_; | 1220 last_pc_ = pc_; |
1151 emit_optional_rex_32(rax, op); | 1221 emit_optional_rex_32(rax, op); |
1152 emit(0xF6); | 1222 emit(0xF6); |
1153 emit_operand(rax, op); // Operation code 0 | 1223 emit_operand(rax, op); // Operation code 0 |
1154 emit(mask.value_); // Low byte emitted. | 1224 emit(mask.value_); // Low byte emitted. |
1155 } | 1225 } |
1156 | 1226 |
1157 | 1227 |
1158 void Assembler::testl(Register reg, Immediate mask) { | 1228 void Assembler::testl(Register reg, Immediate mask) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 | 1261 |
1192 void Assembler::testq(Register dst, Register src) { | 1262 void Assembler::testq(Register dst, Register src) { |
1193 EnsureSpace ensure_space(this); | 1263 EnsureSpace ensure_space(this); |
1194 last_pc_ = pc_; | 1264 last_pc_ = pc_; |
1195 emit_rex_64(dst, src); | 1265 emit_rex_64(dst, src); |
1196 emit(0x85); | 1266 emit(0x85); |
1197 emit_modrm(dst, src); | 1267 emit_modrm(dst, src); |
1198 } | 1268 } |
1199 | 1269 |
1200 | 1270 |
1271 void Assembler::testq(Register dst, Immediate mask) { | |
1272 EnsureSpace ensure_space(this); | |
1273 last_pc_ = pc_; | |
1274 if (dst.is(rax)) { | |
1275 emit_rex_64(); | |
1276 emit(0xA9); | |
1277 emit(mask); | |
1278 } else { | |
1279 emit_rex_64(dst); | |
1280 emit(0xF7); | |
1281 emit_modrm(0, dst); | |
1282 emit(mask); | |
1283 } | |
1284 } | |
1285 | |
1286 | |
1201 // Relocation information implementations | 1287 // Relocation information implementations |
1202 | 1288 |
1203 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { | 1289 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { |
1204 ASSERT(rmode != RelocInfo::NONE); | 1290 ASSERT(rmode != RelocInfo::NONE); |
1205 // Don't record external references unless the heap will be serialized. | 1291 // Don't record external references unless the heap will be serialized. |
1206 if (rmode == RelocInfo::EXTERNAL_REFERENCE && | 1292 if (rmode == RelocInfo::EXTERNAL_REFERENCE && |
1207 !Serializer::enabled() && | 1293 !Serializer::enabled() && |
1208 !FLAG_debug_code) { | 1294 !FLAG_debug_code) { |
1209 return; | 1295 return; |
1210 } | 1296 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1538 UNIMPLEMENTED(); | 1624 UNIMPLEMENTED(); |
1539 return NULL; | 1625 return NULL; |
1540 } | 1626 } |
1541 | 1627 |
1542 byte* JavaScriptFrame::GetCallerStackPointer() const { | 1628 byte* JavaScriptFrame::GetCallerStackPointer() const { |
1543 UNIMPLEMENTED(); | 1629 UNIMPLEMENTED(); |
1544 return NULL; | 1630 return NULL; |
1545 } | 1631 } |
1546 | 1632 |
1547 } } // namespace v8::internal | 1633 } } // namespace v8::internal |
OLD | NEW |