aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2016-05-29 18:42:28 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-05-31 06:55:07 +0000
commit77773997d085e83c811fe1e312f0402b932a56ac (patch)
tree5e511b9b1c315116a3cbcc02a499c415862ab461 /src
parent3241573e1a72f2829d1339cd5bbe62f30d93c37f (diff)
Moved the import cache from QQmlCompiledData to CompilationUnit
Change-Id: I77892919678cb01ba1e697a44122760679a72045 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp13
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h1
-rw-r--r--src/qml/compiler/qv4compileddata.cpp2
-rw-r--r--src/qml/compiler/qv4compileddata_p.h7
-rw-r--r--src/qml/qml/qqmlcompileddata.cpp5
-rw-r--r--src/qml/qml/qqmlcompiler_p.h2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp4
7 files changed, 20 insertions, 14 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 0d3fc4f10b..22e2801055 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -65,16 +65,16 @@ QQmlTypeCompiler::QQmlTypeCompiler(QQmlEnginePrivate *engine, QQmlCompiledData *
bool QQmlTypeCompiler::compile()
{
- compiledData->importCache = new QQmlTypeNameCache;
+ importCache = new QQmlTypeNameCache;
foreach (const QString &ns, typeData->namespaces())
- compiledData->importCache->add(ns);
+ importCache->add(ns);
// Add any Composite Singletons that were used to the import cache
foreach (const QQmlTypeData::TypeReference &singleton, typeData->compositeSingletons())
- compiledData->importCache->add(singleton.type->qmlTypeName(), singleton.type->sourceUrl(), singleton.prefix);
+ importCache->add(singleton.type->qmlTypeName(), singleton.type->sourceUrl(), singleton.prefix);
- typeData->imports().populateCache(compiledData->importCache);
+ typeData->imports().populateCache(importCache.data());
const QHash<int, QQmlTypeData::TypeReference> &resolvedTypes = typeData->resolvedTypeRefs();
for (QHash<int, QQmlTypeData::TypeReference>::ConstIterator resolvedType = resolvedTypes.constBegin(), end = resolvedTypes.constEnd();
@@ -185,7 +185,7 @@ bool QQmlTypeCompiler::compile()
qualifier = qualifier.mid(lastDotIndex+1);
}
- compiledData->importCache->add(qualifier.toString(), scriptIndex, enclosingNamespace);
+ importCache->add(qualifier.toString(), scriptIndex, enclosingNamespace);
QQmlScriptData *scriptData = script.script->scriptData();
scriptData->addref();
compiledData->scripts << scriptData;
@@ -215,7 +215,7 @@ bool QQmlTypeCompiler::compile()
sss.scan();
}
- QmlIR::JSCodeGen v4CodeGenerator(typeData->finalUrlString(), document->code, &document->jsModule, &document->jsParserEngine, document->program, compiledData->importCache, &document->jsGenerator.stringTable);
+ QmlIR::JSCodeGen v4CodeGenerator(typeData->finalUrlString(), document->code, &document->jsModule, &document->jsParserEngine, document->program, importCache, &document->jsGenerator.stringTable);
QQmlJSCodeGenerator jsCodeGen(this, &v4CodeGenerator);
if (!jsCodeGen.generateCodeForComponents())
return false;
@@ -241,6 +241,7 @@ bool QQmlTypeCompiler::compile()
compiledData->compilationUnit = document->javaScriptCompilationUnit;
compiledData->compilationUnit->propertyCaches = m_propertyCaches;
+ compiledData->compilationUnit->importCache = importCache;
// Add to type registry of composites
if (compiledData->compilationUnit->isCompositeType())
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index d84753347a..5abfc7c18d 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -117,6 +117,7 @@ private:
QQmlEnginePrivate *engine;
QQmlCompiledData *compiledData;
QQmlTypeData *typeData;
+ QQmlRefPointer<QQmlTypeNameCache> importCache;
QmlIR::Document *document;
// index is string index of type name (use obj->inheritedTypeNameIndex)
QHash<int, QQmlCustomParser*> customParsers;
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 3472c955c8..17ea5fab44 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -171,6 +171,8 @@ void CompilationUnit::unlink()
propertyCaches.at(ii)->release();
propertyCaches.clear();
+ importCache = nullptr;
+
engine = 0;
free(runtimeStrings);
runtimeStrings = 0;
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index bc75dd0298..db0522c74c 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -62,11 +62,15 @@
#include <private/qqmlnullablevalue_p.h>
#include <private/qv4identifier_p.h>
#include <private/qflagpointer_p.h>
+#ifndef V4_BOOTSTRAP
+#include <private/qqmltypenamecache_p.h>
+#endif
QT_BEGIN_NAMESPACE
class QQmlPropertyCache;
class QQmlPropertyData;
+class QQmlTypeNameCache;
// The vector is indexed by QV4::CompiledData::Object index and the flag
// indicates whether instantiation of the object requires a VME meta-object.
@@ -666,10 +670,13 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount
QVector<QV4::Function *> runtimeFunctions;
mutable QQmlNullableValue<QUrl> m_url;
+ // QML specific fields
QQmlPropertyCacheVector propertyCaches;
QQmlPropertyCache *rootPropertyCache() const { return propertyCaches.at(data->indexOfRootObject).data(); }
bool isCompositeType() const { return propertyCaches.at(data->indexOfRootObject).flag(); }
+ QQmlRefPointer<QQmlTypeNameCache> importCache;
+
// index is object index. This allows fast access to the
// property data when initializing bindings, avoiding expensive
// lookups by string (property name).
diff --git a/src/qml/qml/qqmlcompileddata.cpp b/src/qml/qml/qqmlcompileddata.cpp
index 0305f3605f..569d3e16c4 100644
--- a/src/qml/qml/qqmlcompileddata.cpp
+++ b/src/qml/qml/qqmlcompileddata.cpp
@@ -55,7 +55,7 @@
QT_BEGIN_NAMESPACE
QQmlCompiledData::QQmlCompiledData(QQmlEngine *engine)
-: engine(engine), importCache(0), metaTypeId(-1), listMetaTypeId(-1), isRegisteredWithEngine(false),
+: engine(engine), metaTypeId(-1), listMetaTypeId(-1), isRegisteredWithEngine(false),
totalBindingsCount(0), totalParserStatusCount(0)
{
Q_ASSERT(engine);
@@ -88,9 +88,6 @@ QQmlCompiledData::~QQmlCompiledData()
for (int ii = 0; ii < scripts.count(); ++ii)
scripts.at(ii)->release();
-
- if (importCache)
- importCache->release();
}
void QQmlCompiledData::clear()
diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h
index 55247abae9..b7c393c43a 100644
--- a/src/qml/qml/qqmlcompiler_p.h
+++ b/src/qml/qml/qqmlcompiler_p.h
@@ -89,8 +89,6 @@ public:
QQmlEngine *engine;
- QQmlTypeNameCache *importCache;
-
int metaTypeId;
int listMetaTypeId;
bool isRegisteredWithEngine;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 798c8c8c5d..86149469b7 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -166,7 +166,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI
context = new QQmlContextData;
context->isInternal = true;
- context->imports = compiledData->importCache;
+ context->imports = compiledData->compilationUnit->importCache;
context->imports->addref();
context->initFromTypeCompilationUnit(compiledData->compilationUnit, subComponentIndex);
context->setParent(parentContext);
@@ -1127,7 +1127,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
if (customParser && obj->flags & QV4::CompiledData::Object::HasCustomParserBindings) {
customParser->engine = QQmlEnginePrivate::get(engine);
- customParser->imports = compiledData->importCache;
+ customParser->imports = compiledData->compilationUnit->importCache;
QList<const QV4::CompiledData::Binding *> bindings;
const QV4::CompiledData::Object *obj = qmlUnit->objectAt(index);