Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qv4functiontable_unix.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qv4function_p.h"
6
7#include <assembler/MacroAssemblerCodeRef.h>
8
9#include <QtCore/qfile.h>
10#include <QtCore/qcoreapplication.h>
11
13
14namespace QV4 {
15
16void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
17{
18 // This implements writing of JIT'd addresses so that perf can find the
19 // symbol names.
20 //
21 // Perf expects the mapping to be in a certain place and have certain
22 // content, for more information, see:
23 // https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
24 static bool doProfile = !qEnvironmentVariableIsEmpty("QV4_PROFILE_WRITE_PERF_MAP");
25 if (Q_UNLIKELY(doProfile)) {
26 static QFile perfMapFile(QString::fromLatin1("/tmp/perf-%1.map")
28 static const bool isOpen = perfMapFile.open(QIODevice::WriteOnly);
29 if (!isOpen) {
30 qWarning("QV4::JIT::Assembler: Cannot write perf map file.");
31 doProfile = false;
32 } else {
33 const void *address = codeRef->code().executableAddress();
34 perfMapFile.write(QByteArray::number(reinterpret_cast<quintptr>(address), 16));
35 perfMapFile.putChar(' ');
36 perfMapFile.write(QByteArray::number(static_cast<qsizetype>(codeRef->size()), 16));
37 perfMapFile.putChar(' ');
38 perfMapFile.write(Function::prettyName(function, address).toUtf8());
39 perfMapFile.putChar('\n');
40 perfMapFile.flush();
41 }
42 }
43}
44
45void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
46{
47 Q_UNUSED(function);
48 Q_UNUSED(codeRef);
49
50 // It's not advisable to remove things from the perf map file, as it's primarily used to analyze
51 // a trace after the application has terminated. We want to know about all functions that were
52 // ever jitted then. If the memory ranges overlap, we will have a problem when analyzing the
53 // trace. The JIT should try to avoid this.
54}
55
57{
58 return 0;
59}
60
61} // QV4
62
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
static qint64 applicationPid() Q_DECL_CONST_FUNCTION
\inmodule QtCore
Definition qfile.h:93
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
Combined button and popup list for selecting options.
int toUtf8(char16_t u, OutputPtr &dst, InputPtr &src, InputPtr end)
size_t exceptionHandlerSize()
void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
#define Q_UNLIKELY(x)
#define qWarning
Definition qlogging.h:166
GLuint GLuint64EXT address
SSL_CTX int void * arg
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
#define Q_UNUSED(x)
size_t quintptr
Definition qtypes.h:167
ptrdiff_t qsizetype
Definition qtypes.h:165
static QString prettyName(const Function *function, const void *address)