aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-04-06 11:23:11 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-04-21 15:06:23 +0000
commit223516ae2f7131cc7f8972e9afdeca970d85473d (patch)
treef4415038b5507f26ee88e9a77325ba432d61f211 /src
parent0c7a5165f3b3c9d2f271da4fe3cb49f09844a56e (diff)
V4: make QQmlEnginePrivate::dereferenceScarceResources inlinable.
Done by giving the "expensive" part its own function, that's even unlikely to be called anyway. Change-Id: I35621fb0a764879f9339b9e23f210c66971ff5b7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlengine.cpp32
-rw-r--r--src/qml/qml/qqmlengine_p.h22
2 files changed, 32 insertions, 22 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 63d3feee1e..99ae367773 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1900,28 +1900,16 @@ void QQmlEnginePrivate::warning(QQmlEnginePrivate *engine, const QList<QQmlError
dumpwarning(error);
}
-/*
- This function should be called after evaluation of the js expression is
- complete, and so the scarce resources may be freed safely.
- */
-void QQmlEnginePrivate::dereferenceScarceResources()
-{
- Q_ASSERT(scarceResourcesRefCount > 0);
- scarceResourcesRefCount -= 1;
-
- // if the refcount is zero, then evaluation of the "top level"
- // expression must have completed. We can safely release the
- // scarce resources.
- if (Q_UNLIKELY(scarceResourcesRefCount == 0)) {
- // iterate through the list and release them all.
- // note that the actual SRD is owned by the JS engine,
- // so we cannot delete the SRD; but we can free the
- // memory used by the variant in the SRD.
- QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine());
- while (QV4::ExecutionEngine::ScarceResourceData *sr = engine->scarceResources.first()) {
- sr->data = QVariant();
- engine->scarceResources.remove(sr);
- }
+void QQmlEnginePrivate::cleanupScarceResources()
+{
+ // iterate through the list and release them all.
+ // note that the actual SRD is owned by the JS engine,
+ // so we cannot delete the SRD; but we can free the
+ // memory used by the variant in the SRD.
+ QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine());
+ while (QV4::ExecutionEngine::ScarceResourceData *sr = engine->scarceResources.first()) {
+ sr->data = QVariant();
+ engine->scarceResources.remove(sr);
}
}
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 92eadb0540..440840d3c9 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -267,6 +267,8 @@ private:
struct Deletable { Deletable():next(0) {} virtual ~Deletable() {} Deletable *next; };
QFieldList<Deletable, &Deletable::next> toDeleteInEngineThread;
void doDeleteInEngineThread();
+
+ void cleanupScarceResources();
};
/*
@@ -279,6 +281,26 @@ inline void QQmlEnginePrivate::referenceScarceResources()
scarceResourcesRefCount += 1;
}
+/*
+ This function should be called after evaluation of the js expression is
+ complete, and so the scarce resources may be freed safely.
+ */
+inline void QQmlEnginePrivate::dereferenceScarceResources()
+{
+ Q_ASSERT(scarceResourcesRefCount > 0);
+ scarceResourcesRefCount -= 1;
+
+ // if the refcount is zero, then evaluation of the "top level"
+ // expression must have completed. We can safely release the
+ // scarce resources.
+ if (scarceResourcesRefCount == 0) {
+ QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine());
+ if (Q_UNLIKELY(!engine->scarceResources.isEmpty())) {
+ cleanupScarceResources();
+ }
+ }
+}
+
/*!
Returns true if the calling thread is the QQmlEngine thread.
*/