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

Unified 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 7 years 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/cpu_arm.cc
===================================================================
--- runtime/vm/cpu_arm.cc (revision 31402)
+++ runtime/vm/cpu_arm.cc (working copy)
@@ -6,13 +6,15 @@
#if defined(TARGET_ARCH_ARM)
+#include "vm/cpu.h"
+#include "vm/cpuinfo.h"
+#include "vm/simulator.h"
+
#if defined(HOST_ARCH_ARM)
#include <sys/syscall.h> /* NOLINT */
#include <unistd.h> /* NOLINT */
#endif
-#include "vm/cpu.h"
-
namespace dart {
void CPU::FlushICache(uword start, uword size) {
@@ -48,6 +50,71 @@
"arm";
}
+
+bool CPUFeatures::integer_division_supported_ = false;
+bool CPUFeatures::neon_supported_ = false;
+char CPUFeatures::hardware_[HARDWARE_LEN] = {0};
+#if defined(DEBUG)
+bool CPUFeatures::initialized_ = false;
+#endif
+
+
+bool CPUFeatures::integer_division_supported() {
+ DEBUG_ASSERT(initialized_);
+ return integer_division_supported_;
+}
+
+
+bool CPUFeatures::neon_supported() {
+ DEBUG_ASSERT(initialized_);
+ return neon_supported_;
+}
+
+
+char* CPUFeatures::hardware() {
+ DEBUG_ASSERT(initialized_);
+ return hardware_;
+}
+
+// If we are using the simulator, allow tests to enable/disable support for
+// integer division.
+#if defined(USING_SIMULATOR)
+void CPUFeatures::set_integer_division_supported(bool supported) {
+ integer_division_supported_ = supported;
+}
+
+
+void CPUFeatures::set_neon_supported(bool supported) {
+ neon_supported_ = supported;
+}
+#endif
+
+
+void CPUFeatures::InitOnce() {
+ CpuInfo::Read();
+ CpuInfo::GetCpuModel(hardware_, HARDWARE_LEN);
+#if defined(USING_SIMULATOR)
+ integer_division_supported_ = true;
+ neon_supported_ = true;
+#else
+ ASSERT(CpuInfo::FieldContains("Processor", "ARMv7")); // Implements ARMv7.
+ // Has floating point unit.
+ ASSERT(CpuInfo::FieldContains("Features", "vfp"));
+ // Has integer division.
+ if (CpuInfo::FieldContains("Hardware", "QCT APQ8064")) {
+ // Special case for Qualcomm Krait CPUs in Nexus 4 and 7.
+ integer_division_supported_ = true;
+ } else {
+ integer_division_supported_ = CpuInfo::FieldContains("Features", "idiva");
+ }
+ neon_supported_ = CpuInfo::FieldContains("Features", "neon");
+#endif // defined(USING_SIMULATOR)
+#if defined(DEBUG)
+ initialized_ = true;
+#endif
+}
+
+
} // namespace dart
#endif // defined TARGET_ARCH_ARM
« 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