| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_ARM64_CPU_ARM64_H_ | 5 #ifndef V8_ARM64_CPU_ARM64_H_ |
| 6 #define V8_ARM64_CPU_ARM64_H_ | 6 #define V8_ARM64_CPU_ARM64_H_ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include "serialize.h" | 9 #include "serialize.h" |
| 10 #include "cpu.h" | 10 #include "cpu.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 | 15 |
| 16 // CpuFeatures keeps track of which features are supported by the target CPU. | 16 // CpuFeatures keeps track of which features are supported by the target CPU. |
| 17 // Supported features must be enabled by a CpuFeatureScope before use. | 17 // Supported features must be enabled by a CpuFeatureScope before use. |
| 18 class CpuFeatures : public AllStatic { | 18 class CpuFeatures : public AllStatic { |
| 19 public: | 19 public: |
| 20 // Detect features of the target CPU. Set safe defaults if the serializer | 20 // Detect features of the target CPU. Set safe defaults if the serializer |
| 21 // is enabled (snapshots must be portable). | 21 // is enabled (snapshots must be portable). |
| 22 static void Probe(bool serializer_enabled); | 22 static void Probe(bool serializer_enabled); |
| 23 | 23 |
| 24 // Check whether a feature is supported by the target CPU. | 24 // Check whether a feature is supported by the target CPU. |
| 25 static bool IsSupported(CpuFeature f) { | 25 static bool IsSupported(CpuFeature f) { |
| 26 ASSERT(initialized_); | 26 ASSERT(initialized_); |
| 27 // There are no optional features for ARM64. | 27 return Check(f, supported_); |
| 28 return false; | |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 // There are no optional features for ARM64. | |
| 32 static bool IsSafeForSnapshot(Isolate* isolate, CpuFeature f) { | 30 static bool IsSafeForSnapshot(Isolate* isolate, CpuFeature f) { |
| 33 return IsSupported(f); | 31 return IsSupported(f); |
| 34 } | 32 } |
| 35 | 33 |
| 36 // I and D cache line size in bytes. | 34 // I and D cache line size in bytes. |
| 37 static unsigned dcache_line_size(); | 35 static unsigned dcache_line_size(); |
| 38 static unsigned icache_line_size(); | 36 static unsigned icache_line_size(); |
| 39 | 37 |
| 40 static unsigned supported_; | 38 static unsigned supported_; |
| 41 | 39 |
| 42 static bool VerifyCrossCompiling() { | 40 static bool VerifyCrossCompiling() { |
| 43 // There are no optional features for ARM64. | 41 return cross_compile_ == 0; |
| 44 ASSERT(cross_compile_ == 0); | |
| 45 return true; | |
| 46 } | 42 } |
| 47 | 43 |
| 48 static bool VerifyCrossCompiling(CpuFeature f) { | 44 static bool VerifyCrossCompiling(CpuFeature f) { |
| 49 // There are no optional features for ARM64. | 45 unsigned mask = flag2set(f); |
| 50 USE(f); | 46 return cross_compile_ == 0 || |
| 51 ASSERT(cross_compile_ == 0); | 47 (cross_compile_ & mask) == mask; |
| 52 return true; | |
| 53 } | 48 } |
| 54 | 49 |
| 55 static bool SupportsCrankshaft() { return true; } | 50 static bool SupportsCrankshaft() { return true; } |
| 56 | 51 |
| 57 private: | 52 private: |
| 58 #ifdef DEBUG | 53 #ifdef DEBUG |
| 59 static bool initialized_; | 54 static bool initialized_; |
| 60 #endif | 55 #endif |
| 61 | 56 |
| 62 // This isn't used (and is always 0), but it is required by V8. | 57 static unsigned found_by_runtime_probing_only_; |
| 63 static unsigned cross_compile_; | 58 static unsigned cross_compile_; |
| 64 | 59 |
| 60 static bool Check(CpuFeature f, unsigned set) { |
| 61 return (set & flag2set(f)) != 0; |
| 62 } |
| 63 |
| 64 static unsigned flag2set(CpuFeature f) { |
| 65 return 1u << f; |
| 66 } |
| 67 |
| 65 friend class PlatformFeatureScope; | 68 friend class PlatformFeatureScope; |
| 66 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); | 69 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 } } // namespace v8::internal | 72 } } // namespace v8::internal |
| 70 | 73 |
| 71 #endif // V8_ARM64_CPU_ARM64_H_ | 74 #endif // V8_ARM64_CPU_ARM64_H_ |
| OLD | NEW |