WebKit Bugzilla
Attachment 362197 Details for
Bug 194733
: [JSC] Shrink UnlinkedFunctionExecutable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194733-20190215180725.patch (text/plain), 27.12 KB, created by
Yusuke Suzuki
on 2019-02-15 18:07:26 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2019-02-15 18:07:26 PST
Size:
27.12 KB
patch
obsolete
>Subversion Revision: 241637 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 8049f0c376bf46d80c48aaca4760499ac0aafde8..4f76d930c362a41b6a528299b86954e8b4e74e66 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,67 @@ >+2019-02-15 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [JSC] Shrink UnlinkedFunctionExecutable >+ https://bugs.webkit.org/show_bug.cgi?id=194733 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ UnlinkedFunctionExecutable has sourceURLDirective and sourceMappingURLDirective. These >+ directives can be found in the comment of non-function's source code (Program etc.), >+ and tricky thing is that SourceProvider's directives are updated by Parser. The reason >+ why we have these fields in UnlinkedFunctionExecutable is that we need to update >+ the SourceProvider's directives even if we skip parsing by using CodeCache. These fields >+ are effective only if (1) UnlinkedFunctionExecutable is for non-function things, and (2) it >+ has sourceURLDirective or sourceMappingURLDirective. This is rare enough to purge them to a >+ separated UnlinkedFunctionExecutable::RareData to make UnlinkedFunctionExecutable small. >+ sizeof(UnlinkedFunctionExecutable) is very important since it is super frequently allocated >+ cell. Furthermore, the current JSC allocates two MarkedBlocks for UnlinkedFunctionExecutable >+ in JSGlobalObject initialization, but the usage of the second MarkedBlock is quite low (8%). >+ If we can reduce the size of UnlinkedFunctionExecutable, we can make them one MarkedBlock. >+ Since UnlinkedFunctionExecutable is allocated from IsoSubspace, we do not need to fit it to >+ one of size class. >+ >+ This patch adds RareData to UnlinkedFunctionExecutable and move some rare datas into RareData. >+ And kill one MarkedBlock allocation in JSC initialization phase. >+ >+ * bytecode/UnlinkedFunctionExecutable.cpp: >+ (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): >+ (JSC::UnlinkedFunctionExecutable::ensureRareDataSlow): >+ * bytecode/UnlinkedFunctionExecutable.h: >+ * debugger/DebuggerLocation.cpp: >+ (JSC::DebuggerLocation::DebuggerLocation): >+ * inspector/ScriptDebugServer.cpp: >+ (Inspector::ScriptDebugServer::dispatchDidParseSource): >+ * parser/Lexer.h: >+ (JSC::Lexer::sourceURLDirective const): >+ (JSC::Lexer::sourceMappingURLDirective const): >+ (JSC::Lexer::sourceURL const): Deleted. >+ (JSC::Lexer::sourceMappingURL const): Deleted. >+ * parser/Parser.h: >+ (JSC::Parser<LexerType>::parse): >+ * parser/SourceProvider.h: >+ (JSC::SourceProvider::sourceURLDirective const): >+ (JSC::SourceProvider::sourceMappingURLDirective const): >+ (JSC::SourceProvider::setSourceURLDirective): >+ (JSC::SourceProvider::setSourceMappingURLDirective): >+ (JSC::SourceProvider::sourceURL const): Deleted. We rename it from sourceURL to sourceURLDirective since it is the correct name. >+ (JSC::SourceProvider::sourceMappingURL const): Deleted. We rename it from sourceMappingURL to sourceMappingURLDirective since it is the correct name. >+ * runtime/CachedTypes.cpp: >+ (JSC::CachedSourceProviderShape::encode): >+ (JSC::CachedFunctionExecutableRareData::encode): >+ (JSC::CachedFunctionExecutableRareData::decode const): CachedFunctionExecutable did not have sourceMappingURL to sourceMappingURLDirective. So this patch keeps the same logic. >+ (JSC::CachedFunctionExecutable::rareData const): >+ (JSC::CachedFunctionExecutable::encode): >+ (JSC::CachedFunctionExecutable::decode const): >+ (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): >+ * runtime/CodeCache.cpp: >+ (JSC::CodeCache::getUnlinkedGlobalCodeBlock): >+ (JSC::CodeCache::getUnlinkedGlobalFunctionExecutable): >+ * runtime/CodeCache.h: >+ (JSC::generateUnlinkedCodeBlockImpl): >+ * runtime/FunctionExecutable.h: >+ * runtime/SamplingProfiler.cpp: >+ (JSC::SamplingProfiler::StackFrame::url): >+ > 2019-02-15 Yusuke Suzuki <ysuzuki@apple.com> > > [JSC] Make builtin objects more lazily initialized under non-JIT mode >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >index ce71c6f6edd6df60df2934cb86d6e1c8afc442b6..cada477888b782fabf8c793a2bfecbcd431772b8 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >+++ b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >@@ -42,7 +42,7 @@ > > namespace JSC { > >-static_assert(sizeof(UnlinkedFunctionExecutable) <= 160, "UnlinkedFunctionExecutable should fit in a 160-byte cell. If you increase the size of this class, consider making a size class that perfectly fits it."); >+static_assert(sizeof(UnlinkedFunctionExecutable) <= 128, "UnlinkedFunctionExecutable should fit in a 128-byte cell to keep allocated block only one just after initializing JSGlobalObject."); > > const ClassInfo UnlinkedFunctionExecutable::s_info = { "UnlinkedFunctionExecutable", nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(UnlinkedFunctionExecutable) }; > >@@ -106,7 +106,6 @@ UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* struct > , m_name(node->ident()) > , m_ecmaName(node->ecmaName()) > , m_inferredName(node->inferredName()) >- , m_classSource(node->classSource()) > , m_parentScopeTDZVariables(WTFMove(parentScopeTDZVariables)) > { > // Make sure these bitfields are adequately wide. >@@ -117,6 +116,8 @@ UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* struct > ASSERT(m_superBinding == static_cast<unsigned>(node->superBinding())); > ASSERT(m_derivedContextType == static_cast<unsigned>(derivedContextType)); > ASSERT(!(m_isBuiltinDefaultClassConstructor && constructorKind() == ConstructorKind::None)); >+ if (!node->classSource().isNull()) >+ setClassSource(node->classSource()); > } > > void UnlinkedFunctionExecutable::destroy(JSCell* cell) >@@ -243,6 +244,13 @@ UnlinkedFunctionCodeBlock* UnlinkedFunctionExecutable::unlinkedCodeBlockFor( > return result; > } > >+UnlinkedFunctionExecutable::RareData& UnlinkedFunctionExecutable::ensureRareDataSlow() >+{ >+ ASSERT(!m_rareData); >+ m_rareData = std::make_unique<RareData>(); >+ return *m_rareData; >+} >+ > void UnlinkedFunctionExecutable::setInvalidTypeProfilingOffsets() > { > m_typeProfilingStartOffset = std::numeric_limits<unsigned>::max(); >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h >index 7738152ed844de41397bfdac7bb7a00d482be8c1..defd2f08b87181e6b7f4ff60156907fdb6eb397f 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h >+++ b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h >@@ -56,7 +56,7 @@ class UnlinkedFunctionExecutable final : public JSCell { > public: > friend class CodeCache; > friend class VM; >- friend CachedFunctionExecutable; >+ friend class CachedFunctionExecutable; > > typedef JSCell Base; > static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; >@@ -82,8 +82,16 @@ class UnlinkedFunctionExecutable final : public JSCell { > unsigned parameterCount() const { return m_parameterCount; }; // Excluding 'this'! > SourceParseMode parseMode() const { return static_cast<SourceParseMode>(m_sourceParseMode); }; > >- const SourceCode& classSource() const { return m_classSource; }; >- void setClassSource(const SourceCode& source) { m_classSource = source; }; >+ SourceCode classSource() const >+ { >+ if (m_rareData) >+ return m_rareData->m_classSource; >+ return SourceCode(); >+ } >+ void setClassSource(const SourceCode& source) >+ { >+ ensureRareData().m_classSource = source; >+ } > > bool isInStrictContext() const { return m_isInStrictContext; } > FunctionMode functionMode() const { return static_cast<FunctionMode>(m_functionMode); } >@@ -140,16 +148,46 @@ class UnlinkedFunctionExecutable final : public JSCell { > ConstructAbility constructAbility() const { return static_cast<ConstructAbility>(m_constructAbility); } > JSParserScriptMode scriptMode() const { return static_cast<JSParserScriptMode>(m_scriptMode); } > bool isClassConstructorFunction() const { return constructorKind() != ConstructorKind::None; } >+ bool isClass() const >+ { >+ if (!m_rareData) >+ return false; >+ return !m_rareData->m_classSource.isNull(); >+ } > VariableEnvironment parentScopeTDZVariables() const { return m_parentScopeTDZVariables.environment().toVariableEnvironment(); } > > bool isArrowFunction() const { return isArrowFunctionParseMode(parseMode()); } > > JSC::DerivedContextType derivedContextType() const {return static_cast<JSC::DerivedContextType>(m_derivedContextType); } > >- const String& sourceURLDirective() const { return m_sourceURLDirective; } >- const String& sourceMappingURLDirective() const { return m_sourceMappingURLDirective; } >- void setSourceURLDirective(const String& sourceURL) { m_sourceURLDirective = sourceURL; } >- void setSourceMappingURLDirective(const String& sourceMappingURL) { m_sourceMappingURLDirective = sourceMappingURL; } >+ String sourceURLDirective() const >+ { >+ if (m_rareData) >+ return m_rareData->m_sourceURLDirective; >+ return String(); >+ } >+ String sourceMappingURLDirective() const >+ { >+ if (m_rareData) >+ return m_rareData->m_sourceMappingURLDirective; >+ return String(); >+ } >+ void setSourceURLDirective(const String& sourceURL) >+ { >+ ensureRareData().m_sourceURLDirective = sourceURL; >+ } >+ void setSourceMappingURLDirective(const String& sourceMappingURL) >+ { >+ ensureRareData().m_sourceMappingURLDirective = sourceMappingURL; >+ } >+ >+ struct RareData { >+ WTF_MAKE_STRUCT_FAST_ALLOCATED; >+ >+ SourceCode m_classSource; >+ String m_sourceURLDirective; >+ String m_sourceMappingURLDirective; >+ }; > > private: > UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, CompactVariableMap::Handle, JSC::DerivedContextType, bool isBuiltinDefaultClassConstructor); >@@ -185,12 +223,17 @@ class UnlinkedFunctionExecutable final : public JSCell { > Identifier m_name; > Identifier m_ecmaName; > Identifier m_inferredName; >- SourceCode m_classSource; > >- String m_sourceURLDirective; >- String m_sourceMappingURLDirective; >+ RareData& ensureRareData() >+ { >+ if (LIKELY(m_rareData)) >+ return *m_rareData; >+ return ensureRareDataSlow(); >+ } >+ RareData& ensureRareDataSlow(); > > CompactVariableMap::Handle m_parentScopeTDZVariables; >+ std::unique_ptr<RareData> m_rareData; > > protected: > static void visitChildren(JSCell*, SlotVisitor&); >diff --git a/Source/JavaScriptCore/debugger/DebuggerLocation.cpp b/Source/JavaScriptCore/debugger/DebuggerLocation.cpp >index b139720b4133f53b3318ae3e3adddb34f25e5308..c689b93a6b8e9ead4f0453d6fa6cacefb01f53ba 100644 >--- a/Source/JavaScriptCore/debugger/DebuggerLocation.cpp >+++ b/Source/JavaScriptCore/debugger/DebuggerLocation.cpp >@@ -40,7 +40,7 @@ DebuggerLocation::DebuggerLocation(ScriptExecutable* executable) > column = executable->startColumn(); > url = executable->sourceURL(); > if (url.isEmpty()) >- url = executable->source().provider()->sourceURL(); >+ url = executable->source().provider()->sourceURLDirective(); > } > > } // namespace JSC >diff --git a/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp b/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp >index 35ef25b27858d201e2ae600162e5122d14f70c95..e0a065cd61e7fdcc2fa3c34fd9091a83a56b8eff 100644 >--- a/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp >+++ b/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp >@@ -195,8 +195,8 @@ void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, Sou > script.startLine = sourceProvider->startPosition().m_line.zeroBasedInt(); > script.startColumn = sourceProvider->startPosition().m_column.zeroBasedInt(); > script.isContentScript = isContentScript; >- script.sourceURL = sourceProvider->sourceURL(); >- script.sourceMappingURL = sourceProvider->sourceMappingURL(); >+ script.sourceURL = sourceProvider->sourceURLDirective(); >+ script.sourceMappingURL = sourceProvider->sourceMappingURLDirective(); > > int sourceLength = script.source.length(); > int lineCount = 1; >diff --git a/Source/JavaScriptCore/parser/Lexer.h b/Source/JavaScriptCore/parser/Lexer.h >index 80189d02283a49ee76eab817dce39aac1b686e6b..700d1a756cc36dc5d5ed90508b1908a4f165a900 100644 >--- a/Source/JavaScriptCore/parser/Lexer.h >+++ b/Source/JavaScriptCore/parser/Lexer.h >@@ -87,8 +87,8 @@ class Lexer { > void setSawError(bool sawError) { m_error = sawError; } > String getErrorMessage() const { return m_lexErrorMessage; } > void setErrorMessage(const String& errorMessage) { m_lexErrorMessage = errorMessage; } >- String sourceURL() const { return m_sourceURLDirective; } >- String sourceMappingURL() const { return m_sourceMappingURLDirective; } >+ String sourceURLDirective() const { return m_sourceURLDirective; } >+ String sourceMappingURLDirective() const { return m_sourceMappingURLDirective; } > void clear(); > void setOffset(int offset, int lineStartOffset) > { >diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h >index 1c1a8d97b03dd34d793e6ec7b8c33dbedbbcd7e1..d1f94347e7fb7d0cc5677efd4582e7e114145bab 100644 >--- a/Source/JavaScriptCore/parser/Parser.h >+++ b/Source/JavaScriptCore/parser/Parser.h >@@ -1938,8 +1938,8 @@ std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const I > result->setEndOffset(m_lexer->currentOffset()); > > if (!isFunctionParseMode(parseMode)) { >- m_source->provider()->setSourceURLDirective(m_lexer->sourceURL()); >- m_source->provider()->setSourceMappingURLDirective(m_lexer->sourceMappingURL()); >+ m_source->provider()->setSourceURLDirective(m_lexer->sourceURLDirective()); >+ m_source->provider()->setSourceMappingURLDirective(m_lexer->sourceMappingURLDirective()); > } > } else { > // We can never see a syntax error when reparsing a function, since we should have >diff --git a/Source/JavaScriptCore/parser/SourceProvider.h b/Source/JavaScriptCore/parser/SourceProvider.h >index b3c9c465764fffcb9705ce86fb9ca804c2148645..bff521cfc0e22b31b4ec0d1add620abbf690fde9 100644 >--- a/Source/JavaScriptCore/parser/SourceProvider.h >+++ b/Source/JavaScriptCore/parser/SourceProvider.h >@@ -125,8 +125,8 @@ namespace JSC { > > const SourceOrigin& sourceOrigin() const { return m_sourceOrigin; } > const URL& url() const { return m_url; } >- const String& sourceURL() const { return m_sourceURLDirective; } >- const String& sourceMappingURL() const { return m_sourceMappingURLDirective; } >+ const String& sourceURLDirective() const { return m_sourceURLDirective; } >+ const String& sourceMappingURLDirective() const { return m_sourceMappingURLDirective; } > > TextPosition startPosition() const { return m_startPosition; } > SourceProviderSourceType sourceType() const { return m_sourceType; } >@@ -138,8 +138,8 @@ namespace JSC { > return m_id; > } > >- void setSourceURLDirective(const String& sourceURL) { m_sourceURLDirective = sourceURL; } >- void setSourceMappingURLDirective(const String& sourceMappingURL) { m_sourceMappingURLDirective = sourceMappingURL; } >+ void setSourceURLDirective(const String& sourceURLDirective) { m_sourceURLDirective = sourceURLDirective; } >+ void setSourceMappingURLDirective(const String& sourceMappingURLDirective) { m_sourceMappingURLDirective = sourceMappingURLDirective; } > > private: > JS_EXPORT_PRIVATE void getID(); >diff --git a/Source/JavaScriptCore/runtime/CachedTypes.cpp b/Source/JavaScriptCore/runtime/CachedTypes.cpp >index 610a83bf0499319ab66cecef81b0c6d264fcb0f3..8a1dde3130eb552843e8c19bfa0a1b7119da7020 100644 >--- a/Source/JavaScriptCore/runtime/CachedTypes.cpp >+++ b/Source/JavaScriptCore/runtime/CachedTypes.cpp >@@ -1266,8 +1266,8 @@ class CachedSourceProviderShape : public CachedObject<Source> { > { > m_sourceOrigin.encode(encoder, sourceProvider.sourceOrigin()); > m_url.encode(encoder, sourceProvider.url()); >- m_sourceURLDirective.encode(encoder, sourceProvider.sourceURL()); >- m_sourceMappingURLDirective.encode(encoder, sourceProvider.sourceMappingURL()); >+ m_sourceURLDirective.encode(encoder, sourceProvider.sourceURLDirective()); >+ m_sourceMappingURLDirective.encode(encoder, sourceProvider.sourceMappingURLDirective()); > m_startPosition.encode(encoder, sourceProvider.startPosition()); > } > >@@ -1429,6 +1429,24 @@ class CachedSourceCode : public CachedUnlinkedSourceCodeShape<SourceCode> { > int m_startColumn; > }; > >+class CachedFunctionExecutableRareData : public CachedObject<UnlinkedFunctionExecutable::RareData> { >+public: >+ void encode(Encoder& encoder, const UnlinkedFunctionExecutable::RareData& rareData) >+ { >+ m_classSource.encode(encoder, rareData.m_classSource); >+ } >+ >+ UnlinkedFunctionExecutable::RareData* decode(Decoder& decoder) const >+ { >+ UnlinkedFunctionExecutable::RareData* rareData = new UnlinkedFunctionExecutable::RareData { }; >+ m_classSource.decode(decoder, rareData->m_classSource); >+ return rareData; >+ } >+ >+private: >+ CachedSourceCode m_classSource; >+}; >+ > class CachedFunctionExecutable : public CachedObject<UnlinkedFunctionExecutable> { > public: > void encode(Encoder&, const UnlinkedFunctionExecutable&); >@@ -1464,6 +1482,8 @@ class CachedFunctionExecutable : public CachedObject<UnlinkedFunctionExecutable> > Identifier ecmaName(Decoder& decoder) const { return m_ecmaName.decode(decoder); } > Identifier inferredName(Decoder& decoder) const { return m_inferredName.decode(decoder); } > >+ UnlinkedFunctionExecutable::RareData* rareData(Decoder& decoder) const { return m_rareData.decodeAsPtr(decoder); } >+ > private: > unsigned m_firstLineOffset; > unsigned m_lineCount; >@@ -1489,7 +1509,7 @@ class CachedFunctionExecutable : public CachedObject<UnlinkedFunctionExecutable> > unsigned m_superBinding : 1; > unsigned m_derivedContextType: 2; > >- CachedSourceCode m_classSource; >+ CachedOptional<CachedFunctionExecutableRareData> m_rareData; > > CachedIdentifier m_name; > CachedIdentifier m_ecmaName; >@@ -1824,7 +1844,7 @@ ALWAYS_INLINE void CachedFunctionExecutable::encode(Encoder& encoder, const Unli > m_superBinding = executable.m_superBinding; > m_derivedContextType = executable.m_derivedContextType; > >- m_classSource.encode(encoder, executable.m_classSource); >+ m_rareData.encode(encoder, executable.m_rareData); > > m_name.encode(encoder, executable.name()); > m_ecmaName.encode(encoder, executable.ecmaName()); >@@ -1844,7 +1864,6 @@ ALWAYS_INLINE UnlinkedFunctionExecutable* CachedFunctionExecutable::decode(Decod > UnlinkedFunctionExecutable* executable = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(decoder.vm().heap)) UnlinkedFunctionExecutable(decoder, env, *this); > executable->finishCreation(decoder.vm()); > >- m_classSource.decode(decoder, executable->m_classSource); > m_unlinkedCodeBlockForCall.decode(decoder, executable->m_unlinkedCodeBlockForCall, executable); > m_unlinkedCodeBlockForConstruct.decode(decoder, executable->m_unlinkedCodeBlockForConstruct, executable); > >@@ -1882,6 +1901,8 @@ ALWAYS_INLINE UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(Decoder& de > , m_inferredName(cachedExecutable.inferredName(decoder)) > > , m_parentScopeTDZVariables(decoder.vm().m_compactVariableMap->get(parentScopeTDZVariables)) >+ >+ , m_rareData(cachedExecutable.rareData(decoder)) > { > } > >diff --git a/Source/JavaScriptCore/runtime/CodeCache.cpp b/Source/JavaScriptCore/runtime/CodeCache.cpp >index f1ea777a5fe4fb5bda21d767fec89d6393e273eb..87a3a815638c2c15e123b0081c26a5a9d07caece 100644 >--- a/Source/JavaScriptCore/runtime/CodeCache.cpp >+++ b/Source/JavaScriptCore/runtime/CodeCache.cpp >@@ -70,8 +70,12 @@ UnlinkedCodeBlockType* CodeCache::getUnlinkedGlobalCodeBlock(VM& vm, ExecutableT > bool endColumnIsOnStartLine = !lineCount; > unsigned endColumn = unlinkedCodeBlock->endColumn() + (endColumnIsOnStartLine ? startColumn : 1); > executable->recordParse(unlinkedCodeBlock->codeFeatures(), unlinkedCodeBlock->hasCapturedVariables(), source.firstLine().oneBasedInt() + lineCount, endColumn); >- source.provider()->setSourceURLDirective(unlinkedCodeBlock->sourceURLDirective()); >- source.provider()->setSourceMappingURLDirective(unlinkedCodeBlock->sourceMappingURLDirective()); >+ if (!isFunctionParseMode(unlinkedCodeBlock->parseMode())) { >+ if (!unlinkedCodeBlock->sourceURLDirective().isNull()) >+ source.provider()->setSourceURLDirective(unlinkedCodeBlock->sourceURLDirective()); >+ if (!unlinkedCodeBlock->sourceMappingURLDirective().isNull()) >+ source.provider()->setSourceMappingURLDirective(unlinkedCodeBlock->sourceMappingURLDirective()); >+ } > return unlinkedCodeBlock; > } > >@@ -115,8 +119,12 @@ UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& v > functionConstructorParametersEndPosition); > UnlinkedFunctionExecutable* executable = m_sourceCode.findCacheAndUpdateAge<UnlinkedFunctionExecutable>(vm, key); > if (executable && Options::useCodeCache()) { >- source.provider()->setSourceURLDirective(executable->sourceURLDirective()); >- source.provider()->setSourceMappingURLDirective(executable->sourceMappingURLDirective()); >+ if (!isFunctionParseMode(executable->parseMode())) { >+ if (!executable->sourceURLDirective().isNull()) >+ source.provider()->setSourceURLDirective(executable->sourceURLDirective()); >+ if (!executable->sourceMappingURLDirective().isNull()) >+ source.provider()->setSourceMappingURLDirective(executable->sourceMappingURLDirective()); >+ } > return executable; > } > >@@ -149,8 +157,12 @@ UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& v > ConstructAbility constructAbility = constructAbilityForParseMode(metadata->parseMode()); > UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, constructAbility, JSParserScriptMode::Classic, vm.m_compactVariableMap->get(emptyTDZVariables), DerivedContextType::None); > >- functionExecutable->setSourceURLDirective(source.provider()->sourceURL()); >- functionExecutable->setSourceMappingURLDirective(source.provider()->sourceMappingURL()); >+ if (!isFunctionParseMode(metadata->parseMode())) { >+ if (!source.provider()->sourceURLDirective().isNull()) >+ functionExecutable->setSourceURLDirective(source.provider()->sourceURLDirective()); >+ if (!source.provider()->sourceMappingURLDirective().isNull()) >+ functionExecutable->setSourceMappingURLDirective(source.provider()->sourceMappingURLDirective()); >+ } > > if (Options::useCodeCache()) > m_sourceCode.addCache(key, SourceCodeValue(vm, functionExecutable, m_sourceCode.age())); >diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h >index 45938e6f62887c2b2aa961fbdc202516c7f8dc10..683d5d2984cc0dae68af8e807a1d6d5a0e499e31 100644 >--- a/Source/JavaScriptCore/runtime/CodeCache.h >+++ b/Source/JavaScriptCore/runtime/CodeCache.h >@@ -297,8 +297,12 @@ UnlinkedCodeBlockType* generateUnlinkedCodeBlockImpl(VM& vm, const SourceCode& s > > UnlinkedCodeBlockType* unlinkedCodeBlock = UnlinkedCodeBlockType::create(&vm, executableInfo, debuggerMode); > unlinkedCodeBlock->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), lineCount, unlinkedEndColumn); >- unlinkedCodeBlock->setSourceURLDirective(source.provider()->sourceURL()); >- unlinkedCodeBlock->setSourceMappingURLDirective(source.provider()->sourceMappingURL()); >+ if (!isFunctionParseMode(unlinkedCodeBlock->parseMode())) { >+ if (!source.provider()->sourceURLDirective().isNull()) >+ unlinkedCodeBlock->setSourceURLDirective(source.provider()->sourceURLDirective()); >+ if (!source.provider()->sourceMappingURLDirective().isNull()) >+ unlinkedCodeBlock->setSourceMappingURLDirective(source.provider()->sourceMappingURLDirective()); >+ } > > error = BytecodeGenerator::generate(vm, rootNode.get(), source, unlinkedCodeBlock, debuggerMode, variablesUnderTDZ); > >diff --git a/Source/JavaScriptCore/runtime/FunctionExecutable.h b/Source/JavaScriptCore/runtime/FunctionExecutable.h >index 0e1882983d3fe259f9b81cc2f18f457f098b6d53..3cd1588beab9890af8888543368a9057c3e3bad0 100644 >--- a/Source/JavaScriptCore/runtime/FunctionExecutable.h >+++ b/Source/JavaScriptCore/runtime/FunctionExecutable.h >@@ -132,7 +132,7 @@ class FunctionExecutable final : public ScriptExecutable { > FunctionMode functionMode() { return m_unlinkedExecutable->functionMode(); } > bool isBuiltinFunction() const { return m_unlinkedExecutable->isBuiltinFunction(); } > ConstructAbility constructAbility() const { return m_unlinkedExecutable->constructAbility(); } >- bool isClass() const { return !classSource().isNull(); } >+ bool isClass() const { return m_unlinkedExecutable->isClass(); } > bool isArrowFunction() const { return parseMode() == SourceParseMode::ArrowFunctionMode; } > bool isGetter() const { return parseMode() == SourceParseMode::GetterMode; } > bool isSetter() const { return parseMode() == SourceParseMode::SetterMode; } >@@ -165,7 +165,7 @@ class FunctionExecutable final : public ScriptExecutable { > unsigned parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'! > SourceParseMode parseMode() const { return m_unlinkedExecutable->parseMode(); } > JSParserScriptMode scriptMode() const { return m_unlinkedExecutable->scriptMode(); } >- const SourceCode& classSource() const { return m_unlinkedExecutable->classSource(); } >+ SourceCode classSource() const { return m_unlinkedExecutable->classSource(); } > > static void visitChildren(JSCell*, SlotVisitor&); > static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto) >diff --git a/Source/JavaScriptCore/runtime/SamplingProfiler.cpp b/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >index 4588df51a4547f34594570a4ddd9a363e49b6e5d..372e059aba43f9b9154070ce6faf8f07e1296851 100644 >--- a/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >+++ b/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >@@ -863,7 +863,7 @@ String SamplingProfiler::StackFrame::url() > > String url = static_cast<ScriptExecutable*>(executable)->sourceURL(); > if (url.isEmpty()) >- return static_cast<ScriptExecutable*>(executable)->source().provider()->sourceURL(); // Fall back to sourceURL directive. >+ return static_cast<ScriptExecutable*>(executable)->source().provider()->sourceURLDirective(); // Fall back to sourceURL directive. > return url; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194733
:
362197
|
362202