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