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 | 15 |
16 #if defined(HOST_ARCH_ARM) | 16 #if defined(HOST_ARCH_ARM) |
17 #include <sys/syscall.h> /* NOLINT */ | 17 #include <sys/syscall.h> /* NOLINT */ |
18 #include <unistd.h> /* NOLINT */ | 18 #include <unistd.h> /* NOLINT */ |
19 #endif | 19 #endif |
20 | 20 |
21 namespace dart { | 21 namespace dart { |
22 | 22 |
| 23 // TODO(zra): Add a target for ARMv6. |
| 24 #if defined(TARGET_ARCH_ARM_5TE) |
| 25 DEFINE_FLAG(bool, use_vfp, false, "Use vfp instructions if supported"); |
| 26 DEFINE_FLAG(bool, use_neon, false, "Use neon instructions if supported"); |
| 27 DEFINE_FLAG(bool, use_integer_division, false, |
| 28 "Use integer division instruction if supported"); |
| 29 #else |
23 DEFINE_FLAG(bool, use_vfp, true, "Use vfp instructions if supported"); | 30 DEFINE_FLAG(bool, use_vfp, true, "Use vfp instructions if supported"); |
24 DEFINE_FLAG(bool, use_neon, true, "Use neon instructions if supported"); | 31 DEFINE_FLAG(bool, use_neon, true, "Use neon instructions if supported"); |
| 32 DEFINE_FLAG(bool, use_integer_division, true, |
| 33 "Use integer division instruction if supported"); |
| 34 #endif |
| 35 |
25 #if !defined(HOST_ARCH_ARM) | 36 #if !defined(HOST_ARCH_ARM) |
26 DEFINE_FLAG(bool, sim_use_armv7, true, "Use all ARMv7 instructions"); | 37 #if defined(TARGET_ARCH_ARM_5TE) |
27 DEFINE_FLAG(bool, sim_use_armv5te, false, "Restrict to ARMv5TE instructions"); | |
28 DEFINE_FLAG(bool, sim_use_armv6, false, "Restrict to ARMv6 instructions"); | |
29 DEFINE_FLAG(bool, sim_use_hardfp, false, "Use the softfp ABI."); | 38 DEFINE_FLAG(bool, sim_use_hardfp, false, "Use the softfp ABI."); |
| 39 #else |
| 40 DEFINE_FLAG(bool, sim_use_hardfp, true, "Use the softfp ABI."); |
| 41 #endif |
30 #endif | 42 #endif |
31 | 43 |
32 void CPU::FlushICache(uword start, uword size) { | 44 void CPU::FlushICache(uword start, uword size) { |
33 #if defined(HOST_ARCH_ARM) | 45 #if defined(HOST_ARCH_ARM) |
34 // Nothing to do. Flushing no instructions. | 46 // Nothing to do. Flushing no instructions. |
35 if (size == 0) { | 47 if (size == 0) { |
36 return; | 48 return; |
37 } | 49 } |
38 | 50 |
39 // ARM recommends using the gcc intrinsic __clear_cache on Linux, and the | 51 // ARM recommends using the gcc intrinsic __clear_cache on Linux, and the |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 126 |
115 // Has floating point unit. | 127 // Has floating point unit. |
116 vfp_supported_ = | 128 vfp_supported_ = |
117 (CpuInfo::FieldContains(kCpuInfoFeatures, "vfp") || is_arm64) && | 129 (CpuInfo::FieldContains(kCpuInfoFeatures, "vfp") || is_arm64) && |
118 FLAG_use_vfp; | 130 FLAG_use_vfp; |
119 | 131 |
120 // Has integer division. | 132 // Has integer division. |
121 bool is_krait = CpuInfo::FieldContains(kCpuInfoHardware, "QCT APQ8064"); | 133 bool is_krait = CpuInfo::FieldContains(kCpuInfoHardware, "QCT APQ8064"); |
122 if (is_krait) { | 134 if (is_krait) { |
123 // Special case for Qualcomm Krait CPUs in Nexus 4 and 7. | 135 // Special case for Qualcomm Krait CPUs in Nexus 4 and 7. |
124 integer_division_supported_ = true; | 136 integer_division_supported_ = FLAG_use_integer_division; |
125 } else { | 137 } else { |
126 integer_division_supported_ = | 138 integer_division_supported_ = |
127 CpuInfo::FieldContains(kCpuInfoFeatures, "idiva") || is_arm64; | 139 (CpuInfo::FieldContains(kCpuInfoFeatures, "idiva") || is_arm64) && |
| 140 FLAG_use_integer_division; |
128 } | 141 } |
129 neon_supported_ = | 142 neon_supported_ = |
130 (CpuInfo::FieldContains(kCpuInfoFeatures, "neon") || is_arm64) && | 143 (CpuInfo::FieldContains(kCpuInfoFeatures, "neon") || is_arm64) && |
131 FLAG_use_vfp && FLAG_use_neon; | 144 FLAG_use_vfp && FLAG_use_neon; |
132 | 145 |
133 // Use the cross-compiler's predefined macros to determine whether we should | 146 // Use the cross-compiler's predefined macros to determine whether we should |
134 // use the hard or soft float ABI. | 147 // use the hard or soft float ABI. |
135 #if defined(__ARM_PCS_VFP) | 148 #if defined(__ARM_PCS_VFP) |
136 hardfp_supported_ = true; | 149 hardfp_supported_ = true; |
137 #else | 150 #else |
(...skipping 15 matching lines...) Expand all Loading... |
153 free(const_cast<char*>(hardware_)); | 166 free(const_cast<char*>(hardware_)); |
154 hardware_ = NULL; | 167 hardware_ = NULL; |
155 CpuInfo::Cleanup(); | 168 CpuInfo::Cleanup(); |
156 } | 169 } |
157 | 170 |
158 #else | 171 #else |
159 | 172 |
160 void HostCPUFeatures::InitOnce() { | 173 void HostCPUFeatures::InitOnce() { |
161 CpuInfo::InitOnce(); | 174 CpuInfo::InitOnce(); |
162 hardware_ = CpuInfo::GetCpuModel(); | 175 hardware_ = CpuInfo::GetCpuModel(); |
| 176 |
| 177 #if defined(TARGET_ARCH_ARM_5TE) |
| 178 arm_version_ = ARMv5TE; |
| 179 #else |
| 180 arm_version_ = ARMv7; |
| 181 #endif |
| 182 |
| 183 integer_division_supported_ = FLAG_use_integer_division; |
163 vfp_supported_ = FLAG_use_vfp; | 184 vfp_supported_ = FLAG_use_vfp; |
164 neon_supported_ = FLAG_use_vfp && FLAG_use_neon; | 185 neon_supported_ = FLAG_use_vfp && FLAG_use_neon; |
165 hardfp_supported_ = FLAG_sim_use_hardfp; | 186 hardfp_supported_ = FLAG_sim_use_hardfp; |
166 if (FLAG_sim_use_armv5te) { | |
167 arm_version_ = ARMv5TE; | |
168 integer_division_supported_ = false; | |
169 } else if (FLAG_sim_use_armv6) { | |
170 arm_version_ = ARMv6; | |
171 integer_division_supported_ = true; | |
172 } else if (FLAG_sim_use_armv7) { | |
173 arm_version_ = ARMv7; | |
174 integer_division_supported_ = true; | |
175 } | |
176 #if defined(DEBUG) | 187 #if defined(DEBUG) |
177 initialized_ = true; | 188 initialized_ = true; |
178 #endif | 189 #endif |
179 } | 190 } |
180 | 191 |
181 | 192 |
182 void HostCPUFeatures::Cleanup() { | 193 void HostCPUFeatures::Cleanup() { |
183 DEBUG_ASSERT(initialized_); | 194 DEBUG_ASSERT(initialized_); |
184 #if defined(DEBUG) | 195 #if defined(DEBUG) |
185 initialized_ = false; | 196 initialized_ = false; |
186 #endif | 197 #endif |
187 ASSERT(hardware_ != NULL); | 198 ASSERT(hardware_ != NULL); |
188 free(const_cast<char*>(hardware_)); | 199 free(const_cast<char*>(hardware_)); |
189 hardware_ = NULL; | 200 hardware_ = NULL; |
190 CpuInfo::Cleanup(); | 201 CpuInfo::Cleanup(); |
191 } | 202 } |
192 #endif // defined(HOST_ARCH_ARM) | 203 #endif // defined(HOST_ARCH_ARM) |
193 | 204 |
194 } // namespace dart | 205 } // namespace dart |
195 | 206 |
196 #endif // defined TARGET_ARCH_ARM | 207 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |