| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 CpuFeatures::CpuFeatures() | 51 CpuFeatures::CpuFeatures() |
| 52 : supported_(0), | 52 : supported_(0), |
| 53 enabled_(0), | 53 enabled_(0), |
| 54 found_by_runtime_probing_(0) { | 54 found_by_runtime_probing_(0) { |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 // The Probe method needs executable memory, so it uses Heap::CreateCode. | 58 // The Probe method needs executable memory, so it uses Heap::CreateCode. |
| 59 // Allocation failure is silent and leads to safe default. | 59 // Allocation failure is silent and leads to safe default. |
| 60 void CpuFeatures::Probe(bool portable) { | 60 void CpuFeatures::Probe(bool portable) { |
| 61 ASSERT(HEAP->HasBeenSetup()); | |
| 62 ASSERT(supported_ == 0); | 61 ASSERT(supported_ == 0); |
| 63 if (portable && Serializer::enabled()) { | 62 if (portable && Serializer::enabled()) { |
| 64 supported_ |= OS::CpuFeaturesImpliedByPlatform(); | 63 supported_ |= OS::CpuFeaturesImpliedByPlatform(); |
| 65 return; // No features if we might serialize. | 64 return; // No features if we might serialize. |
| 66 } | 65 } |
| 66 ASSERT(HEAP->HasBeenSetup()); |
| 67 | 67 |
| 68 Assembler assm(NULL, 0); | 68 Assembler assm(NULL, 0); |
| 69 Label cpuid, done; | 69 Label cpuid, done; |
| 70 #define __ assm. | 70 #define __ assm. |
| 71 // Save old esp, since we are going to modify the stack. | 71 // Save old esp, since we are going to modify the stack. |
| 72 __ push(ebp); | 72 __ push(ebp); |
| 73 __ pushfd(); | 73 __ pushfd(); |
| 74 __ push(ecx); | 74 __ push(ecx); |
| 75 __ push(ebx); | 75 __ push(ebx); |
| 76 __ mov(ebp, Operand(esp)); | 76 __ mov(ebp, Operand(esp)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 set_sib(scale, index, ebp); | 277 set_sib(scale, index, ebp); |
| 278 set_dispr(disp, rmode); | 278 set_dispr(disp, rmode); |
| 279 } | 279 } |
| 280 | 280 |
| 281 | 281 |
| 282 bool Operand::is_reg(Register reg) const { | 282 bool Operand::is_reg(Register reg) const { |
| 283 return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only. | 283 return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only. |
| 284 && ((buf_[0] & 0x07) == reg.code()); // register codes match. | 284 && ((buf_[0] & 0x07) == reg.code()); // register codes match. |
| 285 } | 285 } |
| 286 | 286 |
| 287 |
| 288 bool Operand::is_reg_only() const { |
| 289 return (buf_[0] & 0xF8) == 0xC0; // Addressing mode is register only. |
| 290 } |
| 291 |
| 292 |
| 293 Register Operand::reg() const { |
| 294 ASSERT(is_reg_only()); |
| 295 return Register::from_code(buf_[0] & 0x07); |
| 296 } |
| 297 |
| 298 |
| 287 // ----------------------------------------------------------------------------- | 299 // ----------------------------------------------------------------------------- |
| 288 // Implementation of Assembler. | 300 // Implementation of Assembler. |
| 289 | 301 |
| 290 // Emit a single byte. Must always be inlined. | 302 // Emit a single byte. Must always be inlined. |
| 291 #define EMIT(x) \ | 303 #define EMIT(x) \ |
| 292 *pc_++ = (x) | 304 *pc_++ = (x) |
| 293 | 305 |
| 294 | 306 |
| 295 #ifdef GENERATED_CODE_COVERAGE | 307 #ifdef GENERATED_CODE_COVERAGE |
| 296 static void InitCoverageLog(); | 308 static void InitCoverageLog(); |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 EnsureSpace ensure_space(this); | 913 EnsureSpace ensure_space(this); |
| 902 last_pc_ = pc_; | 914 last_pc_ = pc_; |
| 903 EMIT(0x21); | 915 EMIT(0x21); |
| 904 emit_operand(src, dst); | 916 emit_operand(src, dst); |
| 905 } | 917 } |
| 906 | 918 |
| 907 | 919 |
| 908 void Assembler::cmpb(const Operand& op, int8_t imm8) { | 920 void Assembler::cmpb(const Operand& op, int8_t imm8) { |
| 909 EnsureSpace ensure_space(this); | 921 EnsureSpace ensure_space(this); |
| 910 last_pc_ = pc_; | 922 last_pc_ = pc_; |
| 911 EMIT(0x80); | 923 if (op.is_reg(eax)) { |
| 912 emit_operand(edi, op); // edi == 7 | 924 EMIT(0x3C); |
| 925 } else { |
| 926 EMIT(0x80); |
| 927 emit_operand(edi, op); // edi == 7 |
| 928 } |
| 913 EMIT(imm8); | 929 EMIT(imm8); |
| 914 } | 930 } |
| 915 | 931 |
| 916 | 932 |
| 917 void Assembler::cmpb(const Operand& dst, Register src) { | 933 void Assembler::cmpb(const Operand& dst, Register src) { |
| 918 ASSERT(src.is_byte_register()); | 934 ASSERT(src.is_byte_register()); |
| 919 EnsureSpace ensure_space(this); | 935 EnsureSpace ensure_space(this); |
| 920 last_pc_ = pc_; | 936 last_pc_ = pc_; |
| 921 EMIT(0x38); | 937 EMIT(0x38); |
| 922 emit_operand(src, dst); | 938 emit_operand(src, dst); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 | 1285 |
| 1270 | 1286 |
| 1271 void Assembler::shr_cl(Register dst) { | 1287 void Assembler::shr_cl(Register dst) { |
| 1272 EnsureSpace ensure_space(this); | 1288 EnsureSpace ensure_space(this); |
| 1273 last_pc_ = pc_; | 1289 last_pc_ = pc_; |
| 1274 EMIT(0xD3); | 1290 EMIT(0xD3); |
| 1275 EMIT(0xE8 | dst.code()); | 1291 EMIT(0xE8 | dst.code()); |
| 1276 } | 1292 } |
| 1277 | 1293 |
| 1278 | 1294 |
| 1279 void Assembler::subb(const Operand& op, int8_t imm8) { | |
| 1280 EnsureSpace ensure_space(this); | |
| 1281 last_pc_ = pc_; | |
| 1282 if (op.is_reg(eax)) { | |
| 1283 EMIT(0x2c); | |
| 1284 } else { | |
| 1285 EMIT(0x80); | |
| 1286 emit_operand(ebp, op); // ebp == 5 | |
| 1287 } | |
| 1288 EMIT(imm8); | |
| 1289 } | |
| 1290 | |
| 1291 | |
| 1292 void Assembler::sub(const Operand& dst, const Immediate& x) { | 1295 void Assembler::sub(const Operand& dst, const Immediate& x) { |
| 1293 EnsureSpace ensure_space(this); | 1296 EnsureSpace ensure_space(this); |
| 1294 last_pc_ = pc_; | 1297 last_pc_ = pc_; |
| 1295 emit_arith(5, dst, x); | 1298 emit_arith(5, dst, x); |
| 1296 } | 1299 } |
| 1297 | 1300 |
| 1298 | 1301 |
| 1299 void Assembler::sub(Register dst, const Operand& src) { | 1302 void Assembler::sub(Register dst, const Operand& src) { |
| 1300 EnsureSpace ensure_space(this); | 1303 EnsureSpace ensure_space(this); |
| 1301 last_pc_ = pc_; | 1304 last_pc_ = pc_; |
| 1302 EMIT(0x2B); | 1305 EMIT(0x2B); |
| 1303 emit_operand(dst, src); | 1306 emit_operand(dst, src); |
| 1304 } | 1307 } |
| 1305 | 1308 |
| 1306 | 1309 |
| 1307 void Assembler::subb(Register dst, const Operand& src) { | |
| 1308 ASSERT(dst.code() < 4); | |
| 1309 EnsureSpace ensure_space(this); | |
| 1310 last_pc_ = pc_; | |
| 1311 EMIT(0x2A); | |
| 1312 emit_operand(dst, src); | |
| 1313 } | |
| 1314 | |
| 1315 | |
| 1316 void Assembler::sub(const Operand& dst, Register src) { | 1310 void Assembler::sub(const Operand& dst, Register src) { |
| 1317 EnsureSpace ensure_space(this); | 1311 EnsureSpace ensure_space(this); |
| 1318 last_pc_ = pc_; | 1312 last_pc_ = pc_; |
| 1319 EMIT(0x29); | 1313 EMIT(0x29); |
| 1320 emit_operand(src, dst); | 1314 emit_operand(src, dst); |
| 1321 } | 1315 } |
| 1322 | 1316 |
| 1323 | 1317 |
| 1324 void Assembler::test(Register reg, const Immediate& imm) { | 1318 void Assembler::test(Register reg, const Immediate& imm) { |
| 1325 EnsureSpace ensure_space(this); | 1319 EnsureSpace ensure_space(this); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 void Assembler::test(const Operand& op, const Immediate& imm) { | 1361 void Assembler::test(const Operand& op, const Immediate& imm) { |
| 1368 EnsureSpace ensure_space(this); | 1362 EnsureSpace ensure_space(this); |
| 1369 last_pc_ = pc_; | 1363 last_pc_ = pc_; |
| 1370 EMIT(0xF7); | 1364 EMIT(0xF7); |
| 1371 emit_operand(eax, op); | 1365 emit_operand(eax, op); |
| 1372 emit(imm); | 1366 emit(imm); |
| 1373 } | 1367 } |
| 1374 | 1368 |
| 1375 | 1369 |
| 1376 void Assembler::test_b(const Operand& op, uint8_t imm8) { | 1370 void Assembler::test_b(const Operand& op, uint8_t imm8) { |
| 1371 if (op.is_reg_only() && op.reg().code() >= 4) { |
| 1372 test(op, Immediate(imm8)); |
| 1373 return; |
| 1374 } |
| 1377 EnsureSpace ensure_space(this); | 1375 EnsureSpace ensure_space(this); |
| 1378 last_pc_ = pc_; | 1376 last_pc_ = pc_; |
| 1379 EMIT(0xF6); | 1377 EMIT(0xF6); |
| 1380 emit_operand(eax, op); | 1378 emit_operand(eax, op); |
| 1381 EMIT(imm8); | 1379 EMIT(imm8); |
| 1382 } | 1380 } |
| 1383 | 1381 |
| 1384 | 1382 |
| 1385 void Assembler::xor_(Register dst, int32_t imm32) { | 1383 void Assembler::xor_(Register dst, int32_t imm32) { |
| 1386 EnsureSpace ensure_space(this); | 1384 EnsureSpace ensure_space(this); |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 fprintf(coverage_log, "%s\n", file_line); | 2793 fprintf(coverage_log, "%s\n", file_line); |
| 2796 fflush(coverage_log); | 2794 fflush(coverage_log); |
| 2797 } | 2795 } |
| 2798 } | 2796 } |
| 2799 | 2797 |
| 2800 #endif | 2798 #endif |
| 2801 | 2799 |
| 2802 } } // namespace v8::internal | 2800 } } // namespace v8::internal |
| 2803 | 2801 |
| 2804 #endif // V8_TARGET_ARCH_IA32 | 2802 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |