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
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
4#ifndef QV4EXECUTABLEALLOCATOR_H
5#define QV4EXECUTABLEALLOCATOR_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QMultiMap>
19#include <QHash>
20#include <QVector>
21#include <QByteArray>
22#include <QMutex>
23
24#include <QtQml/private/qtqmlglobal_p.h>
25
26namespace WTF {
27class PageAllocation;
28}
29
31
32namespace QV4 {
33
35{
36public:
37 struct ChunkOfPages;
38 struct Allocation;
39
42
43 Allocation *allocate(size_t size);
44 void free(Allocation *allocation);
45
47 {
49 : size(0)
50 , free(true)
51 {}
52
53 void *memoryStart() const;
54 size_t memorySize() const { return size; }
55
56 void *exceptionHandlerStart() const;
57 size_t exceptionHandlerSize() const;
58
59 void *codeStart() const;
60
61 void invalidate() { addr = 0; }
62 bool isValid() const { return addr != 0; }
63 void deallocate(ExecutableAllocator *allocator);
64
65 private:
66 ~Allocation() {}
67
68 friend class ExecutableAllocator;
69
70 Allocation *split(size_t dividingSize);
71 bool mergeNext(ExecutableAllocator *allocator);
72 bool mergePrevious(ExecutableAllocator *allocator);
73
74 quintptr addr = 0;
75 uint size : 31; // More than 2GB of function code? nah :)
76 uint free : 1;
77 Allocation *next = nullptr;
78 Allocation *prev = nullptr;
79 };
80
81 // for debugging / unit-testing
82 int freeAllocationCount() const { return freeAllocations.size(); }
83 int chunkCount() const { return chunks.size(); }
84
86 {
88
89 {}
91
92 WTF::PageAllocation *pages = nullptr;
93 Allocation *firstAllocation = nullptr;
94
95 bool contains(Allocation *alloc) const;
96 };
97
98 ChunkOfPages *chunkForAllocation(Allocation *allocation) const;
99
100private:
101 QMultiMap<size_t, Allocation*> freeAllocations;
102 QMap<quintptr, ChunkOfPages*> chunks;
103 mutable QMutex mutex;
104};
105
106}
107
109
110#endif // QV4EXECUTABLEALLOCATOR_H
\inmodule QtCore
Definition qmutex.h:281
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
size_t exceptionHandlerSize()
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum const void * addr
static void split(QT_FT_Vector *b)
std::unique_ptr< ThunkPool::ThunkAllocation > allocation
Definition qstdweb.cpp:276
#define Q_QML_AUTOTEST_EXPORT
size_t quintptr
Definition qtypes.h:167
unsigned int uint
Definition qtypes.h:34
QMutex mutex
[2]