diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-11 07:29:36 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-11 07:29:36 (GMT) |
commit | 2fdff951927ac4f2aab47c423e73d002b3bed628 (patch) | |
tree | 55741f0fd22784b9bbe8569ea741cf74e9ebd1dd /src | |
parent | 3cd1422bbc106ebe4bf14b4af14c90971fe416eb (diff) | |
download | Qt-2fdff951927ac4f2aab47c423e73d002b3bed628.zip Qt-2fdff951927ac4f2aab47c423e73d002b3bed628.tar.gz Qt-2fdff951927ac4f2aab47c423e73d002b3bed628.tar.bz2 |
Calls to JSC::Debugger's new events that where created in
b62ab93d001d2f3238e24faa133720cb877e3023 commit.
In CallData and ConstructData native function call were replaced by
class with operator() that decorate every call with debugger->functionEntry
and debugger->functionExit events.
In Interpreter new debugger calls for functionExit, functionEntry,
exceptionThrow and exceptionCatch events where created
Diffstat (limited to 'src')
5 files changed, 129 insertions, 4 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp index 0c3081c..fe663ae 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp @@ -550,7 +550,8 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV } } - if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) { + Debugger* debugger = callFrame->dynamicGlobalObject()->debugger(); + if (debugger) { DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue); debugger->exception(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset)); } @@ -575,10 +576,18 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV HandlerInfo* handler = 0; while (!(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) { - if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) + if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) { +#ifdef QT_BUILD_SCRIPT_LIB + if (debugger) + debugger->exceptionThrow(DebuggerCallFrame(callFrame, exceptionValue), codeBlock->ownerNode()->sourceID(),false); +#endif return 0; + } } - +#ifdef QT_BUILD_SCRIPT_LIB + if (debugger) + debugger->exceptionThrow(DebuggerCallFrame(callFrame, exceptionValue), codeBlock->ownerNode()->sourceID(),true); +#endif // Now unwind the scope chain within the exception handler's call frame. ScopeChainNode* scopeChain = callFrame->scopeChain(); @@ -3303,17 +3312,27 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi register base to those of the calling function. */ +#ifdef QT_BUILD_SCRIPT_LIB + Debugger* debugger = callFrame->dynamicGlobalObject()->debugger(); + intptr_t sourceId = callFrame->codeBlock()->source()->asID(); +#endif + int result = (++vPC)->u.operand; if (callFrame->codeBlock()->needsFullScopeChain()) callFrame->scopeChain()->deref(); JSValue returnValue = callFrame->r(result).jsValue(); +#ifdef QT_BUILD_SCRIPT_LIB + if (debugger) { + debugger->functionExit(returnValue, sourceId); + } +#endif vPC = callFrame->returnPC(); int dst = callFrame->returnValueRegister(); callFrame = callFrame->callerFrame(); - + if (callFrame->hasHostCallFrameFlag()) return returnValue; @@ -3674,6 +3693,16 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi */ ASSERT(exceptionValue); ASSERT(!globalData->exception); + +#ifdef QT_BUILD_SCRIPT_LIB + CodeBlock* codeBlock = callFrame->codeBlock(); + Debugger* debugger = callFrame->dynamicGlobalObject()->debugger(); + if (debugger) { + DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue); + debugger->exceptionCatch(debuggerCallFrame, codeBlock->ownerNode()->sourceID()); + } +#endif + int ex = (++vPC)->u.operand; callFrame->r(ex) = exceptionValue; exceptionValue = JSValue(); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp index f13be43..b33c8ba 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp @@ -31,9 +31,32 @@ #endif #include "JSFunction.h" +#include "JSGlobalObject.h" + +#ifdef QT_BUILD_SCRIPT_LIB +#include "Debugger.h" +#include "DebuggerCallFrame.h" +#endif namespace JSC { +#ifdef QT_BUILD_SCRIPT_LIB +JSValue JSC::NativeFuncWrapper::operator() (ExecState* exec, JSObject* jsobj, JSValue thisValue, const ArgList& argList) const +{ + Debugger* debugger = exec->lexicalGlobalObject()->debugger(); + if (debugger) + debugger->callEvent(DebuggerCallFrame(exec), -1, -1); + + JSValue returnValue = ptr(exec, jsobj, thisValue, argList); + + if (debugger) + debugger->functionExit(returnValue, -1); + + return returnValue; +} +#endif + + JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args) { if (callType == CallTypeHost) { diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.h b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.h index d5b0172..5e02945 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.h @@ -48,9 +48,31 @@ namespace JSC { typedef JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*, JSObject*, JSValue thisValue, const ArgList&); +#ifdef QT_BUILD_SCRIPT_LIB + class NativeFuncWrapper + { + NativeFunction ptr; + public: + inline NativeFuncWrapper& operator=(NativeFunction func) + { + ptr = func; + return *this; + } + inline operator NativeFunction() const {return ptr;} + inline operator bool() const {return ptr;} + inline bool operator==(int val) const {return (int)ptr==val;} + + JSValue operator()(ExecState* exec, JSObject* jsobj, JSValue thisValue, const ArgList& argList) const; + }; +#endif + union CallData { struct { +#ifndef QT_BUILD_SCRIPT_LIB NativeFunction function; +#else + NativeFuncWrapper function; +#endif } native; struct { FunctionBodyNode* functionBody; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp index c3b2eeb..5fe792f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp @@ -34,8 +34,30 @@ #include "JSFunction.h" + +#ifdef QT_BUILD_SCRIPT_LIB +#include "Debugger.h" +#include "DebuggerCallFrame.h" +#endif + namespace JSC { +#ifdef QT_BUILD_SCRIPT_LIB +JSObject* JSC::NativeConstrWrapper::operator() (ExecState* exec, JSObject* jsobj, const ArgList& argList) const +{ + Debugger* debugger = exec->lexicalGlobalObject()->debugger(); + if (debugger) + debugger->callEvent(DebuggerCallFrame(exec), -1, -1); + + JSObject* returnValue = ptr(exec, jsobj, argList); + + if ((debugger) && (callDebuggerFunctionExit)) + debugger->functionExit(JSValue(returnValue), -1); + + return returnValue; +} +#endif + JSObject* construct(ExecState* exec, JSValue callee, ConstructType constructType, const ConstructData& constructData, const ArgList& args) { if (constructType == ConstructTypeHost) { diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.h b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.h index 9d580d5..be49e68 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.h @@ -46,9 +46,38 @@ namespace JSC { typedef JSObject* (*NativeConstructor)(ExecState*, JSObject*, const ArgList&); +#ifdef QT_BUILD_SCRIPT_LIB + class NativeConstrWrapper + { + NativeConstructor ptr; + //Hack. If this variable is true and if debugger is attached at the end of + //operator() execution functionExit event will be created (in most cases it will be default) + //This variable was created because of FunctionWrapper::proxyCall method that change result + //on fly. Event shuld be created with original value so the method should call it itself. + bool callDebuggerFunctionExit; + public: + inline NativeConstrWrapper& operator=(NativeConstructor func) + { + callDebuggerFunctionExit = true; + ptr = func; + return *this; + } + inline operator NativeConstructor() const {return ptr;} + inline operator bool() const {return ptr;} + inline bool operator==(int val) const {return (int)ptr==val;} + + inline void doNotCallDebuggerFunctionExit() {callDebuggerFunctionExit = false;} + JSObject* operator()(ExecState*, JSObject*, const ArgList&) const; + }; +#endif + union ConstructData { struct { +#ifndef QT_BUILD_SCRIPT_LIB NativeConstructor function; +#else + NativeConstrWrapper function; +#endif } native; struct { FunctionBodyNode* functionBody; |