1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QQMLJSOPTIMIZATIONS_P_H
#define QQMLJSOPTIMIZATIONS_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
#include <private/qqmljscompilepass_p.h>
QT_BEGIN_NAMESPACE
class Q_QMLCOMPILER_EXPORT QQmlJSOptimizations : public QQmlJSCompilePass
{
public:
using Conversions = QSet<int>;
QQmlJSOptimizations(const QV4::Compiler::JSUnitGenerator *unitGenerator,
const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger,
const BasicBlocks &basicBlocks, const InstructionAnnotations &annotations,
QList<ObjectOrArrayDefinition> objectAndArrayDefinitions)
: QQmlJSCompilePass(unitGenerator, typeResolver, logger, basicBlocks, annotations),
m_objectAndArrayDefinitions{ std::move(objectAndArrayDefinitions) }
{
}
~QQmlJSOptimizations() = default;
BlocksAndAnnotations run(const Function *function);
private:
struct RegisterAccess
{
QList<QQmlJSRegisterContent> trackedTypes;
QHash<int, QQmlJSRegisterContent> typeReaders;
QHash<int, Conversions> registerReadersAndConversions;
int trackedRegister;
};
QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type) override
{
return ProcessInstruction;
}
void endInstruction(QV4::Moth::Instr::Type) override { }
void populateBasicBlocks();
void populateReaderLocations();
void adjustTypes();
bool canMove(int instructionOffset, const RegisterAccess &access) const;
void removeReadsFromErasedInstructions(const QFlatMap<int, InstructionAnnotation>::const_iterator &it);
void removeDeadStoresUntilStable();
bool eraseDeadStore(const InstructionAnnotations::iterator &it, bool &erasedReaders);
QHash<int, RegisterAccess> m_readerLocations;
QList<ObjectOrArrayDefinition> m_objectAndArrayDefinitions;
};
QT_END_NAMESPACE
#endif // QQMLJSOPTIMIZATIONS_P_H
|