Blame SOURCES/Do-not-make-lack-of-SSE2-support-on-x86-32-fatal.patch

ec9e11
From 4950c366b12265f1ea390a6feb8dbbd0d850d206 Mon Sep 17 00:00:00 2001
ec9e11
From: Guillem Jover <guillem@hadrons.org>
ec9e11
Date: Mon, 12 Oct 2015 01:45:37 +0200
ec9e11
Subject: [PATCH v2] Do not make lack of SSE2 support on x86-32 fatal
ec9e11
ec9e11
When an x86-32 CPU does not have SSE2 support (which is the case for
ec9e11
all AMD CPUs, and older Intel CPUs), fallback to use the interpreter,
ec9e11
otherwise use the JIT engine.
ec9e11
ec9e11
Even then, make the lack of SSE2 support on x86-32 fatal when trying
ec9e11
to instantiate a JIT engine, which does require it.
ec9e11
ec9e11
Refactor the required CPU support check into a new pair of privately
ec9e11
exported functions to avoid duplicating the logic, and do so in
ec9e11
functions instead of class members to avoid changing the class
ec9e11
signatures.
ec9e11
ec9e11
Version: 5.7.x
ec9e11
Bug-Debian: https://bugs.debian.org/792594
ec9e11
---
ec9e11
 src/qml/jit/qv4isel_masm.cpp    |  2 ++
ec9e11
 src/qml/jit/qv4isel_masm_p.h    | 18 ++++++++++++++++++
ec9e11
 src/qml/jsruntime/qv4engine.cpp |  1 +
ec9e11
 src/qml/qml/v8/qv8engine.cpp    |  7 -------
ec9e11
 tools/qmljs/qmljs.cpp           |  7 +++----
ec9e11
 5 files changed, 24 insertions(+), 11 deletions(-)
ec9e11
ec9e11
--- a/src/qml/jit/qv4isel_masm.cpp
ec9e11
+++ b/src/qml/jit/qv4isel_masm.cpp
ec9e11
@@ -72,6 +72,8 @@ InstructionSelection<JITAssembler>::Inst
ec9e11
     , compilationUnit(new CompilationUnit)
ec9e11
     , qmlEngine(qmlEngine)
ec9e11
 {
ec9e11
+    checkRequiredCpuSupport();
ec9e11
+
ec9e11
     compilationUnit->codeRefs.resize(module->functions.size());
ec9e11
     module->unitFlags |= QV4::CompiledData::Unit::ContainsMachineCode;
ec9e11
 }
ec9e11
--- a/src/qml/jit/qv4isel_masm_p.h
ec9e11
+++ b/src/qml/jit/qv4isel_masm_p.h
ec9e11
@@ -60,6 +60,7 @@
ec9e11
 
ec9e11
 #include <QtCore/QHash>
ec9e11
 #include <QtCore/QStack>
ec9e11
+#include <private/qsimd_p.h>
ec9e11
 #include <config.h>
ec9e11
 #include <wtf/Vector.h>
ec9e11
 
ec9e11
@@ -72,6 +73,23 @@ QT_BEGIN_NAMESPACE
ec9e11
 namespace QV4 {
ec9e11
 namespace JIT {
ec9e11
 
ec9e11
+Q_QML_PRIVATE_EXPORT inline bool hasRequiredCpuSupport()
ec9e11
+{
ec9e11
+#ifdef Q_PROCESSOR_X86_32
ec9e11
+    return qCpuHasFeature(SSE2);
ec9e11
+#else
ec9e11
+    return true;
ec9e11
+#endif
ec9e11
+}
ec9e11
+
ec9e11
+Q_QML_PRIVATE_EXPORT inline void checkRequiredCpuSupport()
ec9e11
+{
ec9e11
+#ifdef Q_PROCESSOR_X86_32
ec9e11
+    if (!qCpuHasFeature(SSE2))
ec9e11
+        qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer");
ec9e11
+#endif
ec9e11
+}
ec9e11
+
ec9e11
 template <typename JITAssembler = Assembler<DefaultAssemblerTargetConfiguration>>
ec9e11
 class Q_QML_EXPORT InstructionSelection:
ec9e11
         protected IR::IRDecoder,
ec9e11
--- a/src/qml/jsruntime/qv4engine.cpp
ec9e11
+++ b/src/qml/jsruntime/qv4engine.cpp
ec9e11
@@ -165,6 +165,7 @@ ExecutionEngine::ExecutionEngine(EvalISe
ec9e11
 
ec9e11
 #ifdef V4_ENABLE_JIT
ec9e11
         static const bool forceMoth = !qEnvironmentVariableIsEmpty("QV4_FORCE_INTERPRETER") ||
ec9e11
+                                      !JIT::hasRequiredCpuSupport() ||
ec9e11
                                       !OSAllocator::canAllocateExecutableMemory();
ec9e11
         if (forceMoth) {
ec9e11
             factory = new Moth::ISelFactory;
ec9e11
--- a/src/qml/qml/v8/qv8engine.cpp
ec9e11
+++ b/src/qml/qml/v8/qv8engine.cpp
ec9e11
@@ -64,7 +64,6 @@
ec9e11
 #include <QtCore/qjsonvalue.h>
ec9e11
 #include <QtCore/qdatetime.h>
ec9e11
 #include <QtCore/qdatastream.h>
ec9e11
-#include <private/qsimd_p.h>
ec9e11
 
ec9e11
 #include <private/qv4value_p.h>
ec9e11
 #include <private/qv4dateobject_p.h>
ec9e11
@@ -129,12 +128,6 @@ QV8Engine::QV8Engine(QJSEngine* qq)
ec9e11
     , m_xmlHttpRequestData(0)
ec9e11
     , m_listModelData(0)
ec9e11
 {
ec9e11
-#ifdef Q_PROCESSOR_X86_32
ec9e11
-    if (!qCpuHasFeature(SSE2)) {
ec9e11
-        qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer");
ec9e11
-    }
ec9e11
-#endif
ec9e11
-
ec9e11
     QML_MEMORY_SCOPE_STRING("QV8Engine::QV8Engine");
ec9e11
     qMetaTypeId<QJSValue>();
ec9e11
     qMetaTypeId<QList<int> >();
ec9e11
--- a/tools/qmljs/qmljs.cpp
ec9e11
+++ b/tools/qmljs/qmljs.cpp
ec9e11
@@ -92,11 +92,10 @@ int main(int argc, char *argv[])
ec9e11
     enum {
ec9e11
         use_masm,
ec9e11
         use_moth
ec9e11
-    } mode;
ec9e11
+    } mode = use_moth;
ec9e11
 #ifdef V4_ENABLE_JIT
ec9e11
-    mode = use_masm;
ec9e11
-#else
ec9e11
-    mode = use_moth;
ec9e11
+    if (QV4::JIT::hasRequiredCpuSupport())
ec9e11
+        mode = use_masm;
ec9e11
 #endif
ec9e11
 
ec9e11
     bool runAsQml = false;