Changeset 108681 in webkit


Ignore:
Timestamp:
Feb 23, 2012 3:18:05 PM (12 years ago)
Author:
oliver@apple.com
Message:

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):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r108677 r108681  
     12012-02-23  Oliver Hunt  <oliver@apple.com>
     2
     3        Make Interpreter::getStackTrace be able to generate the line number for the top callframe if none is provided
     4        https://bugs.webkit.org/show_bug.cgi?id=79407
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Outside of exception handling, we don't know what our source line number is.  This
     9        change allows us to pass -1 is as the initial line number, and get the correct line
     10        number in the resultant stack trace.  We can't completely elide the initial line
     11        number (yet) due to some idiosyncrasies of the exception handling machinery.
     12
     13        * interpreter/Interpreter.cpp:
     14        (JSC::getLineNumberForCallFrame):
     15        (JSC):
     16        (JSC::Interpreter::getStackTrace):
     17
    1182012-02-22  Filip Pizlo  <fpizlo@apple.com>
    219
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r108444 r108681  
    818818}
    819819
     820static int getLineNumberForCallFrame(CallFrame* callFrame)
     821{
     822    callFrame = callFrame->removeHostCallFrameFlag();
     823    CodeBlock* codeBlock = callFrame->codeBlock();
     824    if (!codeBlock)
     825        return -1;
     826#if ENABLE(INTERPRETER)
     827    if (!globalData->canUseJIT())
     828        return codeBlock->lineNumberForBytecodeOffset(callFrame->bytecodeOffsetForNonDFGCode() - 1);
     829#endif
     830#if ENABLE(JIT)
     831#if ENABLE(DFG_JIT)
     832    if (codeBlock->getJITType() == JITCode::DFGJIT)
     833        return codeBlock->lineNumberForBytecodeOffset(codeBlock->codeOrigin(callFrame->codeOriginIndexForDFG()).bytecodeIndex);
     834#endif
     835    return codeBlock->lineNumberForBytecodeOffset(callFrame->bytecodeOffsetForNonDFGCode());
     836#endif
     837}
     838
    820839static CallFrame* getCallerInfo(JSGlobalData* globalData, CallFrame* callFrame, int& lineNumber)
    821840{
     
    930949        return;
    931950
     951    if (line == -1)
     952        line = getLineNumberForCallFrame(callFrame);
     953   
    932954    while (callFrame && callFrame != CallFrame::noCaller()) {
    933955        UString sourceURL;
Note: See TracChangeset for help on using the changeset viewer.