Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: src/ia32/assembler-ia32.h

Issue 23523060: Add a mechanism to override the detected cpu features. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ((force_feature_ & (static_cast<uint64_t>(1) << f)) != 0) return true;
Sven Panne 2013/09/16 13:48:05 Lift out static_cast<uint64_t>(1) << f into a
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 (supported_ & (static_cast<uint64_t>(1) << f)) != 0;
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 (found_by_runtime_probing_only_ &
548 (static_cast<uint64_t>(1) << f)) != 0; 549 (static_cast<uint64_t>(1) << f)) != 0;
549 } 550 }
550 551
551 static bool IsSafeForSnapshot(CpuFeature f) { 552 static bool IsSafeForSnapshot(CpuFeature f) {
552 return (IsSupported(f) && 553 return (IsSupported(f) &&
553 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); 554 (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))) ||
555 ((force_feature_ & (static_cast<uint64_t>(1) << f)) != 0);
556 }
557
558 static void ForceFeature(CpuFeature f) {
Sven Panne 2013/09/16 13:48:05 I am not sure about the future use cases, perhaps
559 force_feature_ = force_feature_ | (static_cast<uint64_t>(1) << f);
560 }
561
562 static void ClearForcedFeatures() {
563 force_feature_ = 0;
554 } 564 }
555 565
556 private: 566 private:
557 #ifdef DEBUG 567 #ifdef DEBUG
558 static bool initialized_; 568 static bool initialized_;
559 #endif 569 #endif
570 static uint64_t force_feature_;
560 static uint64_t supported_; 571 static uint64_t supported_;
561 static uint64_t found_by_runtime_probing_only_; 572 static uint64_t found_by_runtime_probing_only_;
562 573
563 friend class ExternalReference; 574 friend class ExternalReference;
564 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); 575 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
565 }; 576 };
566 577
567 578
568 class Assembler : public AssemblerBase { 579 class Assembler : public AssemblerBase {
569 private: 580 private:
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 private: 1245 private:
1235 Assembler* assembler_; 1246 Assembler* assembler_;
1236 #ifdef DEBUG 1247 #ifdef DEBUG
1237 int space_before_; 1248 int space_before_;
1238 #endif 1249 #endif
1239 }; 1250 };
1240 1251
1241 } } // namespace v8::internal 1252 } } // namespace v8::internal
1242 1253
1243 #endif // V8_IA32_ASSEMBLER_IA32_H_ 1254 #endif // V8_IA32_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698