| 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 are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // // Generate standard SSE2 floating point code. | 464 // // Generate standard SSE2 floating point code. |
| 465 // } | 465 // } |
| 466 class CpuFeatures : public AllStatic { | 466 class CpuFeatures : public AllStatic { |
| 467 public: | 467 public: |
| 468 // Detect features of the target CPU. Set safe defaults if the serializer | 468 // Detect features of the target CPU. Set safe defaults if the serializer |
| 469 // is enabled (snapshots must be portable). | 469 // is enabled (snapshots must be portable). |
| 470 static void Probe(); | 470 static void Probe(); |
| 471 | 471 |
| 472 // Check whether a feature is supported by the target CPU. | 472 // Check whether a feature is supported by the target CPU. |
| 473 static bool IsSupported(CpuFeature f) { | 473 static bool IsSupported(CpuFeature f) { |
| 474 if (Check(f, cross_compile_)) return true; |
| 474 ASSERT(initialized_); | 475 ASSERT(initialized_); |
| 475 if (f == SSE3 && !FLAG_enable_sse3) return false; | 476 if (f == SSE3 && !FLAG_enable_sse3) return false; |
| 476 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; | 477 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; |
| 477 if (f == CMOV && !FLAG_enable_cmov) return false; | 478 if (f == CMOV && !FLAG_enable_cmov) return false; |
| 478 if (f == SAHF && !FLAG_enable_sahf) return false; | 479 if (f == SAHF && !FLAG_enable_sahf) return false; |
| 479 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; | 480 return Check(f, supported_); |
| 480 } | 481 } |
| 481 | 482 |
| 482 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { | 483 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { |
| 483 ASSERT(initialized_); | 484 ASSERT(initialized_); |
| 484 return (found_by_runtime_probing_only_ & | 485 return Check(f, found_by_runtime_probing_only_); |
| 485 (static_cast<uint64_t>(1) << f)) != 0; | |
| 486 } | 486 } |
| 487 | 487 |
| 488 static bool IsSafeForSnapshot(CpuFeature f) { | 488 static bool IsSafeForSnapshot(CpuFeature f) { |
| 489 return (IsSupported(f) && | 489 return Check(f, cross_compile_) || |
| 490 (IsSupported(f) && |
| 490 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); | 491 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); |
| 491 } | 492 } |
| 492 | 493 |
| 494 static bool VerifyCrossCompiling() { |
| 495 return cross_compile_ == 0; |
| 496 } |
| 497 |
| 498 static bool VerifyCrossCompiling(CpuFeature f) { |
| 499 uint64_t mask = flag2set(f); |
| 500 return cross_compile_ == 0 || |
| 501 (cross_compile_ & mask) == mask; |
| 502 } |
| 503 |
| 493 private: | 504 private: |
| 505 static bool Check(CpuFeature f, uint64_t set) { |
| 506 return (set & flag2set(f)) != 0; |
| 507 } |
| 508 |
| 509 static uint64_t flag2set(CpuFeature f) { |
| 510 return static_cast<uint64_t>(1) << f; |
| 511 } |
| 512 |
| 494 // Safe defaults include CMOV for X64. It is always available, if | 513 // Safe defaults include CMOV for X64. It is always available, if |
| 495 // anyone checks, but they shouldn't need to check. | 514 // anyone checks, but they shouldn't need to check. |
| 496 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1): | 515 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1): |
| 497 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall | 516 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall |
| 498 static const uint64_t kDefaultCpuFeatures = (1 << CMOV); | 517 static const uint64_t kDefaultCpuFeatures = (1 << CMOV); |
| 499 | 518 |
| 500 #ifdef DEBUG | 519 #ifdef DEBUG |
| 501 static bool initialized_; | 520 static bool initialized_; |
| 502 #endif | 521 #endif |
| 503 static uint64_t supported_; | 522 static uint64_t supported_; |
| 504 static uint64_t found_by_runtime_probing_only_; | 523 static uint64_t found_by_runtime_probing_only_; |
| 505 | 524 |
| 525 static uint64_t cross_compile_; |
| 526 |
| 506 friend class ExternalReference; | 527 friend class ExternalReference; |
| 507 friend class PlatformFeatureScope; | 528 friend class PlatformFeatureScope; |
| 508 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); | 529 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); |
| 509 }; | 530 }; |
| 510 | 531 |
| 511 | 532 |
| 512 class Assembler : public AssemblerBase { | 533 class Assembler : public AssemblerBase { |
| 513 private: | 534 private: |
| 514 // We check before assembling an instruction that there is sufficient | 535 // We check before assembling an instruction that there is sufficient |
| 515 // space to write an instruction and its relocation information. | 536 // space to write an instruction and its relocation information. |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 private: | 1681 private: |
| 1661 Assembler* assembler_; | 1682 Assembler* assembler_; |
| 1662 #ifdef DEBUG | 1683 #ifdef DEBUG |
| 1663 int space_before_; | 1684 int space_before_; |
| 1664 #endif | 1685 #endif |
| 1665 }; | 1686 }; |
| 1666 | 1687 |
| 1667 } } // namespace v8::internal | 1688 } } // namespace v8::internal |
| 1668 | 1689 |
| 1669 #endif // V8_X64_ASSEMBLER_X64_H_ | 1690 #endif // V8_X64_ASSEMBLER_X64_H_ |
| OLD | NEW |