Ignore:
Timestamp:
Jun 18, 2012, 11:07:28 PM (13 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Changed JSC to always record line number information so that error.stack
and window.onerror() can report proper line numbers.
https://bugs.webkit.org/show_bug.cgi?id=89410

Patch by Mark Lam <[email protected]> on 2012-06-18
Reviewed by Geoffrey Garen.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::lineNumberForBytecodeOffset):
(JSC::CodeBlock::shrinkToFit): m_lineInfo is now available unconditionally.

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addLineInfo):
(JSC::CodeBlock::hasLineInfo): Unused. Now removed.
(JSC::CodeBlock::needsCallReturnIndices):
(CodeBlock):
(RareData): Hoisted m_lineInfo out of m_rareData. m_lineInfo is now
filled in unconditionally.

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::addLineInfo):

LayoutTests: Ensure that error.stack and window.onerror always have the appropriate
line numbers of the exception being thrown.
https://bugs.webkit.org/show_bug.cgi?id=89410

Patch by Mark Lam <[email protected]> on 2012-06-18
Reviewed by Geoffrey Garen.

  • fast/js/exception-line-number-expected.txt: Added.
  • fast/js/exception-line-number.html: Added.
  • fast/js/script-tests/exception-line-number.js: Added.

(foo):
(window.onerror):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r120244 r120676  
    712712        void addLineInfo(unsigned bytecodeOffset, int lineNo)
    713713        {
    714             createRareDataIfNecessary();
    715             Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo;
     714            Vector<LineInfo>& lineInfo = m_lineInfo;
    716715            if (!lineInfo.size() || lineInfo.last().lineNumber != lineNo) {
    717716                LineInfo info = { bytecodeOffset, lineNo };
     
    721720
    722721        bool hasExpressionInfo() { return m_rareData && m_rareData->m_expressionInfo.size(); }
    723         bool hasLineInfo() { return m_rareData && m_rareData->m_lineInfo.size(); }
    724722        //  We only generate exception handling info if the user is debugging
    725723        // (and may want line number info), or if the function contains exception handler.
    726724        bool needsCallReturnIndices()
    727725        {
    728             return m_rareData &&
    729                 (m_rareData->m_expressionInfo.size() || m_rareData->m_lineInfo.size() || m_rareData->m_exceptionHandlers.size());
     726            return true || (m_rareData
     727                && (m_rareData->m_expressionInfo.size() || m_rareData->m_exceptionHandlers.size()));
    730728        }
    731729
     
    13121310        uint16_t m_optimizationDelayCounter;
    13131311        uint16_t m_reoptimizationRetryCounter;
    1314        
     1312
     1313        Vector<LineInfo> m_lineInfo;
     1314
    13151315        struct RareData {
    13161316           WTF_MAKE_FAST_ALLOCATED;
     
    13341334            Vector<ExpressionRangeInfo> m_expressionInfo;
    13351335            // Line info - present if profiling or debugging.
    1336             Vector<LineInfo> m_lineInfo;
    13371336#if ENABLE(JIT)
    13381337            Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector;
Note: See TracChangeset for help on using the changeset viewer.