diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-02-25 15:45:34 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2011-02-25 16:09:23 (GMT) |
commit | aa1e47a5a1a0978979e98f503cb44c85fc88dece (patch) | |
tree | 970ffd0fe292c45296561e5403d76627da21cb2d /src/script | |
parent | 2af7bc6259e41415817cadb456909f33249225ed (diff) | |
download | Qt-aa1e47a5a1a0978979e98f503cb44c85fc88dece.zip Qt-aa1e47a5a1a0978979e98f503cb44c85fc88dece.tar.gz Qt-aa1e47a5a1a0978979e98f503cb44c85fc88dece.tar.bz2 |
Make QtScript support COLLECT_ON_EVERY_ALLOCATION define
JSC has a define in runtime/Collector.cpp that can be enabled
to force garbage collection on every allocation. This can be
useful when investigating GC-related issues.
When the define is enabled, GC callbacks will happen before the
QScriptEngine(Private) is completely initialized, so we need to
initialize some things earlier (nice cleanup, actually), and
add some guards in the marking callback.
All tests pass with define off and on.
Task-number: QTBUG-17781
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 9e880b6..160058e 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -955,8 +955,11 @@ static QScriptValue __setupPackage__(QScriptContext *ctx, QScriptEngine *eng) } // namespace QScript QScriptEnginePrivate::QScriptEnginePrivate() - : registeredScriptValues(0), freeScriptValues(0), freeScriptValuesCount(0), - registeredScriptStrings(0), inEval(false) + : originalGlobalObjectProxy(0), currentFrame(0), + qobjectPrototype(0), qmetaobjectPrototype(0), variantPrototype(0), + activeAgent(0), agentLineNumber(-1), + registeredScriptValues(0), freeScriptValues(0), freeScriptValuesCount(0), + registeredScriptStrings(0), processEventsInterval(-1), inEval(false) { qMetaTypeId<QScriptValue>(); qMetaTypeId<QList<int> >(); @@ -1002,10 +1005,6 @@ QScriptEnginePrivate::QScriptEnginePrivate() currentFrame = exec; - originalGlobalObjectProxy = 0; - activeAgent = 0; - agentLineNumber = -1; - processEventsInterval = -1; cachedTranslationUrl = JSC::UString(); cachedTranslationContext = JSC::UString(); JSC::setCurrentIdentifierTable(oldTable); @@ -1253,10 +1252,12 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack) { Q_Q(QScriptEngine); - markStack.append(originalGlobalObject()); - markStack.append(globalObject()); - if (originalGlobalObjectProxy) - markStack.append(originalGlobalObjectProxy); + if (originalGlobalObject()) { + markStack.append(originalGlobalObject()); + markStack.append(globalObject()); + if (originalGlobalObjectProxy) + markStack.append(originalGlobalObjectProxy); + } if (qobjectPrototype) markStack.append(qobjectPrototype); @@ -1281,7 +1282,7 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack) } } - { + if (q) { QScriptContext *context = q->currentContext(); while (context) { |