Changeset 208830 in webkit


Ignore:
Timestamp:
Nov 16, 2016, 5:02:06 PM (9 years ago)
Author:
ggaren@apple.com
Message:

UnlinkedCodeBlock should not have a starting line number
https://bugs.webkit.org/show_bug.cgi?id=164838

Reviewed by Mark Lam.

Here's how the starting line number in UnlinkedCodeBlock used to work:

(1) Assign the source code starting line number to the parser starting
line number.

(2) Assign (1) to the AST.

(3) Subtract (1) from (2) and assign to UnlinkedCodeBlock.

Then, when linking:

(4) Add (3) to (1).

This was an awesome no-op.

Generally, unlinked code is code that is not tied to any particular
web page or resource. So, it's inappropriate to think of it having a
starting line number.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::recordParse):
(JSC::UnlinkedCodeBlock::hasCapturedVariables):
(JSC::UnlinkedCodeBlock::firstLine): Deleted.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getUnlinkedGlobalCodeBlock):

  • runtime/CodeCache.h:

(JSC::generateUnlinkedCodeBlock):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r208824 r208830  
     12016-11-16  Geoffrey Garen  <ggaren@apple.com>
     2
     3        UnlinkedCodeBlock should not have a starting line number
     4        https://bugs.webkit.org/show_bug.cgi?id=164838
     5
     6        Reviewed by Mark Lam.
     7
     8        Here's how the starting line number in UnlinkedCodeBlock used to work:
     9
     10        (1) Assign the source code starting line number to the parser starting
     11        line number.
     12
     13        (2) Assign (1) to the AST.
     14
     15        (3) Subtract (1) from (2) and assign to UnlinkedCodeBlock.
     16
     17        Then, when linking:
     18
     19        (4) Add (3) to (1).
     20
     21        This was an awesome no-op.
     22
     23        Generally, unlinked code is code that is not tied to any particular
     24        web page or resource. So, it's inappropriate to think of it having a
     25        starting line number.
     26
     27        * bytecode/UnlinkedCodeBlock.cpp:
     28        (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
     29        * bytecode/UnlinkedCodeBlock.h:
     30        (JSC::UnlinkedCodeBlock::recordParse):
     31        (JSC::UnlinkedCodeBlock::hasCapturedVariables):
     32        (JSC::UnlinkedCodeBlock::firstLine): Deleted.
     33        * runtime/CodeCache.cpp:
     34        (JSC::CodeCache::getUnlinkedGlobalCodeBlock):
     35        * runtime/CodeCache.h:
     36        (JSC::generateUnlinkedCodeBlock):
     37
    1382016-11-16  Yusuke Suzuki  <utatane.tea@gmail.com>
    239
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r208312 r208830  
    7171    , m_derivedContextType(static_cast<unsigned>(info.derivedContextType()))
    7272    , m_evalContextType(static_cast<unsigned>(info.evalContextType()))
    73     , m_firstLine(0)
    7473    , m_lineCount(0)
    7574    , m_endColumn(UINT_MAX)
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r208637 r208830  
    348348    bool typeProfilerExpressionInfoForBytecodeOffset(unsigned bytecodeOffset, unsigned& startDivot, unsigned& endDivot);
    349349
    350     void recordParse(CodeFeatures features, bool hasCapturedVariables, unsigned firstLine, unsigned lineCount, unsigned endColumn)
     350    void recordParse(CodeFeatures features, bool hasCapturedVariables, unsigned lineCount, unsigned endColumn)
    351351    {
    352352        m_features = features;
    353353        m_hasCapturedVariables = hasCapturedVariables;
    354         m_firstLine = firstLine;
    355354        m_lineCount = lineCount;
    356355        // For the UnlinkedCodeBlock, startColumn is always 0.
     
    365364    CodeFeatures codeFeatures() const { return m_features; }
    366365    bool hasCapturedVariables() const { return m_hasCapturedVariables; }
    367     unsigned firstLine() const { return m_firstLine; }
    368366    unsigned lineCount() const { return m_lineCount; }
    369367    ALWAYS_INLINE unsigned startColumn() const { return 0; }
     
    437435    unsigned m_derivedContextType : 2;
    438436    unsigned m_evalContextType : 2;
    439     unsigned m_firstLine;
    440437    unsigned m_lineCount;
    441438    unsigned m_endColumn;
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r208768 r208830  
    6262    if (cache && Options::useCodeCache()) {
    6363        UnlinkedCodeBlockType* unlinkedCodeBlock = jsCast<UnlinkedCodeBlockType*>(cache->cell.get());
    64         unsigned firstLine = source.firstLine() + unlinkedCodeBlock->firstLine();
    6564        unsigned lineCount = unlinkedCodeBlock->lineCount();
    6665        unsigned startColumn = unlinkedCodeBlock->startColumn() + source.startColumn();
    6766        bool endColumnIsOnStartLine = !lineCount;
    6867        unsigned endColumn = unlinkedCodeBlock->endColumn() + (endColumnIsOnStartLine ? startColumn : 1);
    69         executable->recordParse(unlinkedCodeBlock->codeFeatures(), unlinkedCodeBlock->hasCapturedVariables(), firstLine, firstLine + lineCount, startColumn, endColumn);
     68        executable->recordParse(unlinkedCodeBlock->codeFeatures(), unlinkedCodeBlock->hasCapturedVariables(), source.firstLine(), source.firstLine() + lineCount, startColumn, endColumn);
    7069        source.provider()->setSourceURLDirective(unlinkedCodeBlock->sourceURLDirective());
    7170        source.provider()->setSourceMappingURLDirective(unlinkedCodeBlock->sourceMappingURLDirective());
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r208768 r208830  
    247247
    248248    UnlinkedCodeBlockType* unlinkedCodeBlock = UnlinkedCodeBlockType::create(&vm, executable->executableInfo(), debuggerMode);
    249     unlinkedCodeBlock->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), rootNode->firstLine() - source.firstLine(), lineCount, unlinkedEndColumn);
     249    unlinkedCodeBlock->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), lineCount, unlinkedEndColumn);
    250250    unlinkedCodeBlock->setSourceURLDirective(source.provider()->sourceURL());
    251251    unlinkedCodeBlock->setSourceMappingURLDirective(source.provider()->sourceMappingURL());
Note: See TracChangeset for help on using the changeset viewer.