1 | // Copyright (C) 2017 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 | |
4 | #ifndef QV4JIT_P_H |
5 | #define QV4JIT_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/qv4global_p.h> |
19 | #include <private/qv4function_p.h> |
20 | #include <private/qv4instr_moth_p.h> |
21 | #include <private/qv4bytecodehandler_p.h> |
22 | #include <QtCore/qset.h> |
23 | |
24 | #if QT_CONFIG(qml_jit) |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | namespace QV4 { |
29 | namespace JIT { |
30 | |
31 | class BaselineAssembler; |
32 | |
33 | class BaselineJIT final: public Moth::ByteCodeHandler |
34 | { |
35 | public: |
36 | BaselineJIT(QV4::Function *); |
37 | ~BaselineJIT() override; |
38 | |
39 | void generate(); |
40 | |
41 | void generate_Ret() override; |
42 | void generate_Debug() override; |
43 | void generate_LoadConst(int index) override; |
44 | void generate_LoadZero() override; |
45 | void generate_LoadTrue() override; |
46 | void generate_LoadFalse() override; |
47 | void generate_LoadNull() override; |
48 | void generate_LoadUndefined() override; |
49 | void generate_LoadInt(int value) override; |
50 | void generate_MoveConst(int constIndex, int destTemp) override; |
51 | void generate_LoadReg(int reg) override; |
52 | void generate_StoreReg(int reg) override; |
53 | void generate_MoveReg(int srcReg, int destReg) override; |
54 | void generate_LoadImport(int index) override; |
55 | void generate_LoadLocal(int index) override; |
56 | void generate_StoreLocal(int index) override; |
57 | void generate_LoadScopedLocal(int scope, int index) override; |
58 | void generate_StoreScopedLocal(int scope, int index) override; |
59 | void generate_LoadRuntimeString(int stringId) override; |
60 | void generate_MoveRegExp(int regExpId, int destReg) override; |
61 | void generate_LoadClosure(int value) override; |
62 | void generate_LoadName(int name) override; |
63 | void generate_LoadGlobalLookup(int index) override; |
64 | void generate_LoadQmlContextPropertyLookup(int index) override; |
65 | void generate_StoreNameSloppy(int name) override; |
66 | void generate_StoreNameStrict(int name) override; |
67 | void generate_LoadElement(int base) override; |
68 | void generate_StoreElement(int base, int index) override; |
69 | void generate_LoadProperty(int name) override; |
70 | void generate_LoadOptionalProperty(int name, int offset) override; |
71 | void generate_GetLookup(int index) override; |
72 | void generate_GetOptionalLookup(int index, int offset) override; |
73 | void generate_StoreProperty(int name, int base) override; |
74 | void generate_SetLookup(int index, int base) override; |
75 | void generate_LoadSuperProperty(int property) override; |
76 | void generate_StoreSuperProperty(int property) override; |
77 | void generate_Yield() override; |
78 | void generate_YieldStar() override; |
79 | void generate_Resume(int) override; |
80 | |
81 | void generate_CallValue(int name, int argc, int argv) override; |
82 | void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override; |
83 | void generate_CallProperty(int name, int base, int argc, int argv) override; |
84 | void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override; |
85 | void generate_CallName(int name, int argc, int argv) override; |
86 | void generate_CallPossiblyDirectEval(int argc, int argv) override; |
87 | void generate_CallGlobalLookup(int index, int argc, int argv) override; |
88 | void generate_CallQmlContextPropertyLookup(int index, int argc, int argv) override; |
89 | void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override; |
90 | void generate_TailCall(int func, int thisObject, int argc, int argv) override; |
91 | void generate_Construct(int func, int argc, int argv) override; |
92 | void generate_ConstructWithSpread(int func, int argc, int argv) override; |
93 | void generate_SetUnwindHandler(int offset) override; |
94 | void generate_UnwindDispatch() override; |
95 | void generate_UnwindToLabel(int level, int offset) override; |
96 | void generate_DeadTemporalZoneCheck(int name) override; |
97 | void generate_ThrowException() override; |
98 | void generate_GetException() override; |
99 | void generate_SetException() override; |
100 | void generate_CreateCallContext() override; |
101 | void generate_PushCatchContext(int index, int name) override; |
102 | void generate_PushWithContext() override; |
103 | void generate_PushBlockContext(int index) override; |
104 | void generate_CloneBlockContext() override; |
105 | void generate_PushScriptContext(int index) override; |
106 | void generate_PopScriptContext() override; |
107 | void generate_PopContext() override; |
108 | void generate_GetIterator(int iterator) override; |
109 | void generate_IteratorNext(int value, int done) override; |
110 | void generate_IteratorNextForYieldStar(int iterator, int object) override; |
111 | void generate_IteratorClose(int done) override; |
112 | void generate_DestructureRestElement() override; |
113 | void generate_DeleteProperty(int base, int index) override; |
114 | void generate_DeleteName(int name) override; |
115 | void generate_TypeofName(int name) override; |
116 | void generate_TypeofValue() override; |
117 | void generate_DeclareVar(int varName, int isDeletable) override; |
118 | void generate_DefineArray(int argc, int args) override; |
119 | void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override; |
120 | void generate_CreateClass(int classIndex, int heritage, int computedNames) override; |
121 | void generate_CreateMappedArgumentsObject() override; |
122 | void generate_CreateUnmappedArgumentsObject() override; |
123 | void generate_CreateRestParameter(int argIndex) override; |
124 | void generate_ConvertThisToObject() override; |
125 | void generate_LoadSuperConstructor() override; |
126 | void generate_ToObject() override; |
127 | void generate_Jump(int offset) override; |
128 | void generate_JumpTrue(int offset) override; |
129 | void generate_JumpFalse(int offset) override; |
130 | void generate_JumpNoException(int offset) override; |
131 | void generate_JumpNotUndefined(int offset) override; |
132 | void generate_CheckException() override; |
133 | void generate_CmpEqNull() override; |
134 | void generate_CmpNeNull() override; |
135 | void generate_CmpEqInt(int lhs) override; |
136 | void generate_CmpNeInt(int lhs) override; |
137 | void generate_CmpEq(int lhs) override; |
138 | void generate_CmpNe(int lhs) override; |
139 | void generate_CmpGt(int lhs) override; |
140 | void generate_CmpGe(int lhs) override; |
141 | void generate_CmpLt(int lhs) override; |
142 | void generate_CmpLe(int lhs) override; |
143 | void generate_CmpStrictEqual(int lhs) override; |
144 | void generate_CmpStrictNotEqual(int lhs) override; |
145 | void generate_CmpIn(int lhs) override; |
146 | void generate_CmpInstanceOf(int lhs) override; |
147 | void generate_As(int lhs) override; |
148 | void generate_UNot() override; |
149 | void generate_UPlus() override; |
150 | void generate_UMinus() override; |
151 | void generate_UCompl() override; |
152 | void generate_Increment() override; |
153 | void generate_Decrement() override; |
154 | void generate_Add(int lhs) override; |
155 | void generate_BitAnd(int lhs) override; |
156 | void generate_BitOr(int lhs) override; |
157 | void generate_BitXor(int lhs) override; |
158 | void generate_UShr(int lhs) override; |
159 | void generate_Shr(int lhs) override; |
160 | void generate_Shl(int lhs) override; |
161 | void generate_BitAndConst(int rhs) override; |
162 | void generate_BitOrConst(int rhs) override; |
163 | void generate_BitXorConst(int rhs) override; |
164 | void generate_UShrConst(int rhs) override; |
165 | void generate_ShrConst(int rhs) override; |
166 | void generate_ShlConst(int rhs) override; |
167 | void generate_Exp(int lhs) override; |
168 | void generate_Mul(int lhs) override; |
169 | void generate_Div(int lhs) override; |
170 | void generate_Mod(int lhs) override; |
171 | void generate_Sub(int lhs) override; |
172 | void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override; |
173 | void generate_ThrowOnNullOrUndefined() override; |
174 | void generate_GetTemplateObject(int index) override; |
175 | |
176 | Verdict startInstruction(Moth::Instr::Type instr) override; |
177 | void endInstruction(Moth::Instr::Type instr) override; |
178 | |
179 | private: |
180 | QV4::Function *function; |
181 | QScopedPointer<BaselineAssembler> as; |
182 | QSet<int> labels; |
183 | }; |
184 | |
185 | } // namespace JIT |
186 | } // namespace QV4 |
187 | |
188 | QT_END_NAMESPACE |
189 | |
190 | #endif // QT_CONFIG(qml_jit) |
191 | |
192 | #endif // QV4JIT_P_H |
193 | |