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
59static_assert(offsetof(CompilationUnitRuntimeData, runtimeStrings) == 0);
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
192
193 // Non-ES script values are held in the context's importedScripts array.
194 // That one uses the generic write barrier we have for JavaScript arrays.
195 // We don't need to markCustom() here.
197
198 const CompiledData::Unit *unitData() const { return m_compilationUnit->data; }
199
201
206
212
217
219 {
220 if (!runtimeStrings)
221 populate();
222
223 const auto *data = unitData();
224 return data->indexOfRootFunction != -1
226 : nullptr;
227 }
228
229 template<typename Engine = ExecutionEngine>
231 {
232 auto cu = static_cast<Engine *>(engine)->moduleForUrl(relative, this);
233
234 // Make sure that this is actually a dependent script.
235 // Otherwise we cannot guarantee that it's available.
236 Q_ASSERT(cu);
239 [&](const auto &dependentScript) {
240 return dependentScript->url == cu->finalUrl();
241 }));
242
243 return cu;
244 }
245
246 void populate();
247 void clear();
248
249protected:
252
253private:
254 friend struct ExecutionEngine;
255
258
259 struct ResolveSetEntry
260 {
261 ResolveSetEntry() {}
264 const ExecutableCompilationUnit *module = nullptr;
265 QV4::String *exportName = nullptr;
266 };
267
271
275
278
279 QUrl urlAt(int index) const { return QUrl(stringAt(index)); }
280
284 QV4::String *name) const;
285
288 bool includeDefaultExport = true) const;
289};
290
299
300} // namespace QV4
301
302QT_END_NAMESPACE
303
304#endif // QV4EXECUTABLECOMPILATIONUNIT_P_H
friend class QQmlEnginePrivate
Combined button and popup list for selecting options.
Definition qjsvalue.h:24
static void dumpConstantTable(const StaticValue *constants, uint count)
static QString toString(QV4::ReturnedValue v)
QList< QV4::Heap::InternalClass * > runtimeBlocks