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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 if (f == RDTSC && !FLAG_enable_rdtsc) return false; | 529 if (f == RDTSC && !FLAG_enable_rdtsc) return false; |
530 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; | 530 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; |
531 } | 531 } |
532 | 532 |
533 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { | 533 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { |
534 ASSERT(initialized_); | 534 ASSERT(initialized_); |
535 return (found_by_runtime_probing_only_ & | 535 return (found_by_runtime_probing_only_ & |
536 (static_cast<uint64_t>(1) << f)) != 0; | 536 (static_cast<uint64_t>(1) << f)) != 0; |
537 } | 537 } |
538 | 538 |
539 class TryForceFeatureScope BASE_EMBEDDED { | 539 static bool IsSafeForSnapshot(CpuFeature f) { |
540 public: | 540 return (IsSupported(f) && |
541 explicit TryForceFeatureScope(CpuFeature f) | 541 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); |
542 : old_supported_(CpuFeatures::supported_) { | 542 } |
543 if (CanForce()) { | |
544 CpuFeatures::supported_ |= (static_cast<uint64_t>(1) << f); | |
545 } | |
546 } | |
547 | |
548 ~TryForceFeatureScope() { | |
549 if (CanForce()) { | |
550 CpuFeatures::supported_ = old_supported_; | |
551 } | |
552 } | |
553 | |
554 private: | |
555 static bool CanForce() { | |
556 // It's only safe to temporarily force support of CPU features | |
557 // when there's only a single isolate, which is guaranteed when | |
558 // the serializer is enabled. | |
559 return Serializer::enabled(); | |
560 } | |
561 | |
562 const uint64_t old_supported_; | |
563 }; | |
564 | 543 |
565 private: | 544 private: |
566 #ifdef DEBUG | 545 #ifdef DEBUG |
567 static bool initialized_; | 546 static bool initialized_; |
568 #endif | 547 #endif |
569 static uint64_t supported_; | 548 static uint64_t supported_; |
570 static uint64_t found_by_runtime_probing_only_; | 549 static uint64_t found_by_runtime_probing_only_; |
571 | 550 |
572 friend class ExternalReference; | 551 friend class ExternalReference; |
573 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); | 552 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 private: | 1208 private: |
1230 Assembler* assembler_; | 1209 Assembler* assembler_; |
1231 #ifdef DEBUG | 1210 #ifdef DEBUG |
1232 int space_before_; | 1211 int space_before_; |
1233 #endif | 1212 #endif |
1234 }; | 1213 }; |
1235 | 1214 |
1236 } } // namespace v8::internal | 1215 } } // namespace v8::internal |
1237 | 1216 |
1238 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1217 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |