From 37bd7a5711e57ea8c45ae75102ddee3ab905a0e5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 5 Oct 2009 19:16:37 +0200 Subject: QScript: do not crash on PowerPC There is no 'this' register in the global context. The computation of the this register for the global context gives the 'codeBlock' register in the frame header. On Intel processor, a JSValue() is 0x0 when converted to a pointer, but this is not the case on PowerPC (it is 0xfffffff9) so it just crash later when acessing the code block. Solution: special condition for the global context when getting the 'this' object Reviewed-by: Kent Hansen --- src/script/api/qscriptengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 09042e1..3402190 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -805,7 +805,6 @@ QScriptEnginePrivate::QScriptEnginePrivate() JSC::JSGlobalObject *globalObject = new (globalData)QScript::GlobalObject(); JSC::ExecState* exec = globalObject->globalExec(); - *thisRegisterForFrame(exec) = JSC::JSValue(); scriptObjectStructure = QScriptObject::createStructure(globalObject->objectPrototype()); @@ -1079,12 +1078,13 @@ JSC::JSValue QScriptEnginePrivate::toUsableValue(JSC::JSValue value) /*! \internal Return the 'this' value for a given context - The result may be null for the global context */ JSC::JSValue QScriptEnginePrivate::thisForContext(JSC::ExecState *frame) { if (frame->codeBlock() != 0) { return frame->thisValue(); + } else if(frame == frame->lexicalGlobalObject()->globalExec()) { + return frame->globalThisValue(); } else { JSC::Register *thisRegister = thisRegisterForFrame(frame); return thisRegister->jsValue(); -- cgit v0.12