| 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 // } | 528 // } |
| 529 class CpuFeatures : public AllStatic { | 529 class CpuFeatures : public AllStatic { |
| 530 public: | 530 public: |
| 531 // Detect features of the target CPU. Set safe defaults if the serializer | 531 // Detect features of the target CPU. Set safe defaults if the serializer |
| 532 // is enabled (snapshots must be portable). | 532 // is enabled (snapshots must be portable). |
| 533 static void Probe(); | 533 static void Probe(); |
| 534 | 534 |
| 535 // Check whether a feature is supported by the target CPU. | 535 // Check whether a feature is supported by the target CPU. |
| 536 static bool IsSupported(CpuFeature f) { | 536 static bool IsSupported(CpuFeature f) { |
| 537 ASSERT(initialized_); | 537 ASSERT(initialized_); |
| 538 if (Check(f, cross_compile_)) return true; |
| 538 if (f == SSE2 && !FLAG_enable_sse2) return false; | 539 if (f == SSE2 && !FLAG_enable_sse2) return false; |
| 539 if (f == SSE3 && !FLAG_enable_sse3) return false; | 540 if (f == SSE3 && !FLAG_enable_sse3) return false; |
| 540 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; | 541 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; |
| 541 if (f == CMOV && !FLAG_enable_cmov) return false; | 542 if (f == CMOV && !FLAG_enable_cmov) return false; |
| 542 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; | 543 return Check(f, supported_); |
| 543 } | 544 } |
| 544 | 545 |
| 545 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { | 546 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { |
| 546 ASSERT(initialized_); | 547 ASSERT(initialized_); |
| 547 return (found_by_runtime_probing_only_ & | 548 return Check(f, found_by_runtime_probing_only_); |
| 548 (static_cast<uint64_t>(1) << f)) != 0; | |
| 549 } | 549 } |
| 550 | 550 |
| 551 static bool IsSafeForSnapshot(CpuFeature f) { | 551 static bool IsSafeForSnapshot(CpuFeature f) { |
| 552 return (IsSupported(f) && | 552 return Check(f, cross_compile_) || |
| 553 (IsSupported(f) && |
| 553 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); | 554 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); |
| 554 } | 555 } |
| 555 | 556 |
| 557 static bool VerifyCrossCompiling() { |
| 558 return cross_compile_ == 0; |
| 559 } |
| 560 |
| 561 static bool VerifyCrossCompiling(CpuFeature f) { |
| 562 uint64_t mask = flag2set(f); |
| 563 return cross_compile_ == 0 || |
| 564 (cross_compile_ & mask) == mask; |
| 565 } |
| 566 |
| 556 private: | 567 private: |
| 568 static bool Check(CpuFeature f, uint64_t set) { |
| 569 return (set & flag2set(f)) != 0; |
| 570 } |
| 571 |
| 572 static uint64_t flag2set(CpuFeature f) { |
| 573 return static_cast<uint64_t>(1) << f; |
| 574 } |
| 575 |
| 557 #ifdef DEBUG | 576 #ifdef DEBUG |
| 558 static bool initialized_; | 577 static bool initialized_; |
| 559 #endif | 578 #endif |
| 560 static uint64_t supported_; | 579 static uint64_t supported_; |
| 561 static uint64_t found_by_runtime_probing_only_; | 580 static uint64_t found_by_runtime_probing_only_; |
| 562 | 581 |
| 582 static uint64_t cross_compile_; |
| 583 |
| 563 friend class ExternalReference; | 584 friend class ExternalReference; |
| 564 friend class PlatformFeatureScope; | 585 friend class PlatformFeatureScope; |
| 565 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); | 586 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); |
| 566 }; | 587 }; |
| 567 | 588 |
| 568 | 589 |
| 569 class Assembler : public AssemblerBase { | 590 class Assembler : public AssemblerBase { |
| 570 private: | 591 private: |
| 571 // We check before assembling an instruction that there is sufficient | 592 // We check before assembling an instruction that there is sufficient |
| 572 // space to write an instruction and its relocation information. | 593 // space to write an instruction and its relocation information. |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 private: | 1256 private: |
| 1236 Assembler* assembler_; | 1257 Assembler* assembler_; |
| 1237 #ifdef DEBUG | 1258 #ifdef DEBUG |
| 1238 int space_before_; | 1259 int space_before_; |
| 1239 #endif | 1260 #endif |
| 1240 }; | 1261 }; |
| 1241 | 1262 |
| 1242 } } // namespace v8::internal | 1263 } } // namespace v8::internal |
| 1243 | 1264 |
| 1244 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1265 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
| OLD | NEW |