Bug 601222: Blacklist JITs on samsung i9000s. r=dvander a=blocking-fennec GECKO20b7pre_20100929_RELBRANCH FENNEC_4_0b1_BUILD1
authorChris Jones <jones.chris.g@gmail.com>
Fri, 01 Oct 2010 03:45:27 -0500
branchGECKO20b7pre_20100929_RELBRANCH
changeset 54882 4791cfde3ca0fe93f58783ac7769b601fd4798a3
parent 54874 e82996480172cb3b7d4adf373a7743518823b4b9
child 54885 0daed705a12c554cea02ef531a456a3b351efa96
push idunknown
push userunknown
push dateunknown
reviewersdvander, blocking-fennec
bugs601222
milestone2.0b7pre
Bug 601222: Blacklist JITs on samsung i9000s. r=dvander a=blocking-fennec
js/src/jscntxt.cpp
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -40,16 +40,20 @@
 
 /*
  * JS execution context.
  */
 #include <new>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef ANDROID
+# include <fstream>
+# include <string>
+#endif  // ANDROID
 
 #include "jsstdint.h"
 
 #include "jstypes.h"
 #include "jsarena.h" /* Added by JSIFY */
 #include "jsutil.h" /* Added by JSIFY */
 #include "jsclist.h"
 #include "jsprf.h"
@@ -2197,27 +2201,77 @@ FreeOldArenas(JSRuntime *rt, JSArenaPool
 }
 
 void
 JSContext::purge()
 {
     FreeOldArenas(runtime, &regExpPool);
 }
 
+static bool
+ComputeIsJITBroken()
+{
+#ifndef ANDROID
+    return false;
+#else  // ANDROID
+    if (getenv("JS_IGNORE_JIT_BROKENNESS")) {
+        return false;
+    }
+
+    bool broken = false;
+    std::string line;
+    std::ifstream cpuinfo("/proc/cpuinfo");
+    do {
+        if (0 == line.find("Hardware")) {
+            const char* blacklist[] = {
+                "SGH-T959",     // Samsung i9000, Vibrant device
+                "SGH-I897",     // Samsung i9000, Captivate device
+                "SCH-I500",     // Samsung i9000, Fascinate device
+                "SPH-D700",     // Samsung i9000, Epic device
+                NULL
+            };
+            for (const char* hw = blacklist[0]; hw; ++hw) {
+                if (line.npos != line.find(hw)) {
+                    broken = true;
+                    break;
+                }
+            }
+            break;
+        }
+        std::getline(cpuinfo, line);
+    } while(!cpuinfo.fail() && !cpuinfo.eof());
+    return broken;
+#endif  // ifndef ANDROID
+}
+
+static bool
+IsJITBrokenHere()
+{
+    static bool computedIsBroken = false;
+    static bool isBroken = false;
+    if (!computedIsBroken) {
+        isBroken = ComputeIsJITBroken();
+        computedIsBroken = true;
+    }
+    return isBroken;
+}
+
 void
 JSContext::updateJITEnabled()
 {
 #ifdef JS_TRACER
     traceJitEnabled = ((options & JSOPTION_JIT) &&
+                       !IsJITBrokenHere() &&
                        (debugHooks == &js_NullDebugHooks ||
                         (debugHooks == &runtime->globalDebugHooks &&
                          !runtime->debuggerInhibitsJIT())));
 #endif
 #ifdef JS_METHODJIT
-    methodJitEnabled = (options & JSOPTION_METHODJIT)
+    methodJitEnabled = (options & JSOPTION_METHODJIT) &&
+                       !IsJITBrokenHere()
 # ifdef JS_CPU_X86
                        && JSC::MacroAssemblerX86Common::getSSEState() >=
                           JSC::MacroAssemblerX86Common::HasSSE2
 # endif
                         ;
 #endif
 }