| 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(HOST_OS_LINUX) | 6 #if defined(HOST_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, 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"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 method_ = kCpuInfoSystem; | 38 method_ = kCpuInfoSystem; |
| 39 ProcCpuInfo::InitOnce(); | 39 ProcCpuInfo::InitOnce(); |
| 40 #elif defined(HOST_ARCH_ARM64) | 40 #elif defined(HOST_ARCH_ARM64) |
| 41 fields_[kCpuInfoProcessor] = "Processor"; | 41 fields_[kCpuInfoProcessor] = "Processor"; |
| 42 fields_[kCpuInfoModel] = "CPU implementer"; | 42 fields_[kCpuInfoModel] = "CPU implementer"; |
| 43 fields_[kCpuInfoHardware] = "CPU implementer"; | 43 fields_[kCpuInfoHardware] = "CPU implementer"; |
| 44 fields_[kCpuInfoFeatures] = "Features"; | 44 fields_[kCpuInfoFeatures] = "Features"; |
| 45 fields_[kCpuInfoArchitecture] = "CPU architecture"; | 45 fields_[kCpuInfoArchitecture] = "CPU architecture"; |
| 46 method_ = kCpuInfoSystem; | 46 method_ = kCpuInfoSystem; |
| 47 ProcCpuInfo::InitOnce(); | 47 ProcCpuInfo::InitOnce(); |
| 48 #elif defined(HOST_ARCH_MIPS) | |
| 49 fields_[kCpuInfoProcessor] = "system type"; | |
| 50 fields_[kCpuInfoModel] = "cpu model"; | |
| 51 fields_[kCpuInfoHardware] = "cpu model"; | |
| 52 fields_[kCpuInfoFeatures] = "ASEs implemented"; | |
| 53 fields_[kCpuInfoArchitecture] = "CPU architecture"; | |
| 54 method_ = kCpuInfoSystem; | |
| 55 ProcCpuInfo::InitOnce(); | |
| 56 #else | 48 #else |
| 57 #error Unrecognized target architecture | 49 #error Unrecognized target architecture |
| 58 #endif | 50 #endif |
| 59 } | 51 } |
| 60 | 52 |
| 61 | 53 |
| 62 void CpuInfo::Cleanup() { | 54 void CpuInfo::Cleanup() { |
| 63 if (method_ == kCpuInfoCpuId) { | 55 if (method_ == kCpuInfoCpuId) { |
| 64 CpuId::Cleanup(); | 56 CpuId::Cleanup(); |
| 65 } else { | 57 } else { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); | 92 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); |
| 101 } else { | 93 } else { |
| 102 ASSERT(method_ == kCpuInfoSystem); | 94 ASSERT(method_ == kCpuInfoSystem); |
| 103 return ProcCpuInfo::HasField(field); | 95 return ProcCpuInfo::HasField(field); |
| 104 } | 96 } |
| 105 } | 97 } |
| 106 | 98 |
| 107 } // namespace dart | 99 } // namespace dart |
| 108 | 100 |
| 109 #endif // defined(HOST_OS_LINUX) | 101 #endif // defined(HOST_OS_LINUX) |
| OLD | NEW |