Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant
4
7
8#include <assembler/MacroAssemblerCodeRef.h>
9
10#include <QtCore/qfile.h>
11#include <QtCore/qcoreapplication.h>
12
14
15namespace QV4 {
16
17void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
18{
19 // This implements writing of JIT'd addresses so that perf can find the
20 // symbol names.
21 //
22 // Perf expects the mapping to be in a certain place and have certain
23 // content, for more information, see:
24 // https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
25 static bool doProfile = !qEnvironmentVariableIsEmpty("QV4_PROFILE_WRITE_PERF_MAP");
26 if (Q_UNLIKELY(doProfile)) {
27 static QFile perfMapFile(QString::fromLatin1("/tmp/perf-%1.map")
28 .arg(QCoreApplication::applicationPid()));
29 static const bool isOpen = perfMapFile.open(QIODevice::WriteOnly);
30 if (!isOpen) {
31 qWarning("QV4::JIT::Assembler: Cannot write perf map file.");
32 doProfile = false;
33 } else {
34 const void *address = codeRef->code().executableAddress();
35 perfMapFile.write(QByteArray::number(reinterpret_cast<quintptr>(address), 16));
36 perfMapFile.putChar(' ');
37 perfMapFile.write(QByteArray::number(static_cast<qsizetype>(codeRef->size()), 16));
38 perfMapFile.putChar(' ');
39 perfMapFile.write(Function::prettyName(function, address).toUtf8());
40 perfMapFile.putChar('\n');
41 perfMapFile.flush();
42 }
43 }
44}
45
46void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
47{
48 Q_UNUSED(function);
49 Q_UNUSED(codeRef);
50
51 // It's not advisable to remove things from the perf map file, as it's primarily used to analyze
52 // a trace after the application has terminated. We want to know about all functions that were
53 // ever jitted then. If the memory ranges overlap, we will have a problem when analyzing the
54 // trace. The JIT should try to avoid this.
55}
56
58{
59 return 0;
60}
61
62} // QV4
63
64QT_END_NAMESPACE
Definition qjsvalue.h:23
size_t exceptionHandlerSize()
void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)