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
qv4executableallocator_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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
5#ifndef QV4EXECUTABLEALLOCATOR_H
6#define QV4EXECUTABLEALLOCATOR_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QMultiMap>
20#include <QHash>
21#include <QVector>
22#include <QByteArray>
23#include <QMutex>
24
25#include <QtQml/private/qtqmlglobal_p.h>
26
27namespace WTF {
28class PageAllocation;
29}
30
31QT_BEGIN_NAMESPACE
32
33namespace QV4 {
34
35class Q_QML_AUTOTEST_EXPORT ExecutableAllocator
36{
37public:
38 struct ChunkOfPages;
39 struct Allocation;
40
43
46
48 {
50 : size(0)
51 , free(true)
52 {}
53
54 void *memoryStart() const;
55 size_t memorySize() const { return size; }
56
57 void *exceptionHandlerStart() const;
59
60 void *codeStart() const;
61
62 void invalidate() { addr = 0; }
63 bool isValid() const { return addr != 0; }
65
66 private:
67 ~Allocation() {}
68
69 friend class ExecutableAllocator;
70
74
75 quintptr addr = 0;
76 uint size : 31; // More than 2GB of function code? nah :)
77 uint free : 1;
78 Allocation *next = nullptr;
79 Allocation *prev = nullptr;
80 };
81
82 // for debugging / unit-testing
83 int freeAllocationCount() const { return freeAllocations.size(); }
84 int chunkCount() const { return chunks.size(); }
85
87 {
89
90 {}
91 ~ChunkOfPages();
92
95
96 bool contains(Allocation *alloc) const;
97 };
98
100
101private:
104 mutable QMutex mutex;
105};
106
107}
108
109QT_END_NAMESPACE
110
111#endif // QV4EXECUTABLEALLOCATOR_H
Definition qjsvalue.h:23