diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-09-16 12:08:06 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-09-20 10:03:56 +0200 |
commit | 17bd07cbc5b6cf54716e991765ab3088a710d7b3 (patch) | |
tree | 64f0840f9a4da790c37f9a78992a39cfba19c1ae /src/qml/compiler/qv4compiler_p.h | |
parent | a2db40e6c070017960b9f815c66cab354e3466dc (diff) |
QML: Optimize QObject method calls
So far, for each method call we had to allocate a new QObjectMethod as
we didn't have any lookup to cache the methods. Introduce a new lookup
for that and use it for all QObject methods.
Since QObjectMethod contains a pointer to the concrete QObject the
method was retrieved from, some more care has to be taken: If we are
going to call the method right away, we don't need the object since we
always have a thisObject and any further retrieval of the same method
will result in a call again. This enables us to cache the method for any
instance of the same class. When storing the method elsewhere, though,
we need to hold on to the object since you can defer the call or connect
a handler to a signal or similar. For such operations we do need the
object. We can still optimize a bit by re-using the method cache we
build the first time around.
Fixes: QTBUG-95628
Change-Id: I5991180c5e0234cdc179c2b78a43dafc9083e525
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compiler_p.h')
-rw-r--r-- | src/qml/compiler/qv4compiler_p.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4compiler_p.h b/src/qml/compiler/qv4compiler_p.h index 61432aa028..82afb7cf3a 100644 --- a/src/qml/compiler/qv4compiler_p.h +++ b/src/qml/compiler/qv4compiler_p.h @@ -70,6 +70,8 @@ private: }; struct Q_QML_COMPILER_PRIVATE_EXPORT JSUnitGenerator { + enum LookupMode { LookupForStorage, LookupForCall }; + static void generateUnitChecksum(CompiledData::Unit *unit); struct MemberInfo { @@ -83,12 +85,12 @@ struct Q_QML_COMPILER_PRIVATE_EXPORT JSUnitGenerator { int getStringId(const QString &string) const { return stringTable.getStringId(string); } QString stringForIndex(int index) const { return stringTable.stringForIndex(index); } - int registerGetterLookup(const QString &name); - int registerGetterLookup(int nameIndex); + int registerGetterLookup(const QString &name, LookupMode mode); + int registerGetterLookup(int nameIndex, LookupMode mode); int registerSetterLookup(const QString &name); int registerSetterLookup(int nameIndex); - int registerGlobalGetterLookup(int nameIndex); - int registerQmlContextPropertyGetterLookup(int nameIndex); + int registerGlobalGetterLookup(int nameIndex, LookupMode mode); + int registerQmlContextPropertyGetterLookup(int nameIndex, LookupMode mode); int lookupNameIndex(int index) const { return lookups[index].nameIndex(); } QString lookupName(int index) const { return stringForIndex(lookupNameIndex(index)); } |