| Index: src/arm/assembler-arm.h
|
| diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h
|
| index 91e6244bbd42ab73d2ccc9fac41ba8d225ea8440..c9f8cfeaf590f36d77c4ade5d5ed966fedb34e09 100644
|
| --- a/src/arm/assembler-arm.h
|
| +++ b/src/arm/assembler-arm.h
|
| @@ -468,58 +468,97 @@ class MemOperand BASE_EMBEDDED {
|
|
|
| // CpuFeatures keeps track of which features are supported by the target CPU.
|
| // Supported features must be enabled by a Scope before use.
|
| -class CpuFeatures {
|
| +class CpuFeatures : public AllStatic {
|
| public:
|
| // Detect features of the target CPU. Set safe defaults if the serializer
|
| // is enabled (snapshots must be portable).
|
| - void Probe(bool portable);
|
| + static void Probe();
|
|
|
| // Check whether a feature is supported by the target CPU.
|
| - bool IsSupported(CpuFeature f) const {
|
| + static bool IsSupported(CpuFeature f) {
|
| + ASSERT(initialized_);
|
| if (f == VFP3 && !FLAG_enable_vfp3) return false;
|
| return (supported_ & (1u << f)) != 0;
|
| }
|
|
|
| +#ifdef DEBUG
|
| // Check whether a feature is currently enabled.
|
| - bool IsEnabled(CpuFeature f) const {
|
| - return (enabled_ & (1u << f)) != 0;
|
| + static bool IsEnabled(CpuFeature f) {
|
| + ASSERT(initialized_);
|
| + Isolate* isolate = Isolate::UncheckedCurrent();
|
| + if (isolate == NULL) {
|
| + // When no isolate is available, work as if we're running in
|
| + // release mode.
|
| + return IsSupported(f);
|
| + }
|
| + unsigned enabled = static_cast<unsigned>(isolate->enabled_cpu_features());
|
| + return (enabled & (1u << f)) != 0;
|
| }
|
| +#endif
|
|
|
| // Enable a specified feature within a scope.
|
| class Scope BASE_EMBEDDED {
|
| #ifdef DEBUG
|
| public:
|
| - explicit Scope(CpuFeature f)
|
| - : cpu_features_(Isolate::Current()->cpu_features()),
|
| - isolate_(Isolate::Current()) {
|
| - ASSERT(cpu_features_->IsSupported(f));
|
| + explicit Scope(CpuFeature f) {
|
| + unsigned mask = 1u << f;
|
| + ASSERT(CpuFeatures::IsSupported(f));
|
| ASSERT(!Serializer::enabled() ||
|
| - (cpu_features_->found_by_runtime_probing_ & (1u << f)) == 0);
|
| - old_enabled_ = cpu_features_->enabled_;
|
| - cpu_features_->enabled_ |= 1u << f;
|
| + (CpuFeatures::found_by_runtime_probing_ & mask) == 0);
|
| + isolate_ = Isolate::UncheckedCurrent();
|
| + old_enabled_ = 0;
|
| + if (isolate_ != NULL) {
|
| + old_enabled_ = static_cast<unsigned>(isolate_->enabled_cpu_features());
|
| + isolate_->set_enabled_cpu_features(old_enabled_ | mask);
|
| + }
|
| }
|
| ~Scope() {
|
| - ASSERT_EQ(Isolate::Current(), isolate_);
|
| - cpu_features_->enabled_ = old_enabled_;
|
| + ASSERT_EQ(Isolate::UncheckedCurrent(), isolate_);
|
| + if (isolate_ != NULL) {
|
| + isolate_->set_enabled_cpu_features(old_enabled_);
|
| + }
|
| }
|
| private:
|
| - unsigned old_enabled_;
|
| - CpuFeatures* cpu_features_;
|
| Isolate* isolate_;
|
| + unsigned old_enabled_;
|
| #else
|
| public:
|
| explicit Scope(CpuFeature f) {}
|
| #endif
|
| };
|
|
|
| - private:
|
| - CpuFeatures();
|
| + class TryForceFeatureScope BASE_EMBEDDED {
|
| + public:
|
| + explicit TryForceFeatureScope(CpuFeature f)
|
| + : old_supported_(CpuFeatures::supported_) {
|
| + if (CanForce()) {
|
| + CpuFeatures::supported_ |= (1u << f);
|
| + }
|
| + }
|
|
|
| - unsigned supported_;
|
| - unsigned enabled_;
|
| - unsigned found_by_runtime_probing_;
|
| + ~TryForceFeatureScope() {
|
| + if (CanForce()) {
|
| + CpuFeatures::supported_ = old_supported_;
|
| + }
|
| + }
|
|
|
| - friend class Isolate;
|
| + private:
|
| + static bool CanForce() {
|
| + // It's only safe to temporarily force support of CPU features
|
| + // when there's only a single isolate, which is guaranteed when
|
| + // the serializer is enabled.
|
| + return Serializer::enabled();
|
| + }
|
| +
|
| + const unsigned old_supported_;
|
| + };
|
| +
|
| + private:
|
| +#ifdef DEBUG
|
| + static bool initialized_;
|
| +#endif
|
| + static unsigned supported_;
|
| + static unsigned found_by_runtime_probing_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
|
| };
|
| @@ -564,7 +603,7 @@ class Assembler : public AssemblerBase {
|
| // for code generation and assumes its size to be buffer_size. If the buffer
|
| // is too small, a fatal error occurs. No deallocation of the buffer is done
|
| // upon destruction of the assembler.
|
| - Assembler(void* buffer, int buffer_size);
|
| + Assembler(Isolate* isolate, void* buffer, int buffer_size);
|
| ~Assembler();
|
|
|
| // Overrides the default provided by FLAG_debug_code.
|
|
|