Do not make lack of SSE2 support on x86-32 fatal
authorGuillem Jover <guillem@hadrons.org>
Sun, 11 Oct 2015 23:45:37 +0000 (01:45 +0200)
committerLisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
Mon, 2 Jan 2017 15:15:42 +0000 (15:15 +0000)
When an x86-32 CPU does not have SSE2 support (which is the case for
all AMD CPUs, and older Intel CPUs), fallback to use the interpreter,
otherwise use the JIT engine.

Even then, make the lack of SSE2 support on x86-32 fatal when trying
to instantiate a JIT engine, which does require it.

Refactor the required CPU support check into a new pair of privately
exported functions to avoid duplicating the logic, and do so in
functions instead of class members to avoid changing the class
signatures.

Version: 5.7.x
Bug-Debian: https://bugs.debian.org/792594

Gbp-Pq: Name Do-not-make-lack-of-SSE2-support-on-x86-32-fatal.patch

src/qml/jit/qv4isel_masm.cpp
src/qml/jit/qv4isel_masm_p.h
src/qml/jsruntime/qv4engine.cpp
src/qml/qml/v8/qv8engine.cpp
tools/qmljs/qmljs.cpp

index 859ecfbe64d8734133549bba8c114aa55e72bbda..a9e2558f6e83c8b558e8bf9cb6cfd6d5c3f942ae 100644 (file)
@@ -265,6 +265,8 @@ InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::Ex
     , compilationUnit(new CompilationUnit)
     , qmlEngine(qmlEngine)
 {
+    checkRequiredCpuSupport();
+
     compilationUnit->codeRefs.resize(module->functions.size());
 }
 
index 1e6ac1f51c355182a95d76bec10154e443c0746f..d6c1b414fb589b03a39d318d6f0629f3a2b12469 100644 (file)
@@ -59,6 +59,7 @@
 
 #include <QtCore/QHash>
 #include <QtCore/QStack>
+#include <private/qsimd_p.h>
 #include <config.h>
 #include <wtf/Vector.h>
 
@@ -71,6 +72,23 @@ QT_BEGIN_NAMESPACE
 namespace QV4 {
 namespace JIT {
 
+Q_QML_PRIVATE_EXPORT inline bool hasRequiredCpuSupport()
+{
+#ifdef Q_PROCESSOR_X86_32
+    return qCpuHasFeature(SSE2);
+#else
+    return true;
+#endif
+}
+
+Q_QML_PRIVATE_EXPORT inline void checkRequiredCpuSupport()
+{
+#ifdef Q_PROCESSOR_X86_32
+    if (!qCpuHasFeature(SSE2))
+        qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer");
+#endif
+}
+
 class Q_QML_EXPORT InstructionSelection:
         protected IR::IRDecoder,
         public EvalInstructionSelection
index 26f473a7aa04702b50414cb7255f5fff97b469aa..5e4100ac031e5a596f1c157c3fbecb6f4ca6da54 100644 (file)
@@ -162,6 +162,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
 
 #ifdef V4_ENABLE_JIT
         static const bool forceMoth = !qEnvironmentVariableIsEmpty("QV4_FORCE_INTERPRETER") ||
+                                      !JIT::hasRequiredCpuSupport() ||
                                       !OSAllocator::canAllocateExecutableMemory();
         if (forceMoth) {
             factory = new Moth::ISelFactory;
index 46fd4fbbeb00f3fae8c995704bace8538689cc01..20ed1ddb4b9f339bc01208006fe68d8d761a3438 100644 (file)
@@ -65,7 +65,6 @@
 #include <QtCore/qjsonvalue.h>
 #include <QtCore/qdatetime.h>
 #include <QtCore/qdatastream.h>
-#include <private/qsimd_p.h>
 
 #include <private/qv4value_p.h>
 #include <private/qv4dateobject_p.h>
@@ -130,12 +129,6 @@ QV8Engine::QV8Engine(QJSEngine* qq)
     , m_xmlHttpRequestData(0)
     , m_listModelData(0)
 {
-#ifdef Q_PROCESSOR_X86_32
-    if (!qCpuHasFeature(SSE2)) {
-        qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer");
-    }
-#endif
-
     QML_MEMORY_SCOPE_STRING("QV8Engine::QV8Engine");
     qMetaTypeId<QJSValue>();
     qMetaTypeId<QList<int> >();
index 68aa52ce912c474eb60d6356475dad83f91b75bd..94b10f2b39fe1d701d99a82db07a1007e3edc021 100644 (file)
@@ -135,11 +135,10 @@ int main(int argc, char *argv[])
     enum {
         use_masm,
         use_moth
-    } mode;
+    } mode = use_moth;
 #ifdef V4_ENABLE_JIT
-    mode = use_masm;
-#else
-    mode = use_moth;
+    if (QV4::JIT::hasRequiredCpuSupport())
+        mode = use_masm;
 #endif
 
     bool runAsQml = false;