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
27
namespace
WTF
{
28
class
PageAllocation;
29
}
30
31
QT_BEGIN_NAMESPACE
32
33
namespace
QV4
{
34
35
class
Q_QML_AUTOTEST_EXPORT
ExecutableAllocator
36
{
37
public
:
38
struct
ChunkOfPages
;
39
struct
Allocation
;
40
41
ExecutableAllocator
();
42
~
ExecutableAllocator
();
43
44
Allocation
*
allocate
(
size_t
size
);
45
void
free
(
Allocation
*
allocation
);
46
47
struct
Allocation
48
{
49
Allocation
()
50
:
size
(0)
51
,
free
(
true
)
52
{}
53
54
void
*
memoryStart
()
const
;
55
size_t
memorySize
()
const
{
return
size
; }
56
57
void
*
exceptionHandlerStart
()
const
;
58
size_t
exceptionHandlerSize
()
const
;
59
60
void
*
codeStart
()
const
;
61
62
void
invalidate
() {
addr
= 0; }
63
bool
isValid
()
const
{
return
addr
!= 0; }
64
void
deallocate
(
ExecutableAllocator
*
allocator
);
65
66
private
:
67
~
Allocation
() {}
68
69
friend
class
ExecutableAllocator
;
70
71
Allocation
*
split
(
size_t
dividingSize
);
72
bool
mergeNext
(
ExecutableAllocator
*
allocator
);
73
bool
mergePrevious
(
ExecutableAllocator
*
allocator
);
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
86
struct
ChunkOfPages
87
{
88
ChunkOfPages
()
89
90
{}
91
~
ChunkOfPages
();
92
93
WTF
::
PageAllocation
*
pages
=
nullptr
;
94
Allocation
*
firstAllocation
=
nullptr
;
95
96
bool
contains
(
Allocation
*
alloc
)
const
;
97
};
98
99
ChunkOfPages
*
chunkForAllocation
(
Allocation
*
allocation
)
const
;
100
101
private
:
102
QMultiMap
<
size_t
,
Allocation
*>
freeAllocations
;
103
QMap
<
quintptr
,
ChunkOfPages
*>
chunks
;
104
mutable
QMutex
mutex
;
105
};
106
107
}
108
109
QT_END_NAMESPACE
110
111
#
endif
// QV4EXECUTABLEALLOCATOR_H
QV4::ExecutableAllocator
Definition
qv4executableallocator_p.h:36
QV4
Definition
qjsvalue.h:23
WTF
Definition
qv4engine_p.h:33
qtdeclarative
src
qml
jsruntime
qv4executableallocator_p.h
Generated on
for Qt by
1.14.0