| Index: src/x64/assembler-x64.h
|
| diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h
|
| index 52aca637785f45b16ba67e701fce1ce20a30557a..f22f80b50822547d17e7eb818a0dd8f961c0941a 100644
|
| --- a/src/x64/assembler-x64.h
|
| +++ b/src/x64/assembler-x64.h
|
| @@ -434,14 +434,15 @@ class Operand BASE_EMBEDDED {
|
| // } else {
|
| // // Generate standard x87 or SSE2 floating point code.
|
| // }
|
| -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 == SSE2 && !FLAG_enable_sse2) return false;
|
| if (f == SSE3 && !FLAG_enable_sse3) return false;
|
| if (f == CMOV && !FLAG_enable_cmov) return false;
|
| @@ -449,51 +450,65 @@ class CpuFeatures {
|
| 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.
|
| - bool IsEnabled(CpuFeature f) const {
|
| - return (enabled_ & (V8_UINT64_C(1) << 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);
|
| + }
|
| + uint64_t enabled = isolate->enabled_cpu_features();
|
| + 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)
|
| - : cpu_features_(Isolate::Current()->cpu_features()),
|
| - isolate_(Isolate::Current()) {
|
| - uint64_t mask = (V8_UINT64_C(1) << f);
|
| - ASSERT(cpu_features_->IsSupported(f));
|
| + explicit Scope(CpuFeature f) {
|
| + uint64_t mask = V8_UINT64_C(1) << f;
|
| + ASSERT(CpuFeatures::IsSupported(f));
|
| ASSERT(!Serializer::enabled() ||
|
| - (cpu_features_->found_by_runtime_probing_ & mask) == 0);
|
| - old_enabled_ = cpu_features_->enabled_;
|
| - cpu_features_->enabled_ |= mask;
|
| + (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);
|
| + }
|
| }
|
| ~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:
|
| - uint64_t old_enabled_;
|
| - CpuFeatures* cpu_features_;
|
| Isolate* isolate_;
|
| + uint64_t old_enabled_;
|
| #else
|
| public:
|
| explicit Scope(CpuFeature f) {}
|
| #endif
|
| };
|
| - private:
|
| - CpuFeatures();
|
|
|
| + private:
|
| // 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);
|
|
|
| - uint64_t supported_;
|
| - uint64_t enabled_;
|
| - uint64_t found_by_runtime_probing_;
|
| -
|
| - friend class Isolate;
|
| +#ifdef DEBUG
|
| + static bool initialized_;
|
| +#endif
|
| + static uint64_t supported_;
|
| + static uint64_t found_by_runtime_probing_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
|
| };
|
| @@ -526,7 +541,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.
|
|
|