Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmljsbasicblocks_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QQMLJSBASICBLOCKS_P_H
5#define QQMLJSBASICBLOCKS_P_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 <private/qqmljscompilepass_p.h>
19#include <private/qflatmap_p.h>
20
22
23class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSBasicBlocks : public QQmlJSCompilePass
24{
25public:
26 struct BasicBlock {
30 int jumpTarget = -1;
31 bool jumpIsUnconditional = false;
32 };
33
35 const QV4::Compiler::JSUnitGenerator *unitGenerator,
36 const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger)
37 : QQmlJSCompilePass(unitGenerator, typeResolver, logger), m_context{ context }
38 {
39 }
40
41 ~QQmlJSBasicBlocks() = default;
42
44 const Function *function, const InstructionAnnotations &annotations,
46
47private:
48 struct RegisterAccess
49 {
52 QHash<int, QList<int>> registerReadersAndConversions;
53 int trackedRegister;
54 };
55
56 struct ObjectOrArrayDefinition
57 {
58 static constexpr int arrayClassId = -1;
59
60 int instructionOffset = -1;
61 int internalClassId = -1;
62 int argc = 0;
63 int argv = -1;
64 };
65
68
69 void generate_Jump(int offset) override;
70 void generate_JumpTrue(int offset) override;
71 void generate_JumpFalse(int offset) override;
72 void generate_JumpNoException(int offset) override;
73 void generate_JumpNotUndefined(int offset) override;
74
75 void generate_Ret() override;
76 void generate_ThrowException() override;
77
78 void generate_DefineArray(int argc, int argv) override;
79 void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override;
80
81 enum JumpMode { Unconditional, Conditional };
82 void processJump(int offset, JumpMode mode);
83 void populateBasicBlocks();
84 void populateReaderLocations();
85 void adjustTypes();
86 bool canMove(int instructionOffset, const RegisterAccess &access) const;
87
88 void dumpBasicBlocks();
89 void dumpDOTGraph();
90
91 const QV4::Compiler::Context *m_context;
92 InstructionAnnotations m_annotations;
93 QFlatMap<int, BasicBlock> m_basicBlocks;
94 QHash<int, RegisterAccess> m_readerLocations;
95 QList<ObjectOrArrayDefinition> m_objectAndArrayDefinitions;
96 bool m_skipUntilNextLabel = false;
97 bool m_hadBackJumps = false;
98};
99
101
102#endif // QQMLJSBASICBLOCKS_P_H
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
~QQmlJSBasicBlocks()=default
QQmlJSBasicBlocks(const QV4::Compiler::Context *context, const QV4::Compiler::JSUnitGenerator *unitGenerator, const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger)
void generate_JumpTrue(int) override
void generate_JumpFalse(int) override
void generate_Jump(int) override
void generate_DefineArray(int, int) override
void generate_JumpNotUndefined(int) override
void generate_Ret() override
void generate_ThrowException() override
void generate_JumpNoException(int) override
void generate_DefineObjectLiteral(int, int, int) override
virtual void endInstruction(Moth::Instr::Type instr)=0
virtual Verdict startInstruction(Moth::Instr::Type instr)=0
Combined button and popup list for selecting options.
static void * context
DBusConnection const char DBusError * error
GLenum mode
GLenum type
GLenum access
GLenum GLuint GLintptr offset
QJSValueList args
QList< QQmlJSScope::ConstPtr > readTypes