aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit/qv4assemblercommon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jit/qv4assemblercommon.cpp')
-rw-r--r--src/qml/jit/qv4assemblercommon.cpp78
1 files changed, 29 insertions, 49 deletions
diff --git a/src/qml/jit/qv4assemblercommon.cpp b/src/qml/jit/qv4assemblercommon.cpp
index e75f35a665..2b33d0aa10 100644
--- a/src/qml/jit/qv4assemblercommon.cpp
+++ b/src/qml/jit/qv4assemblercommon.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QBuffer>
#include <QFile>
@@ -51,13 +15,15 @@
#include <assembler/LinkBuffer.h>
#include <WTFStubs.h>
+#if QT_CONFIG(qml_jit)
+
#undef ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES
QT_BEGIN_NAMESPACE
namespace QV4 {
namespace JIT {
-Q_LOGGING_CATEGORY(lcAsm, "qt.v4.asm")
+Q_LOGGING_CATEGORY(lcAsm, "qt.qml.v4.asm")
namespace {
class QIODevicePrintStream: public FilePrintStream
@@ -76,15 +42,25 @@ public:
~QIODevicePrintStream()
{}
- void vprintf(const char* format, va_list argList) WTF_ATTRIBUTE_PRINTF(2, 0)
+ void vprintf(const char* format, va_list argList) override WTF_ATTRIBUTE_PRINTF(2, 0)
{
- const int written = qvsnprintf(buf.data(), buf.size(), format, argList);
- if (written > 0)
- dest->write(buf.constData(), written);
- memset(buf.data(), 0, qMin(written, buf.size()));
+ const int printed = qvsnprintf(buf.data(), buf.size(), format, argList);
+ Q_ASSERT(printed <= buf.size());
+
+ qint64 written = 0;
+ while (written < printed) {
+ const qint64 result = dest->write(buf.constData() + written, printed - written);
+ if (result < 0)
+ break;
+ written += result;
+ }
+
+ Q_ASSERT(written <= buf.size());
+ Q_ASSERT(written >= 0);
+ memset(buf.data(), 0, size_t(written));
}
- void flush()
+ void flush() override
{}
private:
@@ -110,7 +86,8 @@ static void printDisassembledOutputWithCalls(QByteArray processedOutput,
break;
const char *functionName = it.value();
processedOutput = processedOutput.insert(
- idx, padding + QByteArray(functionName ? functionName : symbols[it.key()]));
+ idx, QByteArray(padding + QByteArray(
+ functionName ? functionName : symbols[it.key()])));
}
}
@@ -146,7 +123,7 @@ void PlatformAssemblerCommon::link(Function *function, const char *jitKind)
// We use debugAddress here because it's actually for debugging and hidden behind an
// environment variable.
const QByteArray name = Function::prettyName(function, linkBuffer.debugAddress()).toUtf8();
- codeRef = linkBuffer.finalizeCodeWithDisassembly(jitKind, "function %s", name.constData());
+ codeRef = linkBuffer.finalizeCodeWithDisassembly(jitKind, name.constData());
WTF::setDataFile(stderr);
printDisassembledOutputWithCalls(buf.data(), functions);
@@ -159,7 +136,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)
@@ -177,7 +155,7 @@ void PlatformAssemblerCommon::prepareCallWithArgCount(int argc)
void PlatformAssemblerCommon::storeInstructionPointer(int instructionOffset)
{
- Address addr(CppStackFrameRegister, offsetof(QV4::CppStackFrame, instructionPointer));
+ Address addr(CppStackFrameRegister, offsetof(QV4::JSTypesStackFrame, instructionPointer));
store32(TrustedImm32(instructionOffset), addr);
}
@@ -369,3 +347,5 @@ void PlatformAssemblerCommon::storeInt32AsValue(int srcInt, Address destAddr)
} // QV4 namepsace
QT_END_NAMESPACE
+
+#endif // QT_CONFIG(qml_jit)