Revision: 5751
Author: [email protected]
Date: Tue Nov 2 01:26:33 2010
Log: Landing for Rodolph Perfetta.
Improve V8 VFPv3 runtime detection, to address issue 914.
This patch will check for the exact word vfpv3 as well as 0xc08 (CortexA8
part number) as some earlier kernel didn't report vfpv3 for A8.
Codereview URL: http://codereview.chromium.org/4103013/show
http://code.google.com/p/v8/source/detail?r=5751
Modified:
/branches/bleeding_edge/src/platform-linux.cc
=======================================
--- /branches/bleeding_edge/src/platform-linux.cc Wed Oct 27 05:45:46 2010
+++ /branches/bleeding_edge/src/platform-linux.cc Tue Nov 2 01:26:33 2010
@@ -99,30 +99,12 @@
#ifdef __arm__
-bool OS::ArmCpuHasFeature(CpuFeature feature) {
- const char* search_string = NULL;
+static bool CPUInfoContainsString(const char * search_string) {
const char* file_name = "/proc/cpuinfo";
- // Simple detection of VFP at runtime for Linux.
- // It is based on /proc/cpuinfo, which reveals hardware configuration
- // to user-space applications. According to ARM (mid 2009), no similar
- // facility is universally available on the ARM architectures,
- // so it's up to individual OSes to provide such.
- //
// This is written as a straight shot one pass parser
// and not using STL string and ifstream because,
// on Linux, it's reading from a (non-mmap-able)
// character special device.
- switch (feature) {
- case VFP3:
- search_string = "vfp";
- break;
- case ARMv7:
- search_string = "ARMv7";
- break;
- default:
- UNREACHABLE();
- }
-
FILE* f = NULL;
const char* what = search_string;
@@ -149,6 +131,43 @@
// Did not find string in the proc file.
return false;
}
+
+bool OS::ArmCpuHasFeature(CpuFeature feature) {
+ const int max_items = 2;
+ const char* search_strings[max_items] = { NULL, NULL };
+ int search_items = 0;
+ // Simple detection of VFP at runtime for Linux.
+ // It is based on /proc/cpuinfo, which reveals hardware configuration
+ // to user-space applications. According to ARM (mid 2009), no similar
+ // facility is universally available on the ARM architectures,
+ // so it's up to individual OSes to provide such.
+ switch (feature) {
+ case VFP3:
+ search_strings[0] = "vfpv3";
+ // Some old kernels will report vfp for A8, not vfpv3, so we check
for
+ // A8 explicitely. The cpuinfo file report the CPU Part which for
Cortex
+ // A8 is 0xc08.
+ search_strings[1] = "0xc08";
+ search_items = 2;
+ ASSERT(search_items <= max_items);
+ break;
+ case ARMv7:
+ search_strings[0] = "ARMv7" ;
+ search_items = 1;
+ ASSERT(search_items <= max_items);
+ break;
+ default:
+ UNREACHABLE();
+ }
+
+ for (int i = 0; i < search_items; ++i) {
+ if (CPUInfoContainsString(search_strings[i])) {
+ return true;
+ }
+ }
+
+ return false;
+}
#endif // def __arm__
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev