1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQml module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QV4JIT_P_H
41#define QV4JIT_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <private/qv4global_p.h>
55#include <private/qv4function_p.h>
56#include <private/qv4instr_moth_p.h>
57#include <private/qv4bytecodehandler_p.h>
58
59#if QT_CONFIG(qml_jit)
60
61QT_BEGIN_NAMESPACE
62
63namespace QV4 {
64namespace JIT {
65
66class BaselineAssembler;
67
68class BaselineJIT final: public Moth::ByteCodeHandler
69{
70public:
71 BaselineJIT(QV4::Function *);
72 virtual ~BaselineJIT() Q_DECL_OVERRIDE;
73
74 void generate();
75
76 void generate_Ret() override;
77 void generate_Debug() override;
78 void generate_LoadConst(int index) override;
79 void generate_LoadZero() override;
80 void generate_LoadTrue() override;
81 void generate_LoadFalse() override;
82 void generate_LoadNull() override;
83 void generate_LoadUndefined() override;
84 void generate_LoadInt(int value) override;
85 void generate_MoveConst(int constIndex, int destTemp) override;
86 void generate_LoadReg(int reg) override;
87 void generate_StoreReg(int reg) override;
88 void generate_MoveReg(int srcReg, int destReg) override;
89 void generate_LoadImport(int index) override;
90 void generate_LoadLocal(int index) override;
91 void generate_StoreLocal(int index) override;
92 void generate_LoadScopedLocal(int scope, int index) override;
93 void generate_StoreScopedLocal(int scope, int index) override;
94 void generate_LoadRuntimeString(int stringId) override;
95 void generate_MoveRegExp(int regExpId, int destReg) override;
96 void generate_LoadClosure(int value) override;
97 void generate_LoadName(int name) override;
98 void generate_LoadGlobalLookup(int index) override;
99 void generate_LoadQmlContextPropertyLookup(int index) override;
100 void generate_StoreNameSloppy(int name) override;
101 void generate_StoreNameStrict(int name) override;
102 void generate_LoadElement(int base) override;
103 void generate_StoreElement(int base, int index) override;
104 void generate_LoadProperty(int name) override;
105 void generate_GetLookup(int index) override;
106 void generate_StoreProperty(int name, int base) override;
107 void generate_SetLookup(int index, int base) override;
108 void generate_LoadSuperProperty(int property) override;
109 void generate_StoreSuperProperty(int property) override;
110 void generate_Yield() override;
111 void generate_YieldStar() override;
112 void generate_Resume(int) override;
113
114 void generate_CallValue(int name, int argc, int argv) override;
115 void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override;
116 void generate_CallProperty(int name, int base, int argc, int argv) override;
117 void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override;
118 void generate_CallElement(int base, int index, int argc, int argv) override;
119 void generate_CallName(int name, int argc, int argv) override;
120 void generate_CallPossiblyDirectEval(int argc, int argv) override;
121 void generate_CallGlobalLookup(int index, int argc, int argv) override;
122 void generate_CallQmlContextPropertyLookup(int index, int argc, int argv) override;
123 void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override;
124 void generate_TailCall(int func, int thisObject, int argc, int argv) override;
125 void generate_Construct(int func, int argc, int argv) override;
126 void generate_ConstructWithSpread(int func, int argc, int argv) override;
127 void generate_SetUnwindHandler(int offset) override;
128 void generate_UnwindDispatch() override;
129 void generate_UnwindToLabel(int level, int offset) override;
130 void generate_DeadTemporalZoneCheck(int name) override;
131 void generate_ThrowException() override;
132 void generate_GetException() override;
133 void generate_SetException() override;
134 void generate_CreateCallContext() override;
135 void generate_PushCatchContext(int index, int name) override;
136 void generate_PushWithContext() override;
137 void generate_PushBlockContext(int index) override;
138 void generate_CloneBlockContext() override;
139 void generate_PushScriptContext(int index) override;
140 void generate_PopScriptContext() override;
141 void generate_PopContext() override;
142 void generate_GetIterator(int iterator) override;
143 void generate_IteratorNext(int value, int done) override;
144 void generate_IteratorNextForYieldStar(int iterator, int object) override;
145 void generate_IteratorClose(int done) override;
146 void generate_DestructureRestElement() override;
147 void generate_DeleteProperty(int base, int index) override;
148 void generate_DeleteName(int name) override;
149 void generate_TypeofName(int name) override;
150 void generate_TypeofValue() override;
151 void generate_DeclareVar(int varName, int isDeletable) override;
152 void generate_DefineArray(int argc, int args) override;
153 void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override;
154 void generate_CreateClass(int classIndex, int heritage, int computedNames) override;
155 void generate_CreateMappedArgumentsObject() override;
156 void generate_CreateUnmappedArgumentsObject() override;
157 void generate_CreateRestParameter(int argIndex) override;
158 void generate_ConvertThisToObject() override;
159 void generate_LoadSuperConstructor() override;
160 void generate_ToObject() override;
161 void generate_Jump(int offset) override;
162 void generate_JumpTrue(int offset) override;
163 void generate_JumpFalse(int offset) override;
164 void generate_JumpNoException(int offset) override;
165 void generate_JumpNotUndefined(int offset) override;
166 void generate_CheckException() override;
167 void generate_CmpEqNull() override;
168 void generate_CmpNeNull() override;
169 void generate_CmpEqInt(int lhs) override;
170 void generate_CmpNeInt(int lhs) override;
171 void generate_CmpEq(int lhs) override;
172 void generate_CmpNe(int lhs) override;
173 void generate_CmpGt(int lhs) override;
174 void generate_CmpGe(int lhs) override;
175 void generate_CmpLt(int lhs) override;
176 void generate_CmpLe(int lhs) override;
177 void generate_CmpStrictEqual(int lhs) override;
178 void generate_CmpStrictNotEqual(int lhs) override;
179 void generate_CmpIn(int lhs) override;
180 void generate_CmpInstanceOf(int lhs) override;
181 void generate_UNot() override;
182 void generate_UPlus() override;
183 void generate_UMinus() override;
184 void generate_UCompl() override;
185 void generate_Increment() override;
186 void generate_Decrement() override;
187 void generate_Add(int lhs) override;
188 void generate_BitAnd(int lhs) override;
189 void generate_BitOr(int lhs) override;
190 void generate_BitXor(int lhs) override;
191 void generate_UShr(int lhs) override;
192 void generate_Shr(int lhs) override;
193 void generate_Shl(int lhs) override;
194 void generate_BitAndConst(int rhs) override;
195 void generate_BitOrConst(int rhs) override;
196 void generate_BitXorConst(int rhs) override;
197 void generate_UShrConst(int rhs) override;
198 void generate_ShrConst(int rhs) override;
199 void generate_ShlConst(int rhs) override;
200 void generate_Exp(int lhs) override;
201 void generate_Mul(int lhs) override;
202 void generate_Div(int lhs) override;
203 void generate_Mod(int lhs) override;
204 void generate_Sub(int lhs) override;
205 void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override;
206 void generate_ThrowOnNullOrUndefined() override;
207 void generate_GetTemplateObject(int index) override;
208
209 Verdict startInstruction(Moth::Instr::Type instr) override;
210 void endInstruction(Moth::Instr::Type instr) override;
211
212private:
213 QV4::Function *function;
214 QScopedPointer<BaselineAssembler> as;
215 QSet<int> labels;
216};
217
218} // namespace JIT
219} // namespace QV4
220
221QT_END_NAMESPACE
222
223#endif // QT_CONFIG(qml_jit)
224
225#endif // QV4JIT_P_H
226

source code of qtdeclarative/src/qml/jit/qv4baselinejit_p.h