aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-11 11:33:26 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-12 10:09:53 +0100
commit131e2c81d40e3d324c62e113749a08e7993d008f (patch)
treeb8bb24c8a189cba4ef4a46d5eb5c810b7905f51c /src/qml
parent8dbe5b2be4e65e96013651f1ffee1cc26dd1ead1 (diff)
masm: Add error handling for failed mprotect()
If we cannot mprotect() we have to abort the JIT compilation. Delete RepatchBuffer.h as it is unfixable in that regard. Luckily we don't use it. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: Ic5ddbdf51b471db4ddeaa75aab48b24c1f7ced56 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/.prev_CMakeLists.txt1
-rw-r--r--src/qml/CMakeLists.txt1
-rw-r--r--src/qml/jit/qv4assemblercommon.cpp3
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp5
4 files changed, 6 insertions, 4 deletions
diff --git a/src/qml/.prev_CMakeLists.txt b/src/qml/.prev_CMakeLists.txt
index 93f1a9d50b..ff158bf2ee 100644
--- a/src/qml/.prev_CMakeLists.txt
+++ b/src/qml/.prev_CMakeLists.txt
@@ -24,7 +24,6 @@ qt_internal_add_module(Qml
../3rdparty/masm/assembler/MacroAssemblerX86.h
../3rdparty/masm/assembler/MacroAssemblerX86Common.h
../3rdparty/masm/assembler/MacroAssemblerX86_64.h
- ../3rdparty/masm/assembler/RepatchBuffer.h
../3rdparty/masm/assembler/X86Assembler.h
../3rdparty/masm/disassembler/ARM64/A64DOpcode.cpp ../3rdparty/masm/disassembler/ARM64/A64DOpcode.h
../3rdparty/masm/disassembler/ARM64Disassembler.cpp
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 6407c90b21..385b9d923d 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -24,7 +24,6 @@ qt_internal_add_module(Qml
../3rdparty/masm/assembler/MacroAssemblerX86.h
../3rdparty/masm/assembler/MacroAssemblerX86Common.h
../3rdparty/masm/assembler/MacroAssemblerX86_64.h
- ../3rdparty/masm/assembler/RepatchBuffer.h
../3rdparty/masm/assembler/X86Assembler.h
../3rdparty/masm/assembler/ARMv7Assembler.cpp
../3rdparty/masm/disassembler/ARM64/A64DOpcode.cpp ../3rdparty/masm/disassembler/ARM64/A64DOpcode.h
diff --git a/src/qml/jit/qv4assemblercommon.cpp b/src/qml/jit/qv4assemblercommon.cpp
index 137a04cc10..9cf118e04b 100644
--- a/src/qml/jit/qv4assemblercommon.cpp
+++ b/src/qml/jit/qv4assemblercommon.cpp
@@ -160,7 +160,8 @@ void PlatformAssemblerCommon::link(Function *function, const char *jitKind)
generateFunctionTable(function, &codeRef);
- linkBuffer.makeExecutable();
+ if (Q_UNLIKELY(!linkBuffer.makeExecutable()))
+ function->jittedCode = nullptr; // The function is not executable, but the coderef exists.
}
void PlatformAssemblerCommon::prepareCallWithArgCount(int argc)
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index bea301c6e3..03cb69490e 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -444,7 +444,10 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
#if QT_CONFIG(qml_jit)
if (debugger == nullptr) {
- if (function->jittedCode == nullptr) {
+ // Check for codeRef here. In rare cases the JIT compilation may fail, which leaves us
+ // with a (useless) codeRef, but no jittedCode. In that case, don't try to JIT again every
+ // time we execute the function, but just interpret instead.
+ if (function->codeRef == nullptr) {
if (engine->canJIT(function))
QV4::JIT::BaselineJIT(function).generate();
else