diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-05-29 18:47:57 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-05-31 06:55:13 +0000 |
commit | af028f592b4934cbd92c42d94ee405f764edfb80 (patch) | |
tree | e272ff7ee24c790fd972b9b92d4614cbfa86425b /src | |
parent | 77773997d085e83c811fe1e312f0402b932a56ac (diff) |
Moved object/bindings/customparser counters to CompilationUnit
These allow pre-allocating some arrays when instantiating types.
Change-Id: I2ca4ba4a69429918f03a5ba4c501c763e7ffa8dc
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 12 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 3 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlcompileddata.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlcompiler_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 12 |
6 files changed, 20 insertions, 18 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 22e2801055..f8fe145392 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -278,16 +278,16 @@ bool QQmlTypeCompiler::compile() } ++objectCount; if (typeRef->component) { - bindingCount += typeRef->component->totalBindingsCount; - parserStatusCount += typeRef->component->totalParserStatusCount; - objectCount += typeRef->component->totalObjectCount; + bindingCount += typeRef->component->compilationUnit->totalBindingsCount; + parserStatusCount += typeRef->component->compilationUnit->totalParserStatusCount; + objectCount += typeRef->component->compilationUnit->totalObjectCount; } } } - compiledData->totalBindingsCount = bindingCount; - compiledData->totalParserStatusCount = parserStatusCount; - compiledData->totalObjectCount = objectCount; + compiledData->compilationUnit->totalBindingsCount = bindingCount; + compiledData->compilationUnit->totalParserStatusCount = parserStatusCount; + compiledData->compilationUnit->totalObjectCount = objectCount; Q_ASSERT(compiledData->compilationUnit->propertyCaches.count() == static_cast<int>(compiledData->compilationUnit->data->nObjects)); diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 17ea5fab44..728a4d5213 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -67,6 +67,9 @@ CompilationUnit::CompilationUnit() , runtimeLookups(0) , runtimeRegularExpressions(0) , runtimeClasses(0) + , totalBindingsCount(0) + , totalParserStatusCount(0) + , totalObjectCount(0) {} CompilationUnit::~CompilationUnit() diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index db0522c74c..4417074a0e 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -687,6 +687,10 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount QHash<int, IdentifierHash<int>> namedObjectsPerComponentCache; IdentifierHash<int> namedObjectsPerComponent(int componentObjectIndex); + int totalBindingsCount; // Number of bindings used in this type + int totalParserStatusCount; // Number of instantiated types that are QQmlParserStatus subclasses + int totalObjectCount; // Number of objects explicitly instantiated + QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); void unlink(); diff --git a/src/qml/qml/qqmlcompileddata.cpp b/src/qml/qml/qqmlcompileddata.cpp index 569d3e16c4..405bf57448 100644 --- a/src/qml/qml/qqmlcompileddata.cpp +++ b/src/qml/qml/qqmlcompileddata.cpp @@ -55,8 +55,7 @@ QT_BEGIN_NAMESPACE QQmlCompiledData::QQmlCompiledData(QQmlEngine *engine) -: engine(engine), metaTypeId(-1), listMetaTypeId(-1), isRegisteredWithEngine(false), - totalBindingsCount(0), totalParserStatusCount(0) +: engine(engine), metaTypeId(-1), listMetaTypeId(-1), isRegisteredWithEngine(false) { Q_ASSERT(engine); } diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index b7c393c43a..75a6835ae6 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -124,10 +124,6 @@ public: QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit; - int totalBindingsCount; // Number of bindings used in this type - int totalParserStatusCount; // Number of instantiated types that are QQmlParserStatus subclasses - int totalObjectCount; // Number of objects explicitly instantiated - bool isInitialized() const { return hasEngine(); } void initialize(QQmlEngine *); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 86149469b7..289ce4849d 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -81,16 +81,16 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompile sharedState = new QQmlObjectCreatorSharedState; topLevelCreator = true; sharedState->componentAttached = 0; - sharedState->allCreatedBindings.allocate(compiledData->totalBindingsCount); - sharedState->allParserStatusCallbacks.allocate(compiledData->totalParserStatusCount); - sharedState->allCreatedObjects.allocate(compiledData->totalObjectCount); + sharedState->allCreatedBindings.allocate(compiledData->compilationUnit->totalBindingsCount); + sharedState->allParserStatusCallbacks.allocate(compiledData->compilationUnit->totalParserStatusCount); + sharedState->allCreatedObjects.allocate(compiledData->compilationUnit->totalObjectCount); sharedState->allJavaScriptObjects = 0; sharedState->creationContext = creationContext; sharedState->rootContext = 0; QQmlProfiler *profiler = QQmlEnginePrivate::get(engine)->profiler; Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, - sharedState->profiler.init(profiler, compiledData->totalParserStatusCount)); + sharedState->profiler.init(profiler, compiledData->compilationUnit->totalParserStatusCount)); } QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlObjectCreatorSharedState *inheritedSharedState) @@ -181,7 +181,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI Q_ASSERT(sharedState->allJavaScriptObjects || topLevelCreator); if (topLevelCreator) - sharedState->allJavaScriptObjects = scope.alloc(compiledData->totalObjectCount); + sharedState->allJavaScriptObjects = scope.alloc(compiledData->compilationUnit->totalObjectCount); if (subComponentIndex == -1 && compiledData->scripts.count()) { QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count())); @@ -236,7 +236,7 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance) Q_ASSERT(topLevelCreator); Q_ASSERT(!sharedState->allJavaScriptObjects); - sharedState->allJavaScriptObjects = valueScope.alloc(compiledData->totalObjectCount); + sharedState->allJavaScriptObjects = valueScope.alloc(compiledData->compilationUnit->totalObjectCount); QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc(1)); |