Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: runtime/vm/cpu_arm.cc

Issue 120723003: Refactors CPU feature detection. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Cleanup Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 6
7 #if defined(TARGET_ARCH_ARM) 7 #if defined(TARGET_ARCH_ARM)
8 8
9 #include "vm/cpu.h"
10 #include "vm/cpuinfo.h"
11 #include "vm/simulator.h"
12
9 #if defined(HOST_ARCH_ARM) 13 #if defined(HOST_ARCH_ARM)
10 #include <sys/syscall.h> /* NOLINT */ 14 #include <sys/syscall.h> /* NOLINT */
11 #include <unistd.h> /* NOLINT */ 15 #include <unistd.h> /* NOLINT */
12 #endif 16 #endif
13 17
14 #include "vm/cpu.h"
15
16 namespace dart { 18 namespace dart {
17 19
18 void CPU::FlushICache(uword start, uword size) { 20 void CPU::FlushICache(uword start, uword size) {
19 #if defined(HOST_ARCH_ARM) 21 #if defined(HOST_ARCH_ARM)
20 // Nothing to do. Flushing no instructions. 22 // Nothing to do. Flushing no instructions.
21 if (size == 0) { 23 if (size == 0) {
22 return; 24 return;
23 } 25 }
24 26
25 // ARM recommends using the gcc intrinsic __clear_cache on Linux, and the 27 // ARM recommends using the gcc intrinsic __clear_cache on Linux, and the
(...skipping 15 matching lines...) Expand all
41 43
42 44
43 const char* CPU::Id() { 45 const char* CPU::Id() {
44 return 46 return
45 #if !defined(HOST_ARCH_ARM) 47 #if !defined(HOST_ARCH_ARM)
46 "sim" 48 "sim"
47 #endif // !defined(HOST_ARCH_ARM) 49 #endif // !defined(HOST_ARCH_ARM)
48 "arm"; 50 "arm";
49 } 51 }
50 52
53
54 bool CPUFeatures::integer_division_supported_ = false;
55 bool CPUFeatures::neon_supported_ = false;
56 char CPUFeatures::hardware_[HARDWARE_LEN] = {0};
57 #if defined(DEBUG)
58 bool CPUFeatures::initialized_ = false;
59 #endif
60
61
62 bool CPUFeatures::integer_division_supported() {
63 DEBUG_ASSERT(initialized_);
64 return integer_division_supported_;
65 }
66
67
68 bool CPUFeatures::neon_supported() {
69 DEBUG_ASSERT(initialized_);
70 return neon_supported_;
71 }
72
73
74 char* CPUFeatures::hardware() {
75 DEBUG_ASSERT(initialized_);
76 return hardware_;
77 }
78
79 // If we are using the simulator, allow tests to enable/disable support for
80 // integer division.
81 #if defined(USING_SIMULATOR)
82 void CPUFeatures::set_integer_division_supported(bool supported) {
83 integer_division_supported_ = supported;
84 }
85
86
87 void CPUFeatures::set_neon_supported(bool supported) {
88 neon_supported_ = supported;
89 }
90 #endif
91
92
93 void CPUFeatures::InitOnce() {
94 CpuInfo::Read();
95 CpuInfo::GetCpuModel(hardware_, HARDWARE_LEN);
96 #if defined(USING_SIMULATOR)
97 integer_division_supported_ = true;
98 neon_supported_ = true;
99 #else
100 ASSERT(CpuInfo::FieldContains("Processor", "ARMv7")); // Implements ARMv7.
101 // Has floating point unit.
102 ASSERT(CpuInfo::FieldContains("Features", "vfp"));
103 // Has integer division.
104 if (CpuInfo::FieldContains("Hardware", "QCT APQ8064")) {
105 // Special case for Qualcomm Krait CPUs in Nexus 4 and 7.
106 integer_division_supported_ = true;
107 } else {
108 integer_division_supported_ = CpuInfo::FieldContains("Features", "idiva");
109 }
110 neon_supported_ = CpuInfo::FieldContains("Features", "neon");
111 #endif // defined(USING_SIMULATOR)
112 #if defined(DEBUG)
113 initialized_ = true;
114 #endif
115 }
116
117
51 } // namespace dart 118 } // namespace dart
52 119
53 #endif // defined TARGET_ARCH_ARM 120 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/cpu_arm.h ('k') | runtime/vm/cpu_ia32.h » ('j') | runtime/vm/cpu_ia32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698