| Index: src/x64/assembler-x64.h
|
| diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h
|
| index f22f80b50822547d17e7eb818a0dd8f961c0941a..52aca637785f45b16ba67e701fce1ce20a30557a 100644
|
| --- a/src/x64/assembler-x64.h
|
| +++ b/src/x64/assembler-x64.h
|
| @@ -434,15 +434,14 @@ class Operand BASE_EMBEDDED {
|
| // } else {
|
| // // Generate standard x87 or SSE2 floating point code.
|
| // }
|
| -class CpuFeatures : public AllStatic {
|
| +class CpuFeatures {
|
| public:
|
| // Detect features of the target CPU. Set safe defaults if the serializer
|
| // is enabled (snapshots must be portable).
|
| - static void Probe();
|
| + void Probe(bool portable);
|
|
|
| // Check whether a feature is supported by the target CPU.
|
| - static bool IsSupported(CpuFeature f) {
|
| - ASSERT(initialized_);
|
| + bool IsSupported(CpuFeature f) const {
|
| if (f == SSE2 && !FLAG_enable_sse2) return false;
|
| if (f == SSE3 && !FLAG_enable_sse3) return false;
|
| if (f == CMOV && !FLAG_enable_cmov) return false;
|
| @@ -450,65 +449,51 @@ class CpuFeatures : public AllStatic {
|
| if (f == SAHF && !FLAG_enable_sahf) return false;
|
| return (supported_ & (V8_UINT64_C(1) << f)) != 0;
|
| }
|
| -
|
| -#ifdef DEBUG
|
| // Check whether a feature is currently enabled.
|
| - 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);
|
| - }
|
| - uint64_t enabled = isolate->enabled_cpu_features();
|
| - return (enabled & (V8_UINT64_C(1) << f)) != 0;
|
| + bool IsEnabled(CpuFeature f) const {
|
| + return (enabled_ & (V8_UINT64_C(1) << f)) != 0;
|
| }
|
| -#endif
|
| -
|
| // Enable a specified feature within a scope.
|
| class Scope BASE_EMBEDDED {
|
| #ifdef DEBUG
|
| public:
|
| - explicit Scope(CpuFeature f) {
|
| - uint64_t mask = V8_UINT64_C(1) << f;
|
| - ASSERT(CpuFeatures::IsSupported(f));
|
| + explicit Scope(CpuFeature f)
|
| + : cpu_features_(Isolate::Current()->cpu_features()),
|
| + isolate_(Isolate::Current()) {
|
| + uint64_t mask = (V8_UINT64_C(1) << f);
|
| + ASSERT(cpu_features_->IsSupported(f));
|
| ASSERT(!Serializer::enabled() ||
|
| - (CpuFeatures::found_by_runtime_probing_ & mask) == 0);
|
| - isolate_ = Isolate::UncheckedCurrent();
|
| - old_enabled_ = 0;
|
| - if (isolate_ != NULL) {
|
| - old_enabled_ = isolate_->enabled_cpu_features();
|
| - isolate_->set_enabled_cpu_features(old_enabled_ | mask);
|
| - }
|
| + (cpu_features_->found_by_runtime_probing_ & mask) == 0);
|
| + old_enabled_ = cpu_features_->enabled_;
|
| + cpu_features_->enabled_ |= mask;
|
| }
|
| ~Scope() {
|
| - ASSERT_EQ(Isolate::UncheckedCurrent(), isolate_);
|
| - if (isolate_ != NULL) {
|
| - isolate_->set_enabled_cpu_features(old_enabled_);
|
| - }
|
| + ASSERT_EQ(Isolate::Current(), isolate_);
|
| + cpu_features_->enabled_ = old_enabled_;
|
| }
|
| private:
|
| - Isolate* isolate_;
|
| uint64_t old_enabled_;
|
| + CpuFeatures* cpu_features_;
|
| + Isolate* isolate_;
|
| #else
|
| public:
|
| explicit Scope(CpuFeature f) {}
|
| #endif
|
| };
|
| -
|
| private:
|
| + CpuFeatures();
|
| +
|
| // Safe defaults include SSE2 and CMOV for X64. It is always available, if
|
| // anyone checks, but they shouldn't need to check.
|
| // The required user mode extensions in X64 are (from AMD64 ABI Table A.1):
|
| // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall
|
| static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV);
|
|
|
| -#ifdef DEBUG
|
| - static bool initialized_;
|
| -#endif
|
| - static uint64_t supported_;
|
| - static uint64_t found_by_runtime_probing_;
|
| + uint64_t supported_;
|
| + uint64_t enabled_;
|
| + uint64_t found_by_runtime_probing_;
|
| +
|
| + friend class Isolate;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
|
| };
|
| @@ -541,7 +526,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(Isolate* isolate, void* buffer, int buffer_size);
|
| + Assembler(void* buffer, int buffer_size);
|
| ~Assembler();
|
|
|
| // Overrides the default provided by FLAG_debug_code.
|
|
|