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(); }
144 const CompiledObject *objectAt(int index) const
145 {
147 }
148
149 Heap::Object *templateObjectAt(int index) const;
150
157
168
169 void evaluate();
171
173 void markObjects(MarkStack *markStack) const;
174
184
186 {
188 bool byId;
189 };
190
192
193 Heap::Module *module() const;
194 void setModule(Heap::Module *module);
195
197
198 // Non-ES script values are held in the context's importedScripts array.
199 // That one uses the generic write barrier we have for JavaScript arrays.
200 // We don't need to markCustom() here.
202
203 const CompiledData::Unit *unitData() const { return m_compilationUnit->data; }
204
206
211
217
222
224 {
225 if (!runtimeStrings)
226 populate();
227
228 const auto *data = unitData();
229 return data->indexOfRootFunction != -1
231 : nullptr;
232 }
233
234 template<typename Engine = ExecutionEngine>
236 {
237 auto cu = static_cast<Engine *>(engine)->moduleForUrl(relative, this);
238
239 // Make sure that this is actually a dependent script.
240 // Otherwise we cannot guarantee that it's available.
241 Q_ASSERT(cu);
244 [&](const auto &dependentScript) {
245 return dependentScript->url == cu->finalUrl();
246 }));
247
248 return cu;
249 }
250
251 void populate();
252 void clear();
253
254protected:
257
258private:
259 friend struct ExecutionEngine;
260
263
264 struct ResolveSetEntry
265 {
266 ResolveSetEntry() {}
269 const ExecutableCompilationUnit *module = nullptr;
270 QV4::String *exportName = nullptr;
271 };
272
276
280
283
284 QUrl urlAt(int index) const { return QUrl(stringAt(index)); }
285
289 QV4::String *name) const;
290
293 bool includeDefaultExport = true) const;
294};
295
304
305} // namespace QV4
306
307QT_END_NAMESPACE
308
309#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