| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #define V8_ARM_ASSEMBLER_ARM_H_ | 41 #define V8_ARM_ASSEMBLER_ARM_H_ |
| 42 #include <stdio.h> | 42 #include <stdio.h> |
| 43 #include "assembler.h" | 43 #include "assembler.h" |
| 44 #include "constants-arm.h" | 44 #include "constants-arm.h" |
| 45 #include "serialize.h" | 45 #include "serialize.h" |
| 46 | 46 |
| 47 namespace v8 { | 47 namespace v8 { |
| 48 namespace internal { | 48 namespace internal { |
| 49 | 49 |
| 50 // CpuFeatures keeps track of which features are supported by the target CPU. | 50 // CpuFeatures keeps track of which features are supported by the target CPU. |
| 51 // Supported features must be enabled by a Scope before use. | 51 // Supported features must be enabled by a CpuFeatureScope before use. |
| 52 class CpuFeatures : public AllStatic { | 52 class CpuFeatures : public AllStatic { |
| 53 public: | 53 public: |
| 54 // Detect features of the target CPU. Set safe defaults if the serializer | 54 // Detect features of the target CPU. Set safe defaults if the serializer |
| 55 // is enabled (snapshots must be portable). | 55 // is enabled (snapshots must be portable). |
| 56 static void Probe(); | 56 static void Probe(); |
| 57 | 57 |
| 58 // Check whether a feature is supported by the target CPU. | 58 // Check whether a feature is supported by the target CPU. |
| 59 static bool IsSupported(CpuFeature f) { | 59 static bool IsSupported(CpuFeature f) { |
| 60 ASSERT(initialized_); | 60 ASSERT(initialized_); |
| 61 if (f == VFP3 && !FLAG_enable_vfp3) return false; | 61 if (f == VFP3 && !FLAG_enable_vfp3) return false; |
| 62 if (f == VFP2 && !FLAG_enable_vfp2) return false; | 62 if (f == VFP2 && !FLAG_enable_vfp2) return false; |
| 63 if (f == SUDIV && !FLAG_enable_sudiv) return false; | 63 if (f == SUDIV && !FLAG_enable_sudiv) return false; |
| 64 if (f == UNALIGNED_ACCESSES && !FLAG_enable_unaligned_accesses) { | 64 if (f == UNALIGNED_ACCESSES && !FLAG_enable_unaligned_accesses) { |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 if (f == VFP32DREGS && !FLAG_enable_32dregs) return false; | 67 if (f == VFP32DREGS && !FLAG_enable_32dregs) return false; |
| 68 return (supported_ & (1u << f)) != 0; | 68 return (supported_ & (1u << f)) != 0; |
| 69 } | 69 } |
| 70 | 70 |
| 71 #ifdef DEBUG | 71 static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { |
| 72 // Check whether a feature is currently enabled. | |
| 73 static bool IsEnabled(CpuFeature f) { | |
| 74 ASSERT(initialized_); | 72 ASSERT(initialized_); |
| 75 Isolate* isolate = Isolate::UncheckedCurrent(); | 73 return (found_by_runtime_probing_only_ & |
| 76 if (isolate == NULL) { | 74 (static_cast<uint64_t>(1) << f)) != 0; |
| 77 // When no isolate is available, work as if we're running in | |
| 78 // release mode. | |
| 79 return IsSupported(f); | |
| 80 } | |
| 81 unsigned enabled = static_cast<unsigned>(isolate->enabled_cpu_features()); | |
| 82 return (enabled & (1u << f)) != 0; | |
| 83 } | 75 } |
| 84 #endif | |
| 85 | |
| 86 // Enable a specified feature within a scope. | |
| 87 class Scope BASE_EMBEDDED { | |
| 88 #ifdef DEBUG | |
| 89 | |
| 90 public: | |
| 91 explicit Scope(CpuFeature f) { | |
| 92 unsigned mask = 1u << f; | |
| 93 // VFP2 and ARMv7 are implied by VFP3. | |
| 94 if (f == VFP3) mask |= 1u << VFP2 | 1u << ARMv7; | |
| 95 ASSERT(CpuFeatures::IsSupported(f)); | |
| 96 ASSERT(!Serializer::enabled() || | |
| 97 (CpuFeatures::found_by_runtime_probing_ & mask) == 0); | |
| 98 isolate_ = Isolate::UncheckedCurrent(); | |
| 99 old_enabled_ = 0; | |
| 100 if (isolate_ != NULL) { | |
| 101 old_enabled_ = static_cast<unsigned>(isolate_->enabled_cpu_features()); | |
| 102 isolate_->set_enabled_cpu_features(old_enabled_ | mask); | |
| 103 } | |
| 104 } | |
| 105 ~Scope() { | |
| 106 ASSERT_EQ(Isolate::UncheckedCurrent(), isolate_); | |
| 107 if (isolate_ != NULL) { | |
| 108 isolate_->set_enabled_cpu_features(old_enabled_); | |
| 109 } | |
| 110 } | |
| 111 | |
| 112 private: | |
| 113 Isolate* isolate_; | |
| 114 unsigned old_enabled_; | |
| 115 #else | |
| 116 | |
| 117 public: | |
| 118 explicit Scope(CpuFeature f) {} | |
| 119 #endif | |
| 120 }; | |
| 121 | 76 |
| 122 class TryForceFeatureScope BASE_EMBEDDED { | 77 class TryForceFeatureScope BASE_EMBEDDED { |
| 123 public: | 78 public: |
| 124 explicit TryForceFeatureScope(CpuFeature f) | 79 explicit TryForceFeatureScope(CpuFeature f) |
| 125 : old_supported_(CpuFeatures::supported_) { | 80 : old_supported_(CpuFeatures::supported_) { |
| 126 if (CanForce()) { | 81 if (CanForce()) { |
| 127 CpuFeatures::supported_ |= (1u << f); | 82 CpuFeatures::supported_ |= (1u << f); |
| 128 } | 83 } |
| 129 } | 84 } |
| 130 | 85 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 } | 98 } |
| 144 | 99 |
| 145 const unsigned old_supported_; | 100 const unsigned old_supported_; |
| 146 }; | 101 }; |
| 147 | 102 |
| 148 private: | 103 private: |
| 149 #ifdef DEBUG | 104 #ifdef DEBUG |
| 150 static bool initialized_; | 105 static bool initialized_; |
| 151 #endif | 106 #endif |
| 152 static unsigned supported_; | 107 static unsigned supported_; |
| 153 static unsigned found_by_runtime_probing_; | 108 static unsigned found_by_runtime_probing_only_; |
| 154 | 109 |
| 155 friend class ExternalReference; | 110 friend class ExternalReference; |
| 156 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); | 111 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); |
| 157 }; | 112 }; |
| 158 | 113 |
| 159 | 114 |
| 160 // CPU Registers. | 115 // CPU Registers. |
| 161 // | 116 // |
| 162 // 1) We would prefer to use an enum, but enum values are assignment- | 117 // 1) We would prefer to use an enum, but enum values are assignment- |
| 163 // compatible with int, which has caused code-generation bugs. | 118 // compatible with int, which has caused code-generation bugs. |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 public: | 1464 public: |
| 1510 explicit EnsureSpace(Assembler* assembler) { | 1465 explicit EnsureSpace(Assembler* assembler) { |
| 1511 assembler->CheckBuffer(); | 1466 assembler->CheckBuffer(); |
| 1512 } | 1467 } |
| 1513 }; | 1468 }; |
| 1514 | 1469 |
| 1515 | 1470 |
| 1516 } } // namespace v8::internal | 1471 } } // namespace v8::internal |
| 1517 | 1472 |
| 1518 #endif // V8_ARM_ASSEMBLER_ARM_H_ | 1473 #endif // V8_ARM_ASSEMBLER_ARM_H_ |
| OLD | NEW |