Ignore:
Timestamp:
Dec 1, 2016, 4:24:17 PM (8 years ago)
Author:
[email protected]
Message:

SourceCodeKey should use unlinked source code
https://bugs.webkit.org/show_bug.cgi?id=165286

Reviewed by Saam Barati.

This patch splits out UnlinkedSourceCode from SourceCode, and deploys
UnlinkedSourceCode in SourceCodeKey.

It's misleading to store SourceCode in SourceCodeKey because SourceCode
has an absolute location whereas unlinked cached code has no location.

I plan to deploy UnlinkedSourceCode in more places, to indicate code
that has no absolute location.

(JSC::UnlinkedSourceCode::toUTF8):
(JSC::SourceCode::toUTF8): Deleted.

  • parser/SourceCode.h:

(JSC::SourceCode::SourceCode):
(JSC::SourceCode::startColumn):
(JSC::SourceCode::isHashTableDeletedValue): Deleted.
(JSC::SourceCode::hash): Deleted.
(JSC::SourceCode::view): Deleted.
(JSC::SourceCode::providerID): Deleted.
(JSC::SourceCode::isNull): Deleted.
(JSC::SourceCode::provider): Deleted.
(JSC::SourceCode::startOffset): Deleted.
(JSC::SourceCode::endOffset): Deleted.
(JSC::SourceCode::length): Deleted. Move a bunch of stuff in to a new
base class, UnlinkedSourceCode.

  • parser/SourceCodeKey.h:

(JSC::SourceCodeKey::SourceCodeKey): Use UnlinkedSourceCode since code
in the cache has no location.

  • parser/UnlinkedSourceCode.h: Copied from Source/JavaScriptCore/parser/SourceCode.h.

(JSC::UnlinkedSourceCode::UnlinkedSourceCode):
(JSC::UnlinkedSourceCode::provider):
(JSC::SourceCode::SourceCode): Deleted.
(JSC::SourceCode::isHashTableDeletedValue): Deleted.
(JSC::SourceCode::hash): Deleted.
(JSC::SourceCode::view): Deleted.
(JSC::SourceCode::providerID): Deleted.
(JSC::SourceCode::isNull): Deleted.
(JSC::SourceCode::provider): Deleted.
(JSC::SourceCode::firstLine): Deleted.
(JSC::SourceCode::startColumn): Deleted.
(JSC::SourceCode::startOffset): Deleted.
(JSC::SourceCode::endOffset): Deleted.
(JSC::SourceCode::length): Deleted.
(JSC::makeSource): Deleted.
(JSC::SourceCode::subExpression): Deleted.

  • runtime/CodeCache.h: Use UnlinkedSourceCode in the cache.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceCode.h

    r206653 r209220  
    2929#pragma once
    3030
    31 #include "SourceProvider.h"
    32 #include <wtf/RefPtr.h>
     31#include "UnlinkedSourceCode.h"
    3332
    3433namespace JSC {
    3534
    36     class SourceCode {
     35    class SourceCode : public UnlinkedSourceCode {
    3736    public:
    3837        SourceCode()
    39             : m_provider(0)
    40             , m_startChar(0)
    41             , m_endChar(0)
     38            : UnlinkedSourceCode()
    4239            , m_firstLine(0)
    4340            , m_startColumn(0)
     
    4542        }
    4643
    47         SourceCode(WTF::HashTableDeletedValueType)
    48             : m_provider(WTF::HashTableDeletedValue)
    49         {
    50         }
    51 
    5244        SourceCode(PassRefPtr<SourceProvider> provider)
    53             : m_provider(provider)
    54             , m_startChar(0)
    55             , m_endChar(m_provider->source().length())
     45            : UnlinkedSourceCode(provider)
    5646            , m_firstLine(1)
    5747            , m_startColumn(1)
     
    6050
    6151        SourceCode(PassRefPtr<SourceProvider> provider, int firstLine, int startColumn)
    62             : m_provider(provider)
    63             , m_startChar(0)
    64             , m_endChar(m_provider->source().length())
     52            : UnlinkedSourceCode(provider)
    6553            , m_firstLine(std::max(firstLine, 1))
    6654            , m_startColumn(std::max(startColumn, 1))
     
    6856        }
    6957
    70         SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine, int startColumn)
    71             : m_provider(provider)
    72             , m_startChar(start)
    73             , m_endChar(end)
     58        SourceCode(PassRefPtr<SourceProvider> provider, int startOffset, int endOffset, int firstLine, int startColumn)
     59            : UnlinkedSourceCode(provider, startOffset, endOffset)
    7460            , m_firstLine(std::max(firstLine, 1))
    7561            , m_startColumn(std::max(startColumn, 1))
     
    7763        }
    7864
    79         bool isHashTableDeletedValue() const { return m_provider.isHashTableDeletedValue(); }
     65        int firstLine() const { return m_firstLine; }
     66        int startColumn() const { return m_startColumn; }
    8067
    81         unsigned hash() const
    82         {
    83             ASSERT(m_provider);
    84             return m_provider->hash();
    85         }
    86 
    87         StringView view() const
    88         {
    89             if (!m_provider)
    90                 return StringView();
    91             return m_provider->getRange(m_startChar, m_endChar);
    92         }
    93        
    94         CString toUTF8() const;
    95        
    9668        intptr_t providerID() const
    9769        {
     
    10072            return m_provider->asID();
    10173        }
    102        
    103         bool isNull() const { return !m_provider; }
     74
    10475        SourceProvider* provider() const { return m_provider.get(); }
    105         int firstLine() const { return m_firstLine; }
    106         int startColumn() const { return m_startColumn; }
    107         int startOffset() const { return m_startChar; }
    108         int endOffset() const { return m_endChar; }
    109         int length() const { return m_endChar - m_startChar; }
    110        
     76
    11177        SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn);
    11278
    11379    private:
    114         RefPtr<SourceProvider> m_provider;
    115         int m_startChar;
    116         int m_endChar;
    11780        int m_firstLine;
    11881        int m_startColumn;
Note: See TracChangeset for help on using the changeset viewer.