OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "vm/cpuinfo.h" | 8 #include "vm/cpuinfo.h" |
9 #include "vm/cpuid.h" | 9 #include "vm/cpuid.h" |
10 #include "vm/proccpuinfo.h" | 10 #include "vm/proccpuinfo.h" |
11 | 11 |
12 #include "platform/assert.h" | 12 #include "platform/assert.h" |
13 | 13 |
14 // As with Windows, on IA32 and X64, we use the cpuid instruction. | 14 // As with Windows, on IA32 and X64, we use the cpuid instruction. |
15 // The analogous instruction is privileged on ARM and MIPS, so we resort to | 15 // The analogous instruction is privileged on ARM and MIPS, so we resort to |
16 // reading from /proc/cpuinfo. | 16 // reading from /proc/cpuinfo. |
17 | 17 |
18 namespace dart { | 18 namespace dart { |
19 | 19 |
20 CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault; | 20 CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault; |
21 const char* CpuInfo::fields_[kCpuInfoMax] = {0}; | 21 const char* CpuInfo::fields_[kCpuInfoMax] = {0}; |
22 | 22 |
23 void CpuInfo::InitOnce() { | 23 void CpuInfo::InitOnce() { |
24 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) | 24 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
25 fields_[kCpuInfoProcessor] = "vendor_id"; | 25 fields_[kCpuInfoProcessor] = "vendor_id"; |
26 fields_[kCpuInfoModel] = "model name"; | 26 fields_[kCpuInfoModel] = "model name"; |
27 fields_[kCpuInfoHardware] = "model name"; | 27 fields_[kCpuInfoHardware] = "model name"; |
28 fields_[kCpuInfoFeatures] = "flags"; | 28 fields_[kCpuInfoFeatures] = "flags"; |
| 29 fields_[kCpuInfoArchitecture] = "CPU architecture"; |
29 method_ = kCpuInfoCpuId; | 30 method_ = kCpuInfoCpuId; |
30 CpuId::InitOnce(); | 31 CpuId::InitOnce(); |
31 #elif defined(HOST_ARCH_ARM) | 32 #elif defined(HOST_ARCH_ARM) |
32 fields_[kCpuInfoProcessor] = "Processor"; | 33 fields_[kCpuInfoProcessor] = "Processor"; |
33 fields_[kCpuInfoModel] = "model name"; | 34 fields_[kCpuInfoModel] = "model name"; |
34 fields_[kCpuInfoHardware] = "Hardware"; | 35 fields_[kCpuInfoHardware] = "Hardware"; |
35 fields_[kCpuInfoFeatures] = "Features"; | 36 fields_[kCpuInfoFeatures] = "Features"; |
| 37 fields_[kCpuInfoArchitecture] = "CPU architecture"; |
36 method_ = kCpuInfoSystem; | 38 method_ = kCpuInfoSystem; |
37 ProcCpuInfo::InitOnce(); | 39 ProcCpuInfo::InitOnce(); |
38 #elif defined(HOST_ARCH_ARM64) | 40 #elif defined(HOST_ARCH_ARM64) |
39 fields_[kCpuInfoProcessor] = "Processor"; | 41 fields_[kCpuInfoProcessor] = "Processor"; |
40 fields_[kCpuInfoModel] = "CPU implementer"; | 42 fields_[kCpuInfoModel] = "CPU implementer"; |
41 fields_[kCpuInfoHardware] = "CPU implementer"; | 43 fields_[kCpuInfoHardware] = "CPU implementer"; |
42 fields_[kCpuInfoFeatures] = "Features"; | 44 fields_[kCpuInfoFeatures] = "Features"; |
| 45 fields_[kCpuInfoArchitecture] = "CPU architecture"; |
43 method_ = kCpuInfoSystem; | 46 method_ = kCpuInfoSystem; |
44 ProcCpuInfo::InitOnce(); | 47 ProcCpuInfo::InitOnce(); |
45 #elif defined(HOST_ARCH_MIPS) | 48 #elif defined(HOST_ARCH_MIPS) |
46 fields_[kCpuInfoProcessor] = "system type"; | 49 fields_[kCpuInfoProcessor] = "system type"; |
47 fields_[kCpuInfoModel] = "cpu model"; | 50 fields_[kCpuInfoModel] = "cpu model"; |
48 fields_[kCpuInfoHardware] = "cpu model"; | 51 fields_[kCpuInfoHardware] = "cpu model"; |
49 fields_[kCpuInfoFeatures] = "ASEs implemented"; | 52 fields_[kCpuInfoFeatures] = "ASEs implemented"; |
| 53 fields_[kCpuInfoArchitecture] = "CPU architecture"; |
50 method_ = kCpuInfoSystem; | 54 method_ = kCpuInfoSystem; |
51 ProcCpuInfo::InitOnce(); | 55 ProcCpuInfo::InitOnce(); |
52 #else | 56 #else |
53 #error Unrecognized target architecture | 57 #error Unrecognized target architecture |
54 #endif | 58 #endif |
55 } | 59 } |
56 | 60 |
57 | 61 |
58 void CpuInfo::Cleanup() { | 62 void CpuInfo::Cleanup() { |
59 if (method_ == kCpuInfoCpuId) { | 63 if (method_ == kCpuInfoCpuId) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); | 100 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); |
97 } else { | 101 } else { |
98 ASSERT(method_ == kCpuInfoSystem); | 102 ASSERT(method_ == kCpuInfoSystem); |
99 return ProcCpuInfo::HasField(field); | 103 return ProcCpuInfo::HasField(field); |
100 } | 104 } |
101 } | 105 } |
102 | 106 |
103 } // namespace dart | 107 } // namespace dart |
104 | 108 |
105 #endif // defined(TARGET_OS_LINUX) | 109 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |