Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmljsoptimizations_p.h
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
// Qt-Security score:significant
4
5
#
ifndef
QQMLJSOPTIMIZATIONS_P_H
6
#
define
QQMLJSOPTIMIZATIONS_P_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
#
include
<
private
/
qqmljscompilepass_p
.
h
>
19
20
QT_BEGIN_NAMESPACE
21
22
class
Q_QMLCOMPILER_EXPORT
QQmlJSOptimizations
:
public
QQmlJSCompilePass
23
{
24
public
:
25
using
Conversions = QSet<
int
>;
26
27
QQmlJSOptimizations(
const
QV4::Compiler::JSUnitGenerator *unitGenerator,
28
const
QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger,
29
const
BasicBlocks &basicBlocks,
const
InstructionAnnotations &annotations,
30
QList<ObjectOrArrayDefinition> objectAndArrayDefinitions)
31
: QQmlJSCompilePass(unitGenerator, typeResolver, logger, basicBlocks, annotations),
32
m_objectAndArrayDefinitions{ std::move(objectAndArrayDefinitions) }
33
{
34
}
35
36
~QQmlJSOptimizations() =
default
;
37
38
BlocksAndAnnotations run(
const
Function *function);
39
40
private
:
41
struct
RegisterAccess
42
{
43
// Content written by this instruction, or contents merged/converted into this register.
44
QList<QQmlJSRegisterContent> trackedTypes;
45
46
// Instructions that genuinely consume the *value* this write produced (never renames/copies
47
// of it), keyed by instruction offset, with the exact content each one reads it as.
48
// Tracked by content identity, so this follows the value across register renames rather
49
// than being tied to one register slot.
50
// Drives the write's required output type (see QQmlJSTypeResolver::adjustTrackedType) and
51
// whether it can be moved into its single use site (see canMove).
52
QHash<
int
, QQmlJSRegisterContent> typeReaders;
53
54
// Reads of this write's *specific register slot* while it's still the reaching definition
55
// (i.e. before any later write overwrites that register), keyed by instruction offset,
56
// together with the type-conversion instructions crossed between the write and each read.
57
// Drives which type conversions are actually needed in codegen (see liveConversions in
58
// adjustTypes) and, combined with typeReaders, whether a store is conversion-free enough to
59
// move.
60
QHash<
int
, Conversions> registerReadersAndConversions;
61
62
// Register slot written to by this instruction.
63
int
trackedRegister;
64
};
65
66
QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type) override
67
{
68
return
ProcessInstruction;
69
}
70
void
endInstruction(QV4::Moth::Instr::Type) override { }
71
72
void
populateBasicBlocks();
73
void
populateReaderLocationsTrackedTypes();
74
void
populateReaderLocationsReadersAndConversions();
75
void
adjustTypes();
76
bool
canMove(
int
instructionOffset,
const
RegisterAccess &access)
const
;
77
78
void
removeReadsFromErasedInstructions(
const
QFlatMap<
int
, InstructionAnnotation>::const_iterator &it);
79
void
removeDeadStoresUntilStable();
80
bool
eraseDeadStore(
const
InstructionAnnotations::iterator &it,
bool
&erasedReaders);
81
82
QHash<
int
, RegisterAccess> m_readerLocations;
83
QList<ObjectOrArrayDefinition> m_objectAndArrayDefinitions;
84
};
85
86
QT_END_NAMESPACE
87
88
#
endif
// QQMLJSOPTIMIZATIONS_P_H
NewFlatMap
Definition
qqmljsoptimizations.cpp:42
NewFlatMap::appendOrdered
void appendOrdered(const typename OriginalFlatMap::iterator &i)
Definition
qqmljsoptimizations.cpp:46
NewFlatMap::take
OriginalFlatMap take()
Definition
qqmljsoptimizations.cpp:52
QQmlJSOptimizations
Definition
qqmljsoptimizations_p.h:23
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
mergeBlockState
static bool mergeBlockState(BlockState &to, const BlockState &from)
Definition
qqmljsoptimizations.cpp:101
adjustErrorMessage
static QString adjustErrorMessage(QQmlJSRegisterContent origin, const QQmlJSScope::ConstPtr &conversion)
Definition
qqmljsoptimizations.cpp:339
containsAny
static bool containsAny(const ContainerA &container, const ContainerB &elements)
Definition
qqmljsoptimizations.cpp:30
adjustErrorMessage
static QString adjustErrorMessage(QQmlJSRegisterContent origin, QQmlJSRegisterContent conversion)
Definition
qqmljsoptimizations.cpp:346
BlockState
Definition
qqmljsoptimizations.cpp:96
BlockState::registers
QHash< int, RegisterState > registers
Definition
qqmljsoptimizations.cpp:98
qtdeclarative
src
qmlcompiler
qqmljsoptimizations_p.h
Generated on
for Qt by
1.18.0