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

Unified Diff: src/platform-linux.cc

Issue 6905098: ARM: Support hardfloat in SCons build and make it a build time setting (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added CAN_USE_VFP_INSTRUCTIONS when hardfloat is used Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform.h ('k') | src/platform-nullos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index 1ecd8fc81b08b05a7dad8f2495255ec37db95091..d857cd90590dd74db84a6df1bebc2bffad42f930 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -87,6 +87,25 @@ void OS::Setup() {
uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
srandom(static_cast<unsigned int>(seed));
limit_mutex = CreateMutex();
+
+#ifdef __arm__
+ // When running on ARM hardware check that the EABI used by V8 and
+ // by the C code is the same.
+ bool hard_float = OS::ArmUsingHardFloat();
+ if (hard_float) {
+#if !USE_EABI_HARDFLOAT
+ PrintF("ERROR: Binary compiled with -mfloat-abi=hard but without "
+ "-DUSE_EABI_HARDFLOAT\n");
+ exit(1);
+#endif
+ } else {
+#if USE_EABI_HARDFLOAT
+ PrintF("ERROR: Binary not compiled with -mfloat-abi=hard but with "
+ "-DUSE_EABI_HARDFLOAT\n");
+ exit(1);
+#endif
+ }
+#endif
}
@@ -142,6 +161,7 @@ static bool CPUInfoContainsString(const char * search_string) {
return false;
}
+
bool OS::ArmCpuHasFeature(CpuFeature feature) {
const char* search_string = NULL;
// Simple detection of VFP at runtime for Linux.
@@ -177,6 +197,28 @@ bool OS::ArmCpuHasFeature(CpuFeature feature) {
return false;
}
+
+
+// Simple helper function to detect whether the C code is compiled with
+// option -mfloat-abi=hard. The register d0 is loaded with 1.0 and the register
+// pair r0, r1 is loaded with 0.0. If -mfloat-abi=hard is pased to GCC then
+// calling this will return 1.0 and otherwise 0.0.
+static void ArmUsingHardFloatHelper() {
+ asm("mov r0, #0");
+ asm("mov r1, #0");
+ asm("movt r1, #16368");
+ asm("vmov d0, r0, r1");
+ asm("mov r0, #0");
+ asm("mov r1, #0");
+}
+
+
+bool OS::ArmUsingHardFloat() {
+ // Cast helper function from returning void to returning double.
+ typedef double (*F)();
+ F f = FUNCTION_CAST<F>(FUNCTION_ADDR(ArmUsingHardFloatHelper));
+ return f() == 1.0;
+}
#endif // def __arm__
« no previous file with comments | « src/platform.h ('k') | src/platform-nullos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698