aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/doc/src/javascript/finetuning.qdoc6
-rw-r--r--src/qml/doc/src/qmldiskcache.qdoc107
-rw-r--r--src/qml/jsruntime/qv4engine.cpp49
-rw-r--r--src/qml/jsruntime/qv4engine_p.h18
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp7
-rw-r--r--src/qml/jsruntime/qv4script.cpp13
-rw-r--r--src/qml/qml/qqmlglobal_p.h24
-rw-r--r--src/qml/qml/qqmlmetatype.cpp27
-rw-r--r--src/qml/qml/qqmlmetatype_p.h7
-rw-r--r--src/qml/qml/qqmlscriptblob.cpp4
-rw-r--r--src/qml/qml/qqmltypedata.cpp4
-rw-r--r--src/qml/qml/qqmltypeloader.cpp32
-rw-r--r--src/qml/qml/qqmltypeloader_p.h4
13 files changed, 245 insertions, 57 deletions
diff --git a/src/qml/doc/src/javascript/finetuning.qdoc b/src/qml/doc/src/javascript/finetuning.qdoc
index 3826d05b92..14b4c9538d 100644
--- a/src/qml/doc/src/javascript/finetuning.qdoc
+++ b/src/qml/doc/src/javascript/finetuning.qdoc
@@ -78,14 +78,14 @@ Running JavaScript code can be influenced by a few environment variables, partic
\c{perf-<pid>.map} in \e{/tmp} which perf then reads. This environment variable, if
set, causes the JIT to generate this file.
\row
- \li \c{QML_DISABLE_DISK_CACHE}
- \li Disables the disk cache. See \l{The QML Disk Cache}.
- \row
\li \c{QV4_SHOW_BYTECODE}
\li Outputs the IR bytecode generated by Qt to the console.
Has to be combined with \c{QML_DISABLE_DISK_CACHE} or already cached bytecode will not
be shown.
\endtable
+\l{The QML Disk Cache} accepts further environment variables that allow fine tuning its behavior.
+In particular \c{QML_DISABLE_DISK_CACHE} may be useful for debugging.
+
*/
diff --git a/src/qml/doc/src/qmldiskcache.qdoc b/src/qml/doc/src/qmldiskcache.qdoc
index 4941bb02fa..90d9aee723 100644
--- a/src/qml/doc/src/qmldiskcache.qdoc
+++ b/src/qml/doc/src/qmldiskcache.qdoc
@@ -4,26 +4,96 @@
/*!
\page qmldiskcache.html
\title The QML Disk Cache
-\brief QML caches compiled documents on disk to improve load time.
-
-When your application loads a QML or JavaScript file for the first time,
-the QML engine compiles the file into a byte code representation on the
-fly and runs it. The compiling process can be time consuming, and subsequent
-loads of the same document yield the same result. To optimize this step, the
-QML engine can cache the result. It stores the byte code in a cache file and
-later loads the cache file instead of re-compiling when the same file is
-requested again. Usually the files are stored in a subdirectory \c{qmlcache}
-of the system's cache directory, as denoted by QStandardPaths::CacheLocation.
-Checks are in place to make sure that the cache files are only loaded if all
-of the following conditions are met:
+\brief QML documents are generally pre-compiled or cached after compilation.
+
+You should define your QML modules using \l{qt_add_qml_module} that makes sure
+that the \l{Qt Quick Compiler} processes your QML and JavaScript files ahead of
+time. Also, it guarantees optimum performance at run time. The
+\l{Qt Quick Compiler} generates byte code for
+each function and binding. This byte code can be used by the QML interpreter,
+and the Just-in-time (JIT) compiler in the QML engine. In addition, the
+\l{Qt Quick Compiler} generates native code for suitable functions and
+bindings. The native code can be executed directly, which results in better
+performance than interpreting or just-in-time compiling the byte code. Both,
+byte code and native code are then compiled into your binary.
+
+When using \l{qmake} you can specify \c{CONFIG += qtquickcompiler} to
+give similar treatment to QML and JavaScript files added as resources to your
+project. \l{Qt Creator} has a setting that allows passing
+\c{CONFIG += qtquickcompiler} to the qmake command line. By default, it is
+enabled for release and profile builds. \l{qmake} cannot pass as much
+information to the \l{Qt Quick Compiler} as CMake. Therefore, the compilation
+will contain less native code.
+
+You should make sure to load your QML documents from the resource file system
+where possible. Otherwise the QML engine won't be able to find the code compiled
+ahead of time.
+
+If no byte code or native code can be found for a QML document at run time, or
+if the code is found but cannot be used, the QML engine compiles the document
+into a byte code representation on the fly. The compiling process can be time
+consuming, and the result will contain only byte code. Subsequent loads of the
+same document will yield the same byte code. The QML engine can optimize this
+step by caching the result of the compilation. It stores the byte code in a
+cache file and later loads the cache file instead of re-compiling when the same
+QML document is requested again. Usually, the cache files are stored in a
+subdirectory \c{qmlcache} of the system's cache directory, as denoted by
+QStandardPaths::CacheLocation.
+
+Checks are in place to make sure that any cache files and any code compiled
+ahead of time are only loaded if all of the following conditions are met:
\list
\li The Qt version has not changed
\li The source code in the original file has not changed
\li The QML debugger is not running
\endlist
-The disk caching behavior can be fine tuned using the following environment
-variables:
+Only the \c{QML_FORCE_DISK_CACHE} variable (see below) overrides only the
+condition regarding the QML debugger. The other environment variables do not
+influence these conditions.
+
+The primary way of fine tuning the behavior regarding ahead of time compiled
+code and caching is via the environment variable \c{QML_DISK_CACHE}. This
+variable takes a comma-separated list of options, for example:
+
+\badcode
+QML_DISK_CACHE=aot,qmlc-read
+\endcode
+
+The available options are as follows:
+
+\table
+ \header
+ \li Option
+ \li Description
+ \row
+ \li aot-native
+ \li Load the compilation units compiled ahead of time and allow
+ execution of any native code found in them.
+ \row
+ \li aot-bytecode
+ \li Load the compilation units compiled ahead of time and allow
+ interpretation and just-in-time compilation of byte code found
+ in them.
+ \row
+ \li aot
+ \li Shorthand for \c{aot-native,aot-bytecode}.
+ \row
+ \li qmlc-read
+ \li Load any cached compilation units for QML and JavaScript files from
+ the host file system and allow interpretation and just-in-time
+ compilation of byte code found in them.
+ \row
+ \li qmlc-write
+ \li When compiling a QML or JavaScript file on the fly, create a cache
+ file afterward. The cache file can be loaded when the same
+ document is requested again.
+ \row
+ \li qmlc
+ \li Shorthand for \c{qmlc-read,qmlc-write}.
+\endtable
+
+Furthermore, you can use the following environment variables:
\table
\header
@@ -32,22 +102,19 @@ variables:
\row
\li \c{QML_DISABLE_DISK_CACHE}
\li Disables the disk cache and forces re-compilation from source for
- all QML and JavaScript files.
+ all QML and JavaScript files. \c{QML_DISABLE_DISK_CACHE} overrides
+ \c{QML_DISK_CACHE}.
\row
\li \c{QML_FORCE_DISK_CACHE}
\li Enables the disk cache even when debugging QML. You cannot use the
JavaScript debugger this way. It may fail to stop at breakpoints,
for example. You can still use the QML inspector to explore the
object hierarchy, though. \c{QML_FORCE_DISK_CACHE} overrides
- \c{QML_DISABLE_DISK_CACHE}.
+ \c{QML_DISABLE_DISK_CACHE} and \c{QML_DISK_CACHE}.
\row
\li \c{QML_DISK_CACHE_PATH}
\li Specifies a custom location where the cache files shall be stored
instead of using the default location.
\endtable
-You can also specify \c{CONFIG += qtquickcompiler} in your \c{.pro} file
-to perform the compilation ahead of time and integrate the resulting byte code
-directly into your executable. For more information, see \l{Qt Quick Compiler}.
-
*/
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 71b174f315..58283ee9e1 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -2028,8 +2028,14 @@ ReturnedValue ExecutionEngine::global()
QQmlRefPointer<ExecutableCompilationUnit> ExecutionEngine::compileModule(const QUrl &url)
{
QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError;
- if (const QQmlPrivate::CachedQmlUnit *cachedUnit = diskCacheEnabled()
- ? QQmlMetaType::findCachedCompilationUnit(url, &cacheError)
+ const DiskCacheOptions options = diskCacheOptions();
+ if (const QQmlPrivate::CachedQmlUnit *cachedUnit = (options & DiskCache::Aot)
+ ? QQmlMetaType::findCachedCompilationUnit(
+ url,
+ (options & DiskCache::AotByteCode)
+ ? QQmlMetaType::AcceptUntyped
+ : QQmlMetaType::RequireFullyTyped,
+ &cacheError)
: nullptr) {
return ExecutableCompilationUnit::create(
QV4::CompiledData::CompilationUnit(
@@ -2134,9 +2140,44 @@ QV4::Value *ExecutionEngine::registerNativeModule(const QUrl &url, const QV4::Va
return val;
}
-bool ExecutionEngine::diskCacheEnabled() const
+static ExecutionEngine::DiskCacheOptions transFormDiskCache(const char *v)
+{
+ using DiskCache = ExecutionEngine::DiskCache;
+
+ if (v == nullptr)
+ return DiskCache::Enabled;
+
+ ExecutionEngine::DiskCacheOptions result = DiskCache::Disabled;
+ const QList<QByteArray> options = QByteArray(v).split(',');
+ for (const QByteArray &option : options) {
+ if (option == "aot-bytecode")
+ result |= DiskCache::AotByteCode;
+ else if (option == "aot-native")
+ result |= DiskCache::AotNative;
+ else if (option == "aot")
+ result |= DiskCache::Aot;
+ else if (option == "qmlc-read")
+ result |= DiskCache::QmlcRead;
+ else if (option == "qmlc-write")
+ result |= DiskCache::QmlcWrite;
+ else if (option == "qmlc")
+ result |= DiskCache::Qmlc;
+ else
+ qWarning() << "Ignoring unknown option to QML_DISK_CACHE:" << option;
+ }
+
+ return result;
+}
+
+ExecutionEngine::DiskCacheOptions ExecutionEngine::diskCacheOptions() const
{
- return (!disableDiskCache() && !debugger()) || forceDiskCache();
+ if (forceDiskCache())
+ return DiskCache::Enabled;
+ if (disableDiskCache() || debugger())
+ return DiskCache::Disabled;
+ static const DiskCacheOptions options = qmlGetConfigOption<
+ DiskCacheOptions, transFormDiskCache>("QML_DISK_CACHE");
+ return options;
}
void ExecutionEngine::callInContext(QV4::Function *function, QObject *self,
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 57aa7a782c..86e580db88 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -139,6 +139,20 @@ private:
friend struct ExecutionContext;
friend struct Heap::ExecutionContext;
public:
+ enum class DiskCache {
+ Disabled = 0,
+ AotByteCode = 1 << 0,
+ AotNative = 1 << 1,
+ QmlcRead = 1 << 2,
+ QmlcWrite = 1 << 3,
+ Aot = AotByteCode | AotNative,
+ Qmlc = QmlcRead | QmlcWrite,
+ Enabled = Aot | Qmlc,
+
+ };
+
+ Q_DECLARE_FLAGS(DiskCacheOptions, DiskCache);
+
ExecutableAllocator *executableAllocator;
ExecutableAllocator *regExpAllocator;
@@ -735,7 +749,7 @@ public:
Module moduleForUrl(const QUrl &_url, const ExecutableCompilationUnit *referrer = nullptr) const;
Module loadModule(const QUrl &_url, const ExecutableCompilationUnit *referrer = nullptr);
- bool diskCacheEnabled() const;
+ DiskCacheOptions diskCacheOptions() const;
void callInContext(QV4::Function *function, QObject *self, QV4::ExecutionContext *ctxt,
int argc, void **args, QMetaType *types);
@@ -886,6 +900,8 @@ inline bool ExecutionEngine::checkStackLimits()
return false;
}
+Q_DECLARE_OPERATORS_FOR_FLAGS(ExecutionEngine::DiskCacheOptions);
+
} // namespace QV4
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index 132d0fb5a0..898f911334 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -178,9 +178,12 @@ QV4::Function *ExecutableCompilationUnit::linkToEngine(ExecutionEngine *engine)
}
runtimeFunctions.resize(data->functionTableSize);
- static bool forceInterpreter = qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER");
+ static bool ignoreAotCompiledFunctions
+ = qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER")
+ || !(engine->diskCacheOptions() & ExecutionEngine::DiskCache::AotNative);
+
const QQmlPrivate::TypedFunction *aotFunction
- = forceInterpreter ? nullptr : aotCompiledFunctions;
+ = ignoreAotCompiledFunctions ? nullptr : aotCompiledFunctions;
auto advanceAotFunction = [&](int i) -> const QQmlPrivate::TypedFunction * {
if (aotFunction) {
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index c72e1c4e19..395409ad4b 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -188,9 +188,16 @@ Script *Script::createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlCo
error->clear();
QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError;
- if (const QQmlPrivate::CachedQmlUnit *cachedUnit = engine->diskCacheEnabled()
- ? QQmlMetaType::findCachedCompilationUnit(originalUrl, &cacheError)
- : nullptr) {
+ const ExecutionEngine::DiskCacheOptions options = engine->diskCacheOptions();
+ if (const QQmlPrivate::CachedQmlUnit *cachedUnit
+ = (options & ExecutionEngine::DiskCache::Aot)
+ ? QQmlMetaType::findCachedCompilationUnit(
+ originalUrl,
+ (options & ExecutionEngine::DiskCache::AotByteCode)
+ ? QQmlMetaType::AcceptUntyped
+ : QQmlMetaType::RequireFullyTyped,
+ &cacheError)
+ : nullptr) {
QQmlRefPointer<QV4::ExecutableCompilationUnit> jsUnit
= QV4::ExecutableCompilationUnit::create(
QV4::CompiledData::CompilationUnit(cachedUnit->qmlData, cachedUnit->aotCompiledFunctions));
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index f7a50e8350..918f95993f 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -24,20 +24,24 @@
QT_BEGIN_NAMESPACE
+inline bool qmlConvertBoolConfigOption(const char *v)
+{
+ return v != nullptr && qstrcmp(v, "0") != 0 && qstrcmp(v, "false") != 0;
+}
+
+template<typename T, T(*Convert)(const char *)>
+T qmlGetConfigOption(const char *var)
+{
+ if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(var)))
+ return Convert(qgetenv(var));
+ return Convert(nullptr);
+}
#define DEFINE_BOOL_CONFIG_OPTION(name, var) \
static bool name() \
{ \
- static enum { Yes, No, Unknown } status = Unknown; \
- if (status == Unknown) { \
- status = No; \
- if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(#var))) { \
- const QByteArray v = qgetenv(#var); \
- if (v != "0" && v != "false") \
- status = Yes; \
- } \
- } \
- return status == Yes; \
+ static const bool result = qmlGetConfigOption<bool, qmlConvertBoolConfigOption>(#var); \
+ return result; \
}
/*!
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 188140245f..dfe5aa8d7b 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1540,8 +1540,23 @@ QList<QQmlType> QQmlMetaType::qmlSingletonTypes()
return retn;
}
-const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(const QUrl &uri, CachedUnitLookupError *status)
+static bool isFullyTyped(const QQmlPrivate::CachedQmlUnit *unit)
+{
+ qsizetype numTypedFunctions = 0;
+ for (const QQmlPrivate::TypedFunction *function = unit->aotCompiledFunctions;
+ function; ++function) {
+ if (function->functionPtr)
+ ++numTypedFunctions;
+ else
+ return false;
+ }
+ return numTypedFunctions == unit->qmlData->functionTableSize;
+}
+
+const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(
+ const QUrl &uri, QQmlMetaType::CacheMode mode, CachedUnitLookupError *status)
{
+ Q_ASSERT(mode != RejectAll);
const QQmlMetaTypeDataPtr data;
for (const auto lookup : std::as_const(data->lookupCachedQmlUnit)) {
@@ -1553,6 +1568,16 @@ const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(const
*status = CachedUnitLookupError::VersionMismatch;
return nullptr;
}
+
+ if (mode == RequireFullyTyped && !isFullyTyped(unit)) {
+ qCDebug(DBG_DISK_CACHE)
+ << "Error loading pre-compiled file " << uri
+ << ": compilation unit contains functions not compiled to native code.";
+ if (status)
+ *status = CachedUnitLookupError::NotFullyTyped;
+ return nullptr;
+ }
+
if (status)
*status = CachedUnitLookupError::NoError;
return unit;
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index c7a860eaca..c19dd8aff7 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -185,10 +185,13 @@ public:
enum class CachedUnitLookupError {
NoError,
NoUnitFound,
- VersionMismatch
+ VersionMismatch,
+ NotFullyTyped
};
- static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(const QUrl &uri, CachedUnitLookupError *status);
+ enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
+ static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
+ const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
// used by tst_qqmlcachegen.cpp
static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp
index 4ea3816ed4..72bc3a7c12 100644
--- a/src/qml/qml/qqmlscriptblob.cpp
+++ b/src/qml/qml/qqmlscriptblob.cpp
@@ -34,7 +34,7 @@ QQmlRefPointer<QQmlScriptData> QQmlScriptBlob::scriptData() const
void QQmlScriptBlob::dataReceived(const SourceCodeData &data)
{
- if (diskCacheEnabled()) {
+ if (readCacheFile()) {
QQmlRefPointer<QV4::ExecutableCompilationUnit> unit
= QV4::ExecutableCompilationUnit::create();
QString error;
@@ -98,7 +98,7 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data)
auto executableUnit = QV4::ExecutableCompilationUnit::create(std::move(unit));
- if (diskCacheEnabled()) {
+ if (writeCacheFile()) {
QString errorString;
if (executableUnit->saveToDisk(url(), &errorString)) {
QString error;
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index a7234a5477..b030a70abb 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -100,7 +100,7 @@ CompositeMetaTypeIds QQmlTypeData::typeIds(int objectId) const
bool QQmlTypeData::tryLoadFromDiskCache()
{
- if (!diskCacheEnabled())
+ if (!readCacheFile())
return false;
QV4::ExecutionEngine *v4 = typeLoader()->engine()->handle();
@@ -757,7 +757,7 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCach
return;
}
- const bool trySaveToDisk = diskCacheEnabled() && !typeRecompilation;
+ const bool trySaveToDisk = writeCacheFile() && !typeRecompilation;
if (trySaveToDisk) {
QString errorString;
if (m_compiledData->saveToDisk(url(), &errorString)) {
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index a3eae70639..a30d25c30a 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -859,9 +859,27 @@ bool QQmlTypeLoader::Blob::isDebugging() const
return typeLoader()->engine()->handle()->debugger() != nullptr;
}
-bool QQmlTypeLoader::Blob::diskCacheEnabled() const
+bool QQmlTypeLoader::Blob::readCacheFile() const
{
- return typeLoader()->engine()->handle()->diskCacheEnabled();
+ return typeLoader()->engine()->handle()->diskCacheOptions()
+ & QV4::ExecutionEngine::DiskCache::QmlcRead;
+}
+
+bool QQmlTypeLoader::Blob::writeCacheFile() const
+{
+ return typeLoader()->engine()->handle()->diskCacheOptions()
+ & QV4::ExecutionEngine::DiskCache::QmlcWrite;
+}
+
+QQmlMetaType::CacheMode QQmlTypeLoader::Blob::aotCacheMode() const
+{
+ const QV4::ExecutionEngine::DiskCacheOptions options
+ = typeLoader()->engine()->handle()->diskCacheOptions();
+ if (!(options & QV4::ExecutionEngine::DiskCache::Aot))
+ return QQmlMetaType::RejectAll;
+ if (options & QV4::ExecutionEngine::DiskCache::AotByteCode)
+ return QQmlMetaType::AcceptUntyped;
+ return QQmlMetaType::RequireFullyTyped;
}
bool QQmlTypeLoader::Blob::qmldirDataAvailable(const QQmlRefPointer<QQmlQmldirData> &data, QList<QQmlError> *errors)
@@ -934,8 +952,9 @@ QQmlRefPointer<QQmlTypeData> QQmlTypeLoader::getType(const QUrl &unNormalizedUrl
m_typeCache.insert(url, typeData);
QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError;
- if (const QQmlPrivate::CachedQmlUnit *cachedUnit = typeData->diskCacheEnabled()
- ? QQmlMetaType::findCachedCompilationUnit(typeData->url(), &error)
+ const QQmlMetaType::CacheMode cacheMode = typeData->aotCacheMode();
+ if (const QQmlPrivate::CachedQmlUnit *cachedUnit = (cacheMode != QQmlMetaType::RejectAll)
+ ? QQmlMetaType::findCachedCompilationUnit(typeData->url(), cacheMode, &error)
: nullptr) {
QQmlTypeLoader::loadWithCachedUnit(typeData, cachedUnit, mode);
} else {
@@ -993,8 +1012,9 @@ QQmlRefPointer<QQmlScriptBlob> QQmlTypeLoader::getScript(const QUrl &unNormalize
m_scriptCache.insert(url, scriptBlob);
QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError;
- if (const QQmlPrivate::CachedQmlUnit *cachedUnit = scriptBlob->diskCacheEnabled()
- ? QQmlMetaType::findCachedCompilationUnit(scriptBlob->url(), &error)
+ const QQmlMetaType::CacheMode cacheMode = scriptBlob->aotCacheMode();
+ if (const QQmlPrivate::CachedQmlUnit *cachedUnit = (cacheMode != QQmlMetaType::RejectAll)
+ ? QQmlMetaType::findCachedCompilationUnit(scriptBlob->url(), cacheMode, &error)
: nullptr) {
QQmlTypeLoader::loadWithCachedUnit(scriptBlob, cachedUnit);
} else {
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index 1e1a03c607..6c53437d86 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -109,7 +109,9 @@ public:
virtual QString stringAt(int) const { return QString(); }
bool isDebugging() const;
- bool diskCacheEnabled() const;
+ bool readCacheFile() const;
+ bool writeCacheFile() const;
+ QQmlMetaType::CacheMode aotCacheMode() const;
QQmlRefPointer<QQmlImports> m_importCache;
QVector<PendingImportPtr> m_unresolvedImports;