From a5e0f768b358bd79bf0914b86997f2c942aacbe7 Mon Sep 17 00:00:00 2001 From: "olivf@chromium.org" Date: Tue, 17 Sep 2013 13:02:25 +0000 Subject: [PATCH] Add a mechanism to override the detected cpu features. 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 | 1 + src/assembler.cc | 20 ++++++++++++++++++++ src/assembler.h | 13 +++++++++++++ src/ia32/assembler-ia32.h | 1 + src/mips/assembler-mips.h | 1 + src/x64/assembler-x64.h | 1 + 6 files changed, 37 insertions(+) diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h index 866b1c9..1399021 100644 --- a/src/arm/assembler-arm.h +++ b/src/arm/assembler-arm.h @@ -89,6 +89,7 @@ class CpuFeatures : public AllStatic { static unsigned cache_line_size_; friend class ExternalReference; + friend class PlatformFeatureScope; DISALLOW_COPY_AND_ASSIGN(CpuFeatures); }; diff --git a/src/assembler.cc b/src/assembler.cc index fbff62d..6581aa1 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -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(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 { diff --git a/src/assembler.h b/src/assembler.h index 6b399f2..1220074 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -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) diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h index 55eff93..736dd3b 100644 --- a/src/ia32/assembler-ia32.h +++ b/src/ia32/assembler-ia32.h @@ -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); }; diff --git a/src/mips/assembler-mips.h b/src/mips/assembler-mips.h index cb0896a..2e25a56 100644 --- a/src/mips/assembler-mips.h +++ b/src/mips/assembler-mips.h @@ -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); }; diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index f2e37fe..f4cc4a3 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -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); }; -- 2.7.4