summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-09-29 07:27:40 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-29 09:31:17 (GMT)
commitf10dc46c0a0763df4e136bd4664b68e1a1388ad6 (patch)
tree909cbb4944fed9a3914c55cf56c66245d66fe7a7
parentd2459611fd3650d8c80a3ccafd9ec3d58457a888 (diff)
downloadQt-f10dc46c0a0763df4e136bd4664b68e1a1388ad6.zip
Qt-f10dc46c0a0763df4e136bd4664b68e1a1388ad6.tar.gz
Qt-f10dc46c0a0763df4e136bd4664b68e1a1388ad6.tar.bz2
QScript: fix the way the js stack is advanced.
It is possible to call QScriptEngine::pushContext before we start any evaluation. We need to change JSC so it doesn't always start at the beginning of the stack. Also fix QScriptContext::pushContext not to waste space between callframes. Reviewed-by: Kent Hansen
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp8
-rw-r--r--src/script/api/qscriptengine.cpp6
2 files changed, 10 insertions, 4 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp
index bfb0307..4200023 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp
@@ -885,13 +885,21 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec
}
Register* oldEnd = m_registerFile.end();
+#ifdef QT_BUILD_SCRIPT_LIB //with QtScript, we do not necesserly start from scratch
+ Register* newEnd = oldEnd + globalRegisterOffset + codeBlock->m_numCalleeRegisters;
+#else
Register* newEnd = m_registerFile.start() + globalRegisterOffset + codeBlock->m_numCalleeRegisters;
+#endif
if (!m_registerFile.grow(newEnd)) {
*exception = createStackOverflowError(callFrame);
return jsNull();
}
+#ifdef QT_BUILD_SCRIPT_LIB //with QtScript, we do not necesserly start from scratch
+ CallFrame* newCallFrame = CallFrame::create(oldEnd + globalRegisterOffset);
+#else
CallFrame* newCallFrame = CallFrame::create(m_registerFile.start() + globalRegisterOffset);
+#endif
// a 0 codeBlock indicates a built-in caller
newCallFrame->r(codeBlock->thisRegister()) = JSValue(thisObj);
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index b27d1be..ee25239 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -2360,11 +2360,9 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV
JSC::Register *oldEnd = interp->registerFile().end();
int argc = args.size() + 1; //add "this"
JSC::Register *newEnd = oldEnd + argc + JSC::RegisterFile::CallFrameHeaderSize;
- //Without + argc + JSC::RegisterFile::CallFrameHeaderSize, it crashes.
- //It seems that JSC is not consistant with the way the callframe is crated
- if (!interp->registerFile().grow(newEnd + argc + JSC::RegisterFile::CallFrameHeaderSize))
+ if (!interp->registerFile().grow(newEnd))
return 0; //### Stack overflow
- newCallFrame = JSC::CallFrame::create(newEnd);
+ newCallFrame = JSC::CallFrame::create(oldEnd);
newCallFrame[0] = thisObject;
int dst = 0;
JSC::ArgList::const_iterator it;