diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2016-04-06 11:23:11 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-05-04 08:31:00 +0000 |
commit | 9a7cf067a178c7a08a7ed9f2c6253e1feade5569 (patch) | |
tree | 2151b6e6e8ce00a76cef15a28c08b99f60fa0bf9 /src/qml/qml/qqmlengine_p.h | |
parent | 6bead0e730ebf89a6c83de9bf03fad5f9aa56fe3 (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: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmlengine_p.h')
-rw-r--r-- | src/qml/qml/qqmlengine_p.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index df73118b36..003cfa0112 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 (Q_LIKELY(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. */ |