| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 6 |
| 7 #if defined(TARGET_ARCH_MIPS) | 7 #if defined(TARGET_ARCH_MIPS) |
| 8 | 8 |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/cpuinfo.h" | 10 #include "vm/cpuinfo.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 const char* CPU::Id() { | 34 const char* CPU::Id() { |
| 35 return | 35 return |
| 36 #if !defined(HOST_ARCH_MIPS) | 36 #if !defined(HOST_ARCH_MIPS) |
| 37 "sim" | 37 "sim" |
| 38 #endif // !defined(HOST_ARCH_MIPS) | 38 #endif // !defined(HOST_ARCH_MIPS) |
| 39 "mips"; | 39 "mips"; |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 const char* HostCPUFeatures::hardware_ = NULL; | 43 const char* HostCPUFeatures::hardware_ = NULL; |
| 44 MIPSVersion HostCPUFeatures::mips_version_ = MIPSvUnknown; |
| 44 #if defined(DEBUG) | 45 #if defined(DEBUG) |
| 45 bool HostCPUFeatures::initialized_ = false; | 46 bool HostCPUFeatures::initialized_ = false; |
| 46 #endif | 47 #endif |
| 47 | 48 |
| 48 | 49 |
| 49 #if defined(HOST_ARCH_MIPS) | 50 #if defined(HOST_ARCH_MIPS) |
| 50 void HostCPUFeatures::InitOnce() { | 51 void HostCPUFeatures::InitOnce() { |
| 51 CpuInfo::InitOnce(); | 52 CpuInfo::InitOnce(); |
| 52 hardware_ = CpuInfo::GetCpuModel(); | 53 hardware_ = CpuInfo::GetCpuModel(); |
| 53 // Has a floating point unit. | 54 // Has a floating point unit. |
| 54 ASSERT(CpuInfo::FieldContains(kCpuInfoModel, "FPU")); | 55 ASSERT(CpuInfo::FieldContains(kCpuInfoModel, "FPU")); |
| 56 |
| 57 // We want to know the ISA version, but on MIPS, CpuInfo can't tell us, so |
| 58 // we use the same ISA version that Dart's C++ compiler targeted. |
| 59 #if defined(_MIPS_ARCH_MIPS32R2) |
| 60 mips_version_ = MIPS32r2; |
| 61 #elif defined(_MIPS_ARCH_MIPS32) |
| 62 mips_version_ = MIPS32; |
| 63 #endif |
| 64 |
| 55 #if defined(DEBUG) | 65 #if defined(DEBUG) |
| 56 initialized_ = true; | 66 initialized_ = true; |
| 57 #endif | 67 #endif |
| 58 } | 68 } |
| 59 | 69 |
| 60 | 70 |
| 61 void HostCPUFeatures::Cleanup() { | 71 void HostCPUFeatures::Cleanup() { |
| 62 DEBUG_ASSERT(initialized_); | 72 DEBUG_ASSERT(initialized_); |
| 63 #if defined(DEBUG) | 73 #if defined(DEBUG) |
| 64 initialized_ = false; | 74 initialized_ = false; |
| 65 #endif | 75 #endif |
| 66 ASSERT(hardware_ != NULL); | 76 ASSERT(hardware_ != NULL); |
| 67 free(const_cast<char*>(hardware_)); | 77 free(const_cast<char*>(hardware_)); |
| 68 hardware_ = NULL; | 78 hardware_ = NULL; |
| 69 CpuInfo::Cleanup(); | 79 CpuInfo::Cleanup(); |
| 70 } | 80 } |
| 71 | 81 |
| 72 #else | 82 #else |
| 73 | 83 |
| 74 void HostCPUFeatures::InitOnce() { | 84 void HostCPUFeatures::InitOnce() { |
| 75 CpuInfo::InitOnce(); | 85 CpuInfo::InitOnce(); |
| 76 hardware_ = CpuInfo::GetCpuModel(); | 86 hardware_ = CpuInfo::GetCpuModel(); |
| 87 mips_version_ = MIPS32r2; |
| 77 #if defined(DEBUG) | 88 #if defined(DEBUG) |
| 78 initialized_ = true; | 89 initialized_ = true; |
| 79 #endif | 90 #endif |
| 80 } | 91 } |
| 81 | 92 |
| 82 | 93 |
| 83 void HostCPUFeatures::Cleanup() { | 94 void HostCPUFeatures::Cleanup() { |
| 84 DEBUG_ASSERT(initialized_); | 95 DEBUG_ASSERT(initialized_); |
| 85 #if defined(DEBUG) | 96 #if defined(DEBUG) |
| 86 initialized_ = false; | 97 initialized_ = false; |
| 87 #endif | 98 #endif |
| 88 ASSERT(hardware_ != NULL); | 99 ASSERT(hardware_ != NULL); |
| 89 free(const_cast<char*>(hardware_)); | 100 free(const_cast<char*>(hardware_)); |
| 90 hardware_ = NULL; | 101 hardware_ = NULL; |
| 91 CpuInfo::Cleanup(); | 102 CpuInfo::Cleanup(); |
| 92 } | 103 } |
| 93 #endif // defined(HOST_ARCH_MIPS) | 104 #endif // defined(HOST_ARCH_MIPS) |
| 94 | 105 |
| 95 } // namespace dart | 106 } // namespace dart |
| 96 | 107 |
| 97 #endif // defined TARGET_ARCH_MIPS | 108 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |