Add a mechanism to override the detected cpu features.
authorolivf@chromium.org <olivf@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 17 Sep 2013 13:02:25 +0000 (13:02 +0000)
committerolivf@chromium.org <olivf@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 17 Sep 2013 13:02:25 +0000 (13:02 +0000)
BUG=
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/23523060

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16772 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/assembler-arm.h
src/assembler.cc
src/assembler.h
src/ia32/assembler-ia32.h
src/mips/assembler-mips.h
src/x64/assembler-x64.h

index 866b1c9..1399021 100644 (file)
@@ -89,6 +89,7 @@ class CpuFeatures : public AllStatic {
   static unsigned cache_line_size_;
 
   friend class ExternalReference;
+  friend class PlatformFeatureScope;
   DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
 };
 
index fbff62d..6581aa1 100644 (file)
@@ -207,6 +207,26 @@ CpuFeatureScope::~CpuFeatureScope() {
 
 
 // -----------------------------------------------------------------------------
+// Implementation of PlatformFeatureScope
+
+PlatformFeatureScope::PlatformFeatureScope(CpuFeature f)
+    : old_supported_(CpuFeatures::supported_),
+      old_found_by_runtime_probing_only_(
+          CpuFeatures::found_by_runtime_probing_only_) {
+  uint64_t mask = static_cast<uint64_t>(1) << f;
+  CpuFeatures::supported_ |= mask;
+  CpuFeatures::found_by_runtime_probing_only_ &= ~mask;
+}
+
+
+PlatformFeatureScope::~PlatformFeatureScope() {
+  CpuFeatures::supported_ = old_supported_;
+  CpuFeatures::found_by_runtime_probing_only_ =
+      old_found_by_runtime_probing_only_;
+}
+
+
+// -----------------------------------------------------------------------------
 // Implementation of Label
 
 int Label::pos() const {
index 6b399f2..1220074 100644 (file)
@@ -134,6 +134,19 @@ class CpuFeatureScope BASE_EMBEDDED {
 };
 
 
+// Enable a unsupported feature within a scope for cross-compiling for a
+// different CPU.
+class PlatformFeatureScope BASE_EMBEDDED {
+ public:
+  explicit PlatformFeatureScope(CpuFeature f);
+  ~PlatformFeatureScope();
+
+ private:
+  uint64_t old_supported_;
+  uint64_t old_found_by_runtime_probing_only_;
+};
+
+
 // -----------------------------------------------------------------------------
 // Labels represent pc locations; they are typically jump or call targets.
 // After declaration, a label can be freely used to denote known or (yet)
index 55eff93..736dd3b 100644 (file)
@@ -561,6 +561,7 @@ class CpuFeatures : public AllStatic {
   static uint64_t found_by_runtime_probing_only_;
 
   friend class ExternalReference;
+  friend class PlatformFeatureScope;
   DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
 };
 
index cb0896a..2e25a56 100644 (file)
@@ -426,6 +426,7 @@ class CpuFeatures : public AllStatic {
   static unsigned found_by_runtime_probing_only_;
 
   friend class ExternalReference;
+  friend class PlatformFeatureScope;
   DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
 };
 
index f2e37fe..f4cc4a3 100644 (file)
@@ -504,6 +504,7 @@ class CpuFeatures : public AllStatic {
   static uint64_t found_by_runtime_probing_only_;
 
   friend class ExternalReference;
+  friend class PlatformFeatureScope;
   DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
 };