| 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_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/cpuinfo.h" | 10 #include "vm/cpuinfo.h" |
| 11 #include "vm/heap.h" | 11 #include "vm/heap.h" |
| 12 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 13 #include "vm/object.h" | 13 #include "vm/object.h" |
| 14 #include "vm/simulator.h" | 14 #include "vm/simulator.h" |
| 15 #include "vm/thread.h" | 15 #include "vm/thread.h" |
| 16 | 16 |
| 17 #if defined(HOST_ARCH_ARM) | 17 #if defined(HOST_ARCH_ARM) |
| 18 #include <sys/syscall.h> /* NOLINT */ | 18 #include <sys/syscall.h> /* NOLINT */ |
| 19 #include <unistd.h> /* NOLINT */ | 19 #include <unistd.h> /* NOLINT */ |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, use_vfp, true, "Use vfp instructions if supported"); | 24 DEFINE_FLAG(bool, use_vfp, true, "Use vfp instructions if supported"); |
| 25 DEFINE_FLAG(bool, use_neon, true, "Use neon instructions if supported"); | 25 DEFINE_FLAG(bool, use_neon, true, "Use neon instructions if supported"); |
| 26 #if !defined(HOST_ARCH_ARM) | 26 #if !defined(HOST_ARCH_ARM) |
| 27 DEFINE_FLAG(bool, sim_use_armv7, true, "Use all ARMv7 instructions"); | 27 DEFINE_FLAG(bool, sim_use_armv7, true, "Use all ARMv7 instructions"); |
| 28 DEFINE_FLAG(bool, sim_use_armv5te, false, "Restrict to ARMv5TE instructions"); | 28 DEFINE_FLAG(bool, sim_use_armv5te, false, "Restrict to ARMv5TE instructions"); |
| 29 DEFINE_FLAG(bool, sim_use_armv6, false, "Restrict to ARMv6 instructions"); | 29 DEFINE_FLAG(bool, sim_use_armv6, false, "Restrict to ARMv6 instructions"); |
| 30 DEFINE_FLAG(bool, sim_use_hardfp, false, "Use the softfp ABI."); |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 void CPU::FlushICache(uword start, uword size) { | 33 void CPU::FlushICache(uword start, uword size) { |
| 33 #if defined(HOST_ARCH_ARM) | 34 #if defined(HOST_ARCH_ARM) |
| 34 // Nothing to do. Flushing no instructions. | 35 // Nothing to do. Flushing no instructions. |
| 35 if (size == 0) { | 36 if (size == 0) { |
| 36 return; | 37 return; |
| 37 } | 38 } |
| 38 | 39 |
| 39 // ARM recommends using the gcc intrinsic __clear_cache on Linux, and the | 40 // ARM recommends using the gcc intrinsic __clear_cache on Linux, and the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 59 #if !defined(HOST_ARCH_ARM) | 60 #if !defined(HOST_ARCH_ARM) |
| 60 "sim" | 61 "sim" |
| 61 #endif // !defined(HOST_ARCH_ARM) | 62 #endif // !defined(HOST_ARCH_ARM) |
| 62 "arm"; | 63 "arm"; |
| 63 } | 64 } |
| 64 | 65 |
| 65 | 66 |
| 66 bool HostCPUFeatures::integer_division_supported_ = false; | 67 bool HostCPUFeatures::integer_division_supported_ = false; |
| 67 bool HostCPUFeatures::vfp_supported_ = false; | 68 bool HostCPUFeatures::vfp_supported_ = false; |
| 68 bool HostCPUFeatures::neon_supported_ = false; | 69 bool HostCPUFeatures::neon_supported_ = false; |
| 70 bool HostCPUFeatures::hardfp_supported_ = false; |
| 69 const char* HostCPUFeatures::hardware_ = NULL; | 71 const char* HostCPUFeatures::hardware_ = NULL; |
| 70 ARMVersion HostCPUFeatures::arm_version_ = ARMvUnknown; | 72 ARMVersion HostCPUFeatures::arm_version_ = ARMvUnknown; |
| 71 #if defined(DEBUG) | 73 #if defined(DEBUG) |
| 72 bool HostCPUFeatures::initialized_ = false; | 74 bool HostCPUFeatures::initialized_ = false; |
| 73 #endif | 75 #endif |
| 74 | 76 |
| 75 | 77 |
| 76 #if defined(HOST_ARCH_ARM) | 78 #if defined(HOST_ARCH_ARM) |
| 77 void HostCPUFeatures::InitOnce() { | 79 void HostCPUFeatures::InitOnce() { |
| 78 CpuInfo::InitOnce(); | 80 CpuInfo::InitOnce(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 102 bool is_krait = CpuInfo::FieldContains(kCpuInfoHardware, "QCT APQ8064"); | 104 bool is_krait = CpuInfo::FieldContains(kCpuInfoHardware, "QCT APQ8064"); |
| 103 if (is_krait) { | 105 if (is_krait) { |
| 104 // Special case for Qualcomm Krait CPUs in Nexus 4 and 7. | 106 // Special case for Qualcomm Krait CPUs in Nexus 4 and 7. |
| 105 integer_division_supported_ = true; | 107 integer_division_supported_ = true; |
| 106 } else { | 108 } else { |
| 107 integer_division_supported_ = | 109 integer_division_supported_ = |
| 108 CpuInfo::FieldContains(kCpuInfoFeatures, "idiva"); | 110 CpuInfo::FieldContains(kCpuInfoFeatures, "idiva"); |
| 109 } | 111 } |
| 110 neon_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "neon") && | 112 neon_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "neon") && |
| 111 FLAG_use_vfp && FLAG_use_neon; | 113 FLAG_use_vfp && FLAG_use_neon; |
| 114 |
| 115 // Use the cross-compiler's predefined macros to determine whether we should |
| 116 // use the hard or soft float ABI. |
| 117 #if defined(__ARM_PCS_VFP) |
| 118 hardfp_supported_ = true; |
| 119 #else |
| 120 hardfp_supported_ = false; |
| 121 #endif |
| 122 |
| 112 #if defined(DEBUG) | 123 #if defined(DEBUG) |
| 113 initialized_ = true; | 124 initialized_ = true; |
| 114 #endif | 125 #endif |
| 115 } | 126 } |
| 116 | 127 |
| 117 | 128 |
| 118 void HostCPUFeatures::Cleanup() { | 129 void HostCPUFeatures::Cleanup() { |
| 119 DEBUG_ASSERT(initialized_); | 130 DEBUG_ASSERT(initialized_); |
| 120 #if defined(DEBUG) | 131 #if defined(DEBUG) |
| 121 initialized_ = false; | 132 initialized_ = false; |
| 122 #endif | 133 #endif |
| 123 ASSERT(hardware_ != NULL); | 134 ASSERT(hardware_ != NULL); |
| 124 free(const_cast<char*>(hardware_)); | 135 free(const_cast<char*>(hardware_)); |
| 125 hardware_ = NULL; | 136 hardware_ = NULL; |
| 126 CpuInfo::Cleanup(); | 137 CpuInfo::Cleanup(); |
| 127 } | 138 } |
| 128 | 139 |
| 129 #else | 140 #else |
| 130 | 141 |
| 131 void HostCPUFeatures::InitOnce() { | 142 void HostCPUFeatures::InitOnce() { |
| 132 CpuInfo::InitOnce(); | 143 CpuInfo::InitOnce(); |
| 133 hardware_ = CpuInfo::GetCpuModel(); | 144 hardware_ = CpuInfo::GetCpuModel(); |
| 134 vfp_supported_ = FLAG_use_vfp; | 145 vfp_supported_ = FLAG_use_vfp; |
| 135 neon_supported_ = FLAG_use_vfp && FLAG_use_neon; | 146 neon_supported_ = FLAG_use_vfp && FLAG_use_neon; |
| 136 integer_division_supported_ = true; | 147 hardfp_supported_ = FLAG_sim_use_hardfp; |
| 137 if (FLAG_sim_use_armv5te) { | 148 if (FLAG_sim_use_armv5te) { |
| 138 arm_version_ = ARMv5TE; | 149 arm_version_ = ARMv5TE; |
| 150 integer_division_supported_ = false; |
| 139 } else if (FLAG_sim_use_armv6) { | 151 } else if (FLAG_sim_use_armv6) { |
| 140 arm_version_ = ARMv6; | 152 arm_version_ = ARMv6; |
| 153 integer_division_supported_ = true; |
| 141 } else if (FLAG_sim_use_armv7) { | 154 } else if (FLAG_sim_use_armv7) { |
| 142 arm_version_ = ARMv7; | 155 arm_version_ = ARMv7; |
| 156 integer_division_supported_ = true; |
| 143 } | 157 } |
| 144 #if defined(DEBUG) | 158 #if defined(DEBUG) |
| 145 initialized_ = true; | 159 initialized_ = true; |
| 146 #endif | 160 #endif |
| 147 } | 161 } |
| 148 | 162 |
| 149 | 163 |
| 150 void HostCPUFeatures::Cleanup() { | 164 void HostCPUFeatures::Cleanup() { |
| 151 DEBUG_ASSERT(initialized_); | 165 DEBUG_ASSERT(initialized_); |
| 152 #if defined(DEBUG) | 166 #if defined(DEBUG) |
| 153 initialized_ = false; | 167 initialized_ = false; |
| 154 #endif | 168 #endif |
| 155 ASSERT(hardware_ != NULL); | 169 ASSERT(hardware_ != NULL); |
| 156 free(const_cast<char*>(hardware_)); | 170 free(const_cast<char*>(hardware_)); |
| 157 hardware_ = NULL; | 171 hardware_ = NULL; |
| 158 CpuInfo::Cleanup(); | 172 CpuInfo::Cleanup(); |
| 159 } | 173 } |
| 160 #endif // defined(HOST_ARCH_ARM) | 174 #endif // defined(HOST_ARCH_ARM) |
| 161 | 175 |
| 162 } // namespace dart | 176 } // namespace dart |
| 163 | 177 |
| 164 #endif // defined TARGET_ARCH_ARM | 178 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |