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
202
203 Heap::Object *templateObjectAt(int index) const;
204
211
222
223 void evaluate();
225
227 void markObjects(MarkStack *markStack) const;
228
238
240 {
242 bool byId;
243 };
244
246
247 Heap::Module *module() const;
248 void setModule(Heap::Module *module);
249
251
252 // Non-ES script values are held in the context's importedScripts array.
253 // That one uses the generic write barrier we have for JavaScript arrays.
254 // We don't need to markCustom() here.
256
257 const CompiledData::Unit *unitData() const { return m_compilationUnit->data; }
258
260
265
271
276
278 {
279 if (!runtimeStrings)
280 populate();
281
282 const auto *data = unitData();
283 return data->indexOfRootFunction != -1
285 : nullptr;
286 }
287
288 template<typename Engine = ExecutionEngine>
290 {
291 auto cu = static_cast<Engine *>(engine)->moduleForUrl(relative, this);
292
293 // Make sure that this is actually a dependent script.
294 // Otherwise we cannot guarantee that it's available.
295 Q_ASSERT(cu);
298 [&](const auto &dependentScript) {
299 return dependentScript->url == cu->finalUrl();
300 }));
301
302 return cu;
303 }
304
305 void populate();
306 void clear();
307
308protected:
311
312private:
313 friend struct ExecutionEngine;
314
317
318 struct ResolveSetEntry
319 {
320 ResolveSetEntry() {}
323 const ExecutableCompilationUnit *module = nullptr;
324 QV4::String *exportName = nullptr;
325 };
326
330
334
337
338 QUrl urlAt(int index) const { return QUrl(stringAt(index)); }
339
343 QV4::String *name) const;
344
347 bool includeDefaultExport = true) const;
348};
349
358
359} // namespace QV4
360
361QT_END_NAMESPACE
362
363#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