Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4executablecompilationunit_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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// Qt-Security score:significant
4
5#ifndef QV4EXECUTABLECOMPILATIONUNIT_P_H
6#define QV4EXECUTABLECOMPILATIONUNIT_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
19#include <private/qintrusivelist_p.h>
20#include <private/qqmlmetatype_p.h>
21#include <private/qqmlnullablevalue_p.h>
22#include <private/qqmlpropertycachevector_p.h>
23#include <private/qqmlrefcount_p.h>
24#include <private/qqmltype_p.h>
25#include <private/qqmltypenamecache_p.h>
26#include <private/qv4compileddata_p.h>
27#include <private/qv4identifierhash_p.h>
28
29#include <memory>
30
31QT_BEGIN_NAMESPACE
32
33class QQmlScriptData;
35
36namespace QV4 {
37
39
41{
42 Heap::String **runtimeStrings = nullptr; // Array
43
44 // pointers either to data->constants() or little-endian memory copy.
45 // We keep this member twice so that the JIT can access it via standard layout.
46 const StaticValue *constants = nullptr;
47
50 const StaticValue **imports = nullptr;
51
56};
57
60static_assert(offsetof(CompilationUnitRuntimeData, constants) == sizeof(QV4::Heap::String **));
64
65class Q_QML_EXPORT ExecutableCompilationUnit final
68{
70public:
73 friend struct ExecutionEngine;
74
76
79
80 QUrl url() const { return m_compilationUnit->url(); }
81 QUrl finalUrl() const { return m_compilationUnit->finalUrl(); }
82
87
92
97
98 // mapping from component object index (CompiledData::Unit object index that points to component) to identifier hash of named objects
99 // this is initialized on-demand by QQmlContextData
102
107
112
114
119
120 // --- interface for QQmlPropertyCacheCreator
125
130
136 bool isESModule() const { return m_compilationUnit->isESModule(); }
137
138 int objectCount() const { return m_compilationUnit->objectCount(); }
139 const CompiledObject *objectAt(int index) const
140 {
142 }
143
144 Heap::Object *templateObjectAt(int index) const;
145
152
163
164 void evaluate();
166
168 void markObjects(MarkStack *markStack) const;
169
179
181 {
183 bool byId;
184 };
185
187
188 Heap::Module *module() const;
189 void setModule(Heap::Module *module);
190
193
194 const CompiledData::Unit *unitData() const { return m_compilationUnit->data; }
195
197
202
208
213
215 {
216 if (!runtimeStrings)
217 populate();
218
219 const auto *data = unitData();
220 return data->indexOfRootFunction != -1
222 : nullptr;
223 }
224
225 template<typename Engine = ExecutionEngine>
227 {
228 auto cu = static_cast<Engine *>(engine)->moduleForUrl(relative, this);
229
230 // Make sure that this is actually a dependent script.
231 // Otherwise we cannot guarantee that it's available.
232 Q_ASSERT(cu);
235 [&](const auto &dependentScript) {
236 return dependentScript->url == cu->finalUrl();
237 }));
238
239 return cu;
240 }
241
242 void populate();
243 void clear();
244
245protected:
248
249private:
250 friend struct ExecutionEngine;
251
254
255 struct ResolveSetEntry
256 {
257 ResolveSetEntry() {}
260 const ExecutableCompilationUnit *module = nullptr;
261 QV4::String *exportName = nullptr;
262 };
263
267
271
274
275 QUrl urlAt(int index) const { return QUrl(stringAt(index)); }
276
280 QV4::String *name) const;
281
284 bool includeDefaultExport = true) const;
285};
286
295
296} // namespace QV4
297
298QT_END_NAMESPACE
299
300#endif // QV4EXECUTABLECOMPILATIONUNIT_P_H
friend class QQmlEnginePrivate
Definition qjsvalue.h:23
static void dumpConstantTable(const StaticValue *constants, uint count)
static QString toString(QV4::ReturnedValue v)
QVector< QV4::Heap::Object * > templateObjects
QVector< QV4::Heap::InternalClass * > runtimeBlocks