Changeset 209220 in webkit
- Timestamp:
- Dec 1, 2016 4:24:17 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r209123 r209220 624 624 parser/Parser.cpp 625 625 parser/ParserArena.cpp 626 parser/SourceCode.cpp627 626 parser/SourceProvider.cpp 628 627 parser/SourceProviderCache.cpp 628 parser/UnlinkedSourceCode.cpp 629 629 parser/VariableEnvironment.cpp 630 630 -
trunk/Source/JavaScriptCore/ChangeLog
r209204 r209220 1 2016-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 1 59 2016-12-01 Keith Miller <keith_miller@apple.com> 2 60 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r209201 r209220 538 538 0F8F2B99172F04FF007DBDA5 /* DFGDesiredIdentifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F2B97172F04FD007DBDA5 /* DFGDesiredIdentifiers.cpp */; }; 539 539 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 */; }; 541 541 0F8F943C1667631300D61971 /* CodeSpecializationKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */; }; 542 542 0F8F94401667633000D61971 /* CodeBlockHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */; }; … … 1019 1019 141448CD13A1783700F5BA1A /* TinyBloomFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 141448CC13A1783700F5BA1A /* TinyBloomFilter.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1020 1020 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, ); }; }; 1021 1022 1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1421359A0A677F4F00A8195E /* JSBase.cpp */; }; 1022 1023 14280823107EC02C0013E7B2 /* Debugger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8580255597D01FF60F7 /* Debugger.cpp */; }; … … 1150 1151 149559EE0DDCDDF700648087 /* DebuggerCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 149559ED0DDCDDF700648087 /* DebuggerCallFrame.cpp */; }; 1151 1152 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, ); }; }; 1152 1154 14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */; }; 1153 1155 14AD910C1DCA92940014F9FE /* EvalCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 14AD91061DCA92940014F9FE /* EvalCodeBlock.h */; }; … … 2083 2085 BC18C45E0E16F5CD00B34460 /* CLoopStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D792640DAA03FB001A9F05 /* CLoopStack.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2084 2086 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, ); }; };2086 2087 BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC18C3C10E16EE3300B34460 /* StringConstructor.h */; }; 2087 2088 BC18C4680E16F5CD00B34460 /* StringObject.h in Headers */ = {isa = PBXBuildFile; fileRef = BC18C3C30E16EE3300B34460 /* StringObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2950 2951 0F8F2B97172F04FD007DBDA5 /* DFGDesiredIdentifiers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDesiredIdentifiers.cpp; path = dfg/DFGDesiredIdentifiers.cpp; sourceTree = "<group>"; }; 2951 2952 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>"; }; 2953 2954 0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeSpecializationKind.cpp; sourceTree = "<group>"; }; 2954 2955 0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeBlockHash.cpp; sourceTree = "<group>"; }; … … 3425 3426 141448CC13A1783700F5BA1A /* TinyBloomFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TinyBloomFilter.h; sourceTree = "<group>"; }; 3426 3427 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>"; }; 3427 3429 1421359A0A677F4F00A8195E /* JSBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBase.cpp; sourceTree = "<group>"; }; 3428 3430 142711380A460BBB0080EEEA /* JSBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBase.h; sourceTree = "<group>"; }; … … 3511 3513 14A1563010966365006FA260 /* DateInstanceCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateInstanceCache.h; sourceTree = "<group>"; }; 3512 3514 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>"; }; 3513 3516 14ABB36E099C076400E2A24F /* JSCJSValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCJSValue.h; sourceTree = "<group>"; }; 3514 3517 14ABB454099C2A0F00E2A24F /* JSType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSType.h; sourceTree = "<group>"; }; … … 3763 3766 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSWrapperObject.h; sourceTree = "<group>"; }; 3764 3767 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>"; };3766 3768 65EA4C99092AF9E20093D800 /* JSLock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLock.cpp; sourceTree = "<group>"; tabWidth = 8; }; 3767 3769 65EA4C9A092AF9E20093D800 /* JSLock.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JSLock.h; sourceTree = "<group>"; tabWidth = 8; }; … … 6039 6041 E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */, 6040 6042 E3794E741B77EB97005543AE /* ModuleAnalyzer.h */, 6043 000BEAF0DF604481AF6AB68C /* ModuleScopeData.h */, 6041 6044 930DAD030FB1EB1A0082D205 /* NodeConstructors.h */, 6042 6045 F692A86D0255597D01FF60F7 /* Nodes.cpp */, … … 6052 6055 65303D631447B9E100D3F904 /* ParserTokens.h */, 6053 6056 869EBCB60E8C6D4A008722CC /* ResultType.h */, 6054 0F8F2B9D17306C8B007DBDA5 /* SourceCode.cpp */,6055 65E866EE0DD59AFA00A2B2A1/* SourceCode.h */,6057 0F8F2B9D17306C8B007DBDA5 /* UnlinkedSourceCode.cpp */, 6058 14201D581DECF26A00904BD3 /* SourceCode.h */, 6056 6059 70B7918E1C0244C9002481E2 /* SourceCodeKey.h */, 6057 6060 0F493AF816D0CAD10084508B /* SourceProvider.cpp */, … … 6061 6064 E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */, 6062 6065 A7A7EE7711B98B8D0065A14F /* SyntaxChecker.h */, 6066 14AB66751DECF40900A56C26 /* UnlinkedSourceCode.h */, 6063 6067 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */, 6064 6068 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */, 6065 000BEAF0DF604481AF6AB68C /* ModuleScopeData.h */,6066 6069 ); 6067 6070 path = parser; … … 8100 8103 0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */, 8101 8104 0F40E4A71C497F7400A577FA /* AirOpcode.h in Headers */, 8105 14AB66761DECF40900A56C26 /* UnlinkedSourceCode.h in Headers */, 8102 8106 0FDF67D71D9DC442001B9825 /* AirKind.h in Headers */, 8103 8107 0FD8A32617D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h in Headers */, … … 8779 8783 BC18C4540E16F5CD00B34460 /* PropertyNameArray.h in Headers */, 8780 8784 0FF7168C15A3B235008F5DAA /* PropertyOffset.h in Headers */, 8785 14201D591DECF26A00904BD3 /* SourceCode.h in Headers */, 8781 8786 BC18C4550E16F5CD00B34460 /* PropertySlot.h in Headers */, 8782 8787 0FB7F39C15ED8E4600F167B2 /* PropertyStorage.h in Headers */, … … 8854 8859 A709F2F017A0AC0400512E98 /* SlowPathCall.h in Headers */, 8855 8860 933040040E6A749400786E6A /* SmallStrings.h in Headers */, 8856 BC18C4640E16F5CD00B34460 /* SourceCode.h in Headers */,8857 8861 0F7C39FD1C8F659500480151 /* RegExpObjectInlines.h in Headers */, 8858 8862 0F7CF9521DC027D90098CC12 /* StopIfNecessaryTimer.h in Headers */, … … 10307 10311 C225494315F7DBAA0065E898 /* SlotVisitor.cpp in Sources */, 10308 10312 9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */, 10309 0F8F2B9E17306C8D007DBDA5 /* SourceCode.cpp in Sources */,10313 0F8F2B9E17306C8D007DBDA5 /* UnlinkedSourceCode.cpp in Sources */, 10310 10314 0F493AFA16D0CAD30084508B /* SourceProvider.cpp in Sources */, 10311 10315 0F338DF51BE93D550013C88F /* B3ConstrainedValue.cpp in Sources */, -
trunk/Source/JavaScriptCore/parser/SourceCode.h
r206653 r209220 29 29 #pragma once 30 30 31 #include "SourceProvider.h" 32 #include <wtf/RefPtr.h> 31 #include "UnlinkedSourceCode.h" 33 32 34 33 namespace JSC { 35 34 36 class SourceCode {35 class SourceCode : public UnlinkedSourceCode { 37 36 public: 38 37 SourceCode() 39 : m_provider(0) 40 , m_startChar(0) 41 , m_endChar(0) 38 : UnlinkedSourceCode() 42 39 , m_firstLine(0) 43 40 , m_startColumn(0) … … 45 42 } 46 43 47 SourceCode(WTF::HashTableDeletedValueType)48 : m_provider(WTF::HashTableDeletedValue)49 {50 }51 52 44 SourceCode(PassRefPtr<SourceProvider> provider) 53 : m_provider(provider) 54 , m_startChar(0) 55 , m_endChar(m_provider->source().length()) 45 : UnlinkedSourceCode(provider) 56 46 , m_firstLine(1) 57 47 , m_startColumn(1) … … 60 50 61 51 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) 65 53 , m_firstLine(std::max(firstLine, 1)) 66 54 , m_startColumn(std::max(startColumn, 1)) … … 68 56 } 69 57 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) 74 60 , m_firstLine(std::max(firstLine, 1)) 75 61 , m_startColumn(std::max(startColumn, 1)) … … 77 63 } 78 64 79 bool isHashTableDeletedValue() const { return m_provider.isHashTableDeletedValue(); } 65 int firstLine() const { return m_firstLine; } 66 int startColumn() const { return m_startColumn; } 80 67 81 unsigned hash() const82 {83 ASSERT(m_provider);84 return m_provider->hash();85 }86 87 StringView view() const88 {89 if (!m_provider)90 return StringView();91 return m_provider->getRange(m_startChar, m_endChar);92 }93 94 CString toUTF8() const;95 96 68 intptr_t providerID() const 97 69 { … … 100 72 return m_provider->asID(); 101 73 } 102 103 bool isNull() const { return !m_provider; } 74 104 75 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 111 77 SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn); 112 78 113 79 private: 114 RefPtr<SourceProvider> m_provider;115 int m_startChar;116 int m_endChar;117 80 int m_firstLine; 118 81 int m_startColumn; -
trunk/Source/JavaScriptCore/parser/SourceCodeKey.h
r208768 r209220 28 28 29 29 #include "ParserModes.h" 30 #include " SourceCode.h"30 #include "UnlinkedSourceCode.h" 31 31 #include <wtf/HashTraits.h> 32 32 … … 77 77 78 78 SourceCodeKey( 79 const SourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode,79 const UnlinkedSourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode, 80 80 JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext, 81 81 DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled) … … 125 125 126 126 private: 127 SourceCode m_sourceCode;127 UnlinkedSourceCode m_sourceCode; 128 128 String m_name; 129 129 SourceCodeFlags m_flags; -
trunk/Source/JavaScriptCore/parser/UnlinkedSourceCode.cpp
r209219 r209220 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include " SourceCode.h"27 #include "UnlinkedSourceCode.h" 28 28 29 29 #include "JSCInlines.h" … … 32 32 namespace JSC { 33 33 34 CString SourceCode::toUTF8() const34 CString UnlinkedSourceCode::toUTF8() const 35 35 { 36 36 if (!m_provider) -
trunk/Source/JavaScriptCore/parser/UnlinkedSourceCode.h
r209192 r209220 1 1 /* 2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 namespace JSC { 35 35 36 class SourceCode {36 class UnlinkedSourceCode { 37 37 public: 38 SourceCode()38 UnlinkedSourceCode() 39 39 : m_provider(0) 40 40 , m_startChar(0) 41 41 , m_endChar(0) 42 , m_firstLine(0)43 , m_startColumn(0)44 42 { 45 43 } 46 44 47 SourceCode(WTF::HashTableDeletedValueType)45 UnlinkedSourceCode(WTF::HashTableDeletedValueType) 48 46 : m_provider(WTF::HashTableDeletedValue) 49 47 { 50 48 } 51 49 52 SourceCode(PassRefPtr<SourceProvider> provider)50 UnlinkedSourceCode(PassRefPtr<SourceProvider> provider) 53 51 : m_provider(provider) 54 52 , m_startChar(0) 55 53 , m_endChar(m_provider->source().length()) 56 , m_firstLine(1)57 , m_startColumn(1)58 54 { 59 55 } 60 56 61 SourceCode(PassRefPtr<SourceProvider> provider, int firstLine, int startColumn)57 UnlinkedSourceCode(PassRefPtr<SourceProvider> provider, int startOffset, int endOffset) 62 58 : 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) 67 61 { 68 62 } 69 63 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) 76 68 { 77 69 } … … 94 86 CString toUTF8() const; 95 87 96 intptr_t providerID() const97 {98 if (!m_provider)99 return SourceProvider::nullID;100 return m_provider->asID();101 }102 103 88 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; }107 89 int startOffset() const { return m_startChar; } 108 90 int endOffset() const { return m_endChar; } 109 91 int length() const { return m_endChar - m_startChar; } 110 111 SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn);112 92 113 pr ivate:93 protected: 114 94 RefPtr<SourceProvider> m_provider; 115 95 int m_startChar; 116 96 int m_endChar; 117 int m_firstLine;118 int m_startColumn;119 97 }; 120 98 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 132 99 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r209196 r209220 31 31 #include "Parser.h" 32 32 #include "ParserModes.h" 33 #include "SourceCode.h"34 33 #include "SourceCodeKey.h" 35 34 #include "Strong.h" … … 39 38 #include "UnlinkedModuleProgramCodeBlock.h" 40 39 #include "UnlinkedProgramCodeBlock.h" 40 #include "UnlinkedSourceCode.h" 41 41 #include <wtf/CurrentTime.h> 42 42 #include <wtf/Forward.h>
Note: See TracChangeset
for help on using the changeset viewer.