Changeset 209220 in webkit


Ignore:
Timestamp:
Dec 1, 2016 4:24:17 PM (7 years ago)
Author:
ggaren@apple.com
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.
Location:
trunk/Source/JavaScriptCore
Files:
6 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r209123 r209220  
    624624    parser/Parser.cpp
    625625    parser/ParserArena.cpp
    626     parser/SourceCode.cpp
    627626    parser/SourceProvider.cpp
    628627    parser/SourceProviderCache.cpp
     628    parser/UnlinkedSourceCode.cpp
    629629    parser/VariableEnvironment.cpp
    630630
  • trunk/Source/JavaScriptCore/ChangeLog

    r209204 r209220  
     12016-12-01  Geoffrey Garen  <ggaren@apple.com>
     2
     3        SourceCodeKey should use unlinked source code
     4        https://bugs.webkit.org/show_bug.cgi?id=165286
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch splits out UnlinkedSourceCode from SourceCode, and deploys
     9        UnlinkedSourceCode in SourceCodeKey.
     10
     11        It's misleading to store SourceCode in SourceCodeKey because SourceCode
     12        has an absolute location whereas unlinked cached code has no location.
     13
     14        I plan to deploy UnlinkedSourceCode in more places, to indicate code
     15        that has no absolute location.
     16
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * parser/SourceCode.cpp:
     19        (JSC::UnlinkedSourceCode::toUTF8):
     20        (JSC::SourceCode::toUTF8): Deleted.
     21        * parser/SourceCode.h:
     22        (JSC::SourceCode::SourceCode):
     23        (JSC::SourceCode::startColumn):
     24        (JSC::SourceCode::isHashTableDeletedValue): Deleted.
     25        (JSC::SourceCode::hash): Deleted.
     26        (JSC::SourceCode::view): Deleted.
     27        (JSC::SourceCode::providerID): Deleted.
     28        (JSC::SourceCode::isNull): Deleted.
     29        (JSC::SourceCode::provider): Deleted.
     30        (JSC::SourceCode::startOffset): Deleted.
     31        (JSC::SourceCode::endOffset): Deleted.
     32        (JSC::SourceCode::length): Deleted. Move a bunch of stuff in to a new
     33        base class, UnlinkedSourceCode.
     34
     35        * parser/SourceCodeKey.h:
     36        (JSC::SourceCodeKey::SourceCodeKey): Use UnlinkedSourceCode since code
     37        in the cache has no location.
     38
     39        * parser/UnlinkedSourceCode.h: Copied from Source/JavaScriptCore/parser/SourceCode.h.
     40        (JSC::UnlinkedSourceCode::UnlinkedSourceCode):
     41        (JSC::UnlinkedSourceCode::provider):
     42        (JSC::SourceCode::SourceCode): Deleted.
     43        (JSC::SourceCode::isHashTableDeletedValue): Deleted.
     44        (JSC::SourceCode::hash): Deleted.
     45        (JSC::SourceCode::view): Deleted.
     46        (JSC::SourceCode::providerID): Deleted.
     47        (JSC::SourceCode::isNull): Deleted.
     48        (JSC::SourceCode::provider): Deleted.
     49        (JSC::SourceCode::firstLine): Deleted.
     50        (JSC::SourceCode::startColumn): Deleted.
     51        (JSC::SourceCode::startOffset): Deleted.
     52        (JSC::SourceCode::endOffset): Deleted.
     53        (JSC::SourceCode::length): Deleted.
     54        (JSC::makeSource): Deleted.
     55        (JSC::SourceCode::subExpression): Deleted.
     56
     57        * runtime/CodeCache.h: Use UnlinkedSourceCode in the cache.
     58
    1592016-12-01  Keith Miller  <keith_miller@apple.com>
    260
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r209201 r209220  
    538538                0F8F2B99172F04FF007DBDA5 /* DFGDesiredIdentifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F2B97172F04FD007DBDA5 /* DFGDesiredIdentifiers.cpp */; };
    539539                0F8F2B9A172F0501007DBDA5 /* DFGDesiredIdentifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8F2B98172F04FD007DBDA5 /* DFGDesiredIdentifiers.h */; };
    540                 0F8F2B9E17306C8D007DBDA5 /* SourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F2B9D17306C8B007DBDA5 /* SourceCode.cpp */; };
     540                0F8F2B9E17306C8D007DBDA5 /* UnlinkedSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F2B9D17306C8B007DBDA5 /* UnlinkedSourceCode.cpp */; };
    541541                0F8F943C1667631300D61971 /* CodeSpecializationKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */; };
    542542                0F8F94401667633000D61971 /* CodeBlockHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */; };
     
    10191019                141448CD13A1783700F5BA1A /* TinyBloomFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 141448CC13A1783700F5BA1A /* TinyBloomFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10201020                14150133154BB13F005D8C98 /* WeakSetInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 14150132154BB13F005D8C98 /* WeakSetInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1021                14201D591DECF26A00904BD3 /* SourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 14201D581DECF26A00904BD3 /* SourceCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10211022                1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1421359A0A677F4F00A8195E /* JSBase.cpp */; };
    10221023                14280823107EC02C0013E7B2 /* Debugger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8580255597D01FF60F7 /* Debugger.cpp */; };
     
    11501151                149559EE0DDCDDF700648087 /* DebuggerCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 149559ED0DDCDDF700648087 /* DebuggerCallFrame.cpp */; };
    11511152                14A1563210966365006FA260 /* DateInstanceCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A1563010966365006FA260 /* DateInstanceCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1153                14AB66761DECF40900A56C26 /* UnlinkedSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 14AB66751DECF40900A56C26 /* UnlinkedSourceCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11521154                14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */; };
    11531155                14AD910C1DCA92940014F9FE /* EvalCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 14AD91061DCA92940014F9FE /* EvalCodeBlock.h */; };
     
    20832085                BC18C45E0E16F5CD00B34460 /* CLoopStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D792640DAA03FB001A9F05 /* CLoopStack.h */; settings = {ATTRIBUTES = (Private, ); }; };
    20842086                BC18C4630E16F5CD00B34460 /* SourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2085                 BC18C4640E16F5CD00B34460 /* SourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E866EE0DD59AFA00A2B2A1 /* SourceCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    20862087                BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC18C3C10E16EE3300B34460 /* StringConstructor.h */; };
    20872088                BC18C4680E16F5CD00B34460 /* StringObject.h in Headers */ = {isa = PBXBuildFile; fileRef = BC18C3C30E16EE3300B34460 /* StringObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    29502951                0F8F2B97172F04FD007DBDA5 /* DFGDesiredIdentifiers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDesiredIdentifiers.cpp; path = dfg/DFGDesiredIdentifiers.cpp; sourceTree = "<group>"; };
    29512952                0F8F2B98172F04FD007DBDA5 /* DFGDesiredIdentifiers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DFGDesiredIdentifiers.h; path = dfg/DFGDesiredIdentifiers.h; sourceTree = "<group>"; };
    2952                 0F8F2B9D17306C8B007DBDA5 /* SourceCode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SourceCode.cpp; sourceTree = "<group>"; };
     2953                0F8F2B9D17306C8B007DBDA5 /* UnlinkedSourceCode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkedSourceCode.cpp; sourceTree = "<group>"; };
    29532954                0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeSpecializationKind.cpp; sourceTree = "<group>"; };
    29542955                0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeBlockHash.cpp; sourceTree = "<group>"; };
     
    34253426                141448CC13A1783700F5BA1A /* TinyBloomFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TinyBloomFilter.h; sourceTree = "<group>"; };
    34263427                14150132154BB13F005D8C98 /* WeakSetInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakSetInlines.h; sourceTree = "<group>"; };
     3428                14201D581DECF26A00904BD3 /* SourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceCode.h; sourceTree = "<group>"; };
    34273429                1421359A0A677F4F00A8195E /* JSBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBase.cpp; sourceTree = "<group>"; };
    34283430                142711380A460BBB0080EEEA /* JSBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBase.h; sourceTree = "<group>"; };
     
    35113513                14A1563010966365006FA260 /* DateInstanceCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateInstanceCache.h; sourceTree = "<group>"; };
    35123514                14A396A60CD2933100B5B4FF /* SymbolTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolTable.h; sourceTree = "<group>"; };
     3515                14AB66751DECF40900A56C26 /* UnlinkedSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedSourceCode.h; sourceTree = "<group>"; };
    35133516                14ABB36E099C076400E2A24F /* JSCJSValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCJSValue.h; sourceTree = "<group>"; };
    35143517                14ABB454099C2A0F00E2A24F /* JSType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSType.h; sourceTree = "<group>"; };
     
    37633766                65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSWrapperObject.h; sourceTree = "<group>"; };
    37643767                65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceProvider.h; sourceTree = "<group>"; };
    3765                 65E866EE0DD59AFA00A2B2A1 /* SourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceCode.h; sourceTree = "<group>"; };
    37663768                65EA4C99092AF9E20093D800 /* JSLock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLock.cpp; sourceTree = "<group>"; tabWidth = 8; };
    37673769                65EA4C9A092AF9E20093D800 /* JSLock.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JSLock.h; sourceTree = "<group>"; tabWidth = 8; };
     
    60396041                                E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */,
    60406042                                E3794E741B77EB97005543AE /* ModuleAnalyzer.h */,
     6043                                000BEAF0DF604481AF6AB68C /* ModuleScopeData.h */,
    60416044                                930DAD030FB1EB1A0082D205 /* NodeConstructors.h */,
    60426045                                F692A86D0255597D01FF60F7 /* Nodes.cpp */,
     
    60526055                                65303D631447B9E100D3F904 /* ParserTokens.h */,
    60536056                                869EBCB60E8C6D4A008722CC /* ResultType.h */,
    6054                                 0F8F2B9D17306C8B007DBDA5 /* SourceCode.cpp */,
    6055                                 65E866EE0DD59AFA00A2B2A1 /* SourceCode.h */,
     6057                                0F8F2B9D17306C8B007DBDA5 /* UnlinkedSourceCode.cpp */,
     6058                                14201D581DECF26A00904BD3 /* SourceCode.h */,
    60566059                                70B7918E1C0244C9002481E2 /* SourceCodeKey.h */,
    60576060                                0F493AF816D0CAD10084508B /* SourceProvider.cpp */,
     
    60616064                                E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */,
    60626065                                A7A7EE7711B98B8D0065A14F /* SyntaxChecker.h */,
     6066                                14AB66751DECF40900A56C26 /* UnlinkedSourceCode.h */,
    60636067                                79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */,
    60646068                                79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */,
    6065                                 000BEAF0DF604481AF6AB68C /* ModuleScopeData.h */,
    60666069                        );
    60676070                        path = parser;
     
    81008103                                0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */,
    81018104                                0F40E4A71C497F7400A577FA /* AirOpcode.h in Headers */,
     8105                                14AB66761DECF40900A56C26 /* UnlinkedSourceCode.h in Headers */,
    81028106                                0FDF67D71D9DC442001B9825 /* AirKind.h in Headers */,
    81038107                                0FD8A32617D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h in Headers */,
     
    87798783                                BC18C4540E16F5CD00B34460 /* PropertyNameArray.h in Headers */,
    87808784                                0FF7168C15A3B235008F5DAA /* PropertyOffset.h in Headers */,
     8785                                14201D591DECF26A00904BD3 /* SourceCode.h in Headers */,
    87818786                                BC18C4550E16F5CD00B34460 /* PropertySlot.h in Headers */,
    87828787                                0FB7F39C15ED8E4600F167B2 /* PropertyStorage.h in Headers */,
     
    88548859                                A709F2F017A0AC0400512E98 /* SlowPathCall.h in Headers */,
    88558860                                933040040E6A749400786E6A /* SmallStrings.h in Headers */,
    8856                                 BC18C4640E16F5CD00B34460 /* SourceCode.h in Headers */,
    88578861                                0F7C39FD1C8F659500480151 /* RegExpObjectInlines.h in Headers */,
    88588862                                0F7CF9521DC027D90098CC12 /* StopIfNecessaryTimer.h in Headers */,
     
    1030710311                                C225494315F7DBAA0065E898 /* SlotVisitor.cpp in Sources */,
    1030810312                                9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
    10309                                 0F8F2B9E17306C8D007DBDA5 /* SourceCode.cpp in Sources */,
     10313                                0F8F2B9E17306C8D007DBDA5 /* UnlinkedSourceCode.cpp in Sources */,
    1031010314                                0F493AFA16D0CAD30084508B /* SourceProvider.cpp in Sources */,
    1031110315                                0F338DF51BE93D550013C88F /* B3ConstrainedValue.cpp in Sources */,
  • 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;
  • trunk/Source/JavaScriptCore/parser/SourceCodeKey.h

    r208768 r209220  
    2828
    2929#include "ParserModes.h"
    30 #include "SourceCode.h"
     30#include "UnlinkedSourceCode.h"
    3131#include <wtf/HashTraits.h>
    3232
     
    7777
    7878    SourceCodeKey(
    79         const SourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode,
     79        const UnlinkedSourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode,
    8080        JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext,
    8181        DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled)
     
    125125
    126126private:
    127     SourceCode m_sourceCode;
     127    UnlinkedSourceCode m_sourceCode;
    128128    String m_name;
    129129    SourceCodeFlags m_flags;
  • trunk/Source/JavaScriptCore/parser/UnlinkedSourceCode.cpp

    r209219 r209220  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "SourceCode.h"
     27#include "UnlinkedSourceCode.h"
    2828
    2929#include "JSCInlines.h"
     
    3232namespace JSC {
    3333
    34 CString SourceCode::toUTF8() const
     34CString UnlinkedSourceCode::toUTF8() const
    3535{
    3636    if (!m_provider)
  • trunk/Source/JavaScriptCore/parser/UnlinkedSourceCode.h

    r209192 r209220  
    11/*
    2  * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2013, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434namespace JSC {
    3535
    36     class SourceCode {
     36    class UnlinkedSourceCode {
    3737    public:
    38         SourceCode()
     38        UnlinkedSourceCode()
    3939            : m_provider(0)
    4040            , m_startChar(0)
    4141            , m_endChar(0)
    42             , m_firstLine(0)
    43             , m_startColumn(0)
    4442        {
    4543        }
    4644
    47         SourceCode(WTF::HashTableDeletedValueType)
     45        UnlinkedSourceCode(WTF::HashTableDeletedValueType)
    4846            : m_provider(WTF::HashTableDeletedValue)
    4947        {
    5048        }
    5149
    52         SourceCode(PassRefPtr<SourceProvider> provider)
     50        UnlinkedSourceCode(PassRefPtr<SourceProvider> provider)
    5351            : m_provider(provider)
    5452            , m_startChar(0)
    5553            , m_endChar(m_provider->source().length())
    56             , m_firstLine(1)
    57             , m_startColumn(1)
    5854        {
    5955        }
    6056
    61         SourceCode(PassRefPtr<SourceProvider> provider, int firstLine, int startColumn)
     57        UnlinkedSourceCode(PassRefPtr<SourceProvider> provider, int startOffset, int endOffset)
    6258            : m_provider(provider)
    63             , m_startChar(0)
    64             , m_endChar(m_provider->source().length())
    65             , m_firstLine(std::max(firstLine, 1))
    66             , m_startColumn(std::max(startColumn, 1))
     59            , m_startChar(startOffset)
     60            , m_endChar(endOffset)
    6761        {
    6862        }
    6963
    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)
    74             , m_firstLine(std::max(firstLine, 1))
    75             , m_startColumn(std::max(startColumn, 1))
     64        UnlinkedSourceCode(const UnlinkedSourceCode& other)
     65            : m_provider(other.m_provider)
     66            , m_startChar(other.m_startChar)
     67            , m_endChar(other.m_endChar)
    7668        {
    7769        }
     
    9486        CString toUTF8() const;
    9587       
    96         intptr_t providerID() const
    97         {
    98             if (!m_provider)
    99                 return SourceProvider::nullID;
    100             return m_provider->asID();
    101         }
    102        
    10388        bool isNull() const { return !m_provider; }
    104         SourceProvider* provider() const { return m_provider.get(); }
    105         int firstLine() const { return m_firstLine; }
    106         int startColumn() const { return m_startColumn; }
    10789        int startOffset() const { return m_startChar; }
    10890        int endOffset() const { return m_endChar; }
    10991        int length() const { return m_endChar - m_startChar; }
    110        
    111         SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn);
    11292
    113     private:
     93    protected:
    11494        RefPtr<SourceProvider> m_provider;
    11595        int m_startChar;
    11696        int m_endChar;
    117         int m_firstLine;
    118         int m_startColumn;
    11997    };
    12098
    121     inline SourceCode makeSource(const String& source, const String& url = String(), const TextPosition& startPosition = TextPosition::minimumPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
    122     {
    123         return SourceCode(StringSourceProvider::create(source, url, startPosition, sourceType), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
    124     }
    125    
    126     inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn)
    127     {
    128         startColumn += 1; // Convert to base 1.
    129         return SourceCode(provider(), openBrace, closeBrace + 1, firstLine, startColumn);
    130     }
    131 
    13299} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r209196 r209220  
    3131#include "Parser.h"
    3232#include "ParserModes.h"
    33 #include "SourceCode.h"
    3433#include "SourceCodeKey.h"
    3534#include "Strong.h"
     
    3938#include "UnlinkedModuleProgramCodeBlock.h"
    4039#include "UnlinkedProgramCodeBlock.h"
     40#include "UnlinkedSourceCode.h"
    4141#include <wtf/CurrentTime.h>
    4242#include <wtf/Forward.h>
Note: See TracChangeset for help on using the changeset viewer.