summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-11-10 04:36:01 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-11-10 04:36:01 (GMT)
commit364f783827e2f304b67dc7b0027a76641d1a67b5 (patch)
treea83ab49ea0bda77f6c44d1e01a27905404a2af96 /src/script/api/qscriptengine.cpp
parentca199c62e0a0da82ac086eea1462073d519ea7e9 (diff)
parenteba8efb5b91baea88ca94da181fd746c6e9252ec (diff)
downloadQt-364f783827e2f304b67dc7b0027a76641d1a67b5.zip
Qt-364f783827e2f304b67dc7b0027a76641d1a67b5.tar.gz
Qt-364f783827e2f304b67dc7b0027a76641d1a67b5.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 2b60a46..216f325 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1093,6 +1093,8 @@ void QScriptEnginePrivate::setContextFlags(JSC::ExecState *exec, uint flags)
void QScriptEnginePrivate::mark(JSC::MarkStack& markStack)
{
+ Q_Q(QScriptEngine);
+
markStack.append(originalGlobalObject());
markStack.append(globalObject());
if (originalGlobalObjectProxy)
@@ -1130,6 +1132,22 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack)
markStack.append((*it)->prototype);
}
}
+
+ {
+ QScriptContext *context = q->currentContext();
+
+ while (context) {
+ JSC::ScopeChainNode *node = frameForContext(context)->scopeChain();
+ JSC::ScopeChainIterator it(node);
+ for (it = node->begin(); it != node->end(); ++it) {
+ JSC::JSObject *object = *it;
+ if (object)
+ markStack.append(object);
+ }
+
+ context = context->parentContext();
+ }
+ }
}
bool QScriptEnginePrivate::isCollecting() const
@@ -2281,7 +2299,8 @@ QScriptContext *QScriptEngine::pushContext()
return the new top frame. (might be the same as exec if a new stackframe was not needed) or 0 if stack overflow
*/
JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSValue _thisObject,
- const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor)
+ const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor,
+ bool clearScopeChain)
{
JSC::JSValue thisObject = _thisObject;
if (calledAsConstructor) {
@@ -2315,7 +2334,14 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV
for (it = args.begin(); it != args.end(); ++it)
newCallFrame[++dst] = *it;
newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize;
- newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
+
+ if (!clearScopeChain) {
+ newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
+ } else {
+ JSC::JSObject *jscObject = originalGlobalObject();
+ JSC::ScopeChainNode *scn = new JSC::ScopeChainNode(0, jscObject, &exec->globalData(), jscObject);
+ newCallFrame->init(0, /*vPC=*/0, scn, exec, flags | ShouldRestoreCallFrame, argc, callee);
+ }
} else {
setContextFlags(newCallFrame, flags);
#if ENABLE(JIT)