From 22e4a74ff1e9bac5faa14e508579c64e647181a0 Mon Sep 17 00:00:00 2001 From: "oliver@apple.com" Date: Thu, 23 Feb 2012 23:18:05 +0000 Subject: [PATCH] Make Interpreter::getStackTrace be able to generate the line number for the top callframe if none is provided https://bugs.webkit.org/show_bug.cgi?id=79407 Reviewed by Gavin Barraclough. Outside of exception handling, we don't know what our source line number is. This change allows us to pass -1 is as the initial line number, and get the correct line number in the resultant stack trace. We can't completely elide the initial line number (yet) due to some idiosyncrasies of the exception handling machinery. * interpreter/Interpreter.cpp: (JSC::getLineNumberForCallFrame): (JSC): (JSC::Interpreter::getStackTrace): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108681 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/JavaScriptCore/ChangeLog | 17 +++++++++++++++++ Source/JavaScriptCore/interpreter/Interpreter.cpp | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 8099f61..cb388cb 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,20 @@ +2012-02-23 Oliver Hunt + + Make Interpreter::getStackTrace be able to generate the line number for the top callframe if none is provided + https://bugs.webkit.org/show_bug.cgi?id=79407 + + Reviewed by Gavin Barraclough. + + Outside of exception handling, we don't know what our source line number is. This + change allows us to pass -1 is as the initial line number, and get the correct line + number in the resultant stack trace. We can't completely elide the initial line + number (yet) due to some idiosyncrasies of the exception handling machinery. + + * interpreter/Interpreter.cpp: + (JSC::getLineNumberForCallFrame): + (JSC): + (JSC::Interpreter::getStackTrace): + 2012-02-22 Filip Pizlo DFG OSR exit value profiling should have graceful handling of local variables and arguments diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp index eb6a29d..336f109 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.cpp +++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp @@ -817,6 +817,25 @@ static void appendSourceToError(CallFrame* callFrame, ErrorInstance* exception, exception->putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, message)); } +static int getLineNumberForCallFrame(CallFrame* callFrame) +{ + callFrame = callFrame->removeHostCallFrameFlag(); + CodeBlock* codeBlock = callFrame->codeBlock(); + if (!codeBlock) + return -1; +#if ENABLE(INTERPRETER) + if (!globalData->canUseJIT()) + return codeBlock->lineNumberForBytecodeOffset(callFrame->bytecodeOffsetForNonDFGCode() - 1); +#endif +#if ENABLE(JIT) +#if ENABLE(DFG_JIT) + if (codeBlock->getJITType() == JITCode::DFGJIT) + return codeBlock->lineNumberForBytecodeOffset(codeBlock->codeOrigin(callFrame->codeOriginIndexForDFG()).bytecodeIndex); +#endif + return codeBlock->lineNumberForBytecodeOffset(callFrame->bytecodeOffsetForNonDFGCode()); +#endif +} + static CallFrame* getCallerInfo(JSGlobalData* globalData, CallFrame* callFrame, int& lineNumber) { UNUSED_PARAM(globalData); @@ -929,6 +948,9 @@ void Interpreter::getStackTrace(JSGlobalData* globalData, int line, VectorcodeBlock()) { -- 2.7.4