WebKit Bugzilla
Attachment 369814 Details for
Bug 197833
: [JSC] Shrink sizeof(UnlinkedFunctionExecutable) more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197833-20190513195537.patch (text/plain), 19.55 KB, created by
Yusuke Suzuki
on 2019-05-13 19:55:38 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2019-05-13 19:55:38 PDT
Size:
19.55 KB
patch
obsolete
>Subversion Revision: 245270 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index c20f93b297301d070bcd59226ec0bcb8c89a6c11..59670fade4daae317457fc9ad533b98036cdd57d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,37 @@ >+2019-05-13 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [JSC] Shrink sizeof(UnlinkedFunctionExecutable) more >+ https://bugs.webkit.org/show_bug.cgi?id=197833 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ It turns out that Gmail creates so many JSFunctions, FunctionExecutables, and UnlinkedFunctionExecutables. >+ As a first step, this patch reduces the sizeof(UnlinkedFunctionExecutable) more (16 bytes). >+ >+ * bytecode/CodeBlock.cpp: >+ (JSC::CodeBlock::inferredName const): >+ * bytecode/InlineCallFrame.cpp: >+ (JSC::InlineCallFrame::inferredName const): >+ * bytecode/UnlinkedFunctionExecutable.cpp: >+ (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): >+ * bytecode/UnlinkedFunctionExecutable.h: >+ * parser/ASTBuilder.h: >+ (JSC::ASTBuilder::createGeneratorFunctionBody): >+ * runtime/CachedTypes.cpp: >+ (JSC::CachedFunctionExecutable::ecmaName const): >+ (JSC::CachedFunctionExecutable::encode): >+ (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): >+ (JSC::CachedFunctionExecutable::inferredName const): Deleted. >+ * runtime/FunctionExecutable.h: >+ * runtime/FunctionExecutableDump.cpp: >+ (JSC::FunctionExecutableDump::dump const): >+ * runtime/JSFunction.cpp: >+ (JSC::JSFunction::calculatedDisplayName): >+ (JSC::getCalculatedDisplayName): >+ * runtime/SamplingProfiler.cpp: >+ (JSC::SamplingProfiler::StackFrame::displayName): >+ (JSC::SamplingProfiler::StackFrame::displayNameForJSONTests): >+ > 2019-05-13 Yusuke Suzuki <ysuzuki@apple.com> > > [JSC] Compress JIT related data more by using Packed<> >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ec1fd0759b74f1f95d3094c89cca1bacff95fbfe..31095ea800881dcc95c745c8626b96ca3230a4a9 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,13 @@ >+2019-05-13 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [JSC] Shrink sizeof(UnlinkedFunctionExecutable) more >+ https://bugs.webkit.org/show_bug.cgi?id=197833 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * testing/Internals.cpp: >+ (WebCore::Internals::parserMetaData): >+ > 2019-05-13 Yusuke Suzuki <ysuzuki@apple.com> > > Unreviewed, build fix after 245258, missing ThreadSpecific.h include >diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp >index bcb8a9d212c40e27fc30d3cb58a45ea558dd01e0..bc9ed129def31a37d4f78451c3a167a71b8dee09 100644 >--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp >+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp >@@ -122,7 +122,7 @@ CString CodeBlock::inferredName() const > case EvalCode: > return "<eval>"; > case FunctionCode: >- return jsCast<FunctionExecutable*>(ownerExecutable())->inferredName().utf8(); >+ return jsCast<FunctionExecutable*>(ownerExecutable())->ecmaName().utf8(); > case ModuleCode: > return "<module>"; > default: >diff --git a/Source/JavaScriptCore/bytecode/InlineCallFrame.cpp b/Source/JavaScriptCore/bytecode/InlineCallFrame.cpp >index ad2e0b89d2a6f63b7060c563ae2fde1302356794..de672fe1aa8b8591afbd2d6c0a800aa96a8f9c76 100644 >--- a/Source/JavaScriptCore/bytecode/InlineCallFrame.cpp >+++ b/Source/JavaScriptCore/bytecode/InlineCallFrame.cpp >@@ -56,7 +56,7 @@ CString InlineCallFrame::hashAsStringIfPossible() const > > CString InlineCallFrame::inferredName() const > { >- return jsCast<FunctionExecutable*>(baselineCodeBlock->ownerExecutable())->inferredName().utf8(); >+ return jsCast<FunctionExecutable*>(baselineCodeBlock->ownerExecutable())->ecmaName().utf8(); > } > > void InlineCallFrame::dumpBriefFunctionInformation(PrintStream& out) const >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >index 5e7148ebbc853c576b8bbb1c5a6f8ed669be7a08..14a069c5e07608d309182293656eb2187fd97fd6 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >+++ b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >@@ -84,34 +84,33 @@ static UnlinkedFunctionCodeBlock* generateUnlinkedFunctionCodeBlock( > UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& parentSource, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, Optional<CompactVariableMap::Handle> parentScopeTDZVariables, DerivedContextType derivedContextType, bool isBuiltinDefaultClassConstructor) > : Base(*vm, structure) > , m_firstLineOffset(node->firstLine() - parentSource.firstLine().oneBasedInt()) >+ , m_isInStrictContext(node->isInStrictContext()) > , m_lineCount(node->lastLine() - node->firstLine()) >+ , m_hasCapturedVariables(false) > , m_unlinkedFunctionNameStart(node->functionNameStart() - parentSource.startOffset()) >+ , m_isBuiltinFunction(kind == UnlinkedBuiltinFunction) > , m_unlinkedBodyStartColumn(node->startColumn()) >+ , m_isBuiltinDefaultClassConstructor(isBuiltinDefaultClassConstructor) > , m_unlinkedBodyEndColumn(m_lineCount ? node->endColumn() : node->endColumn() - node->startColumn()) >+ , m_constructAbility(static_cast<unsigned>(constructAbility)) > , m_startOffset(node->source().startOffset() - parentSource.startOffset()) >+ , m_scriptMode(static_cast<unsigned>(scriptMode)) > , m_sourceLength(node->source().length()) >+ , m_superBinding(static_cast<unsigned>(node->superBinding())) > , m_parametersStartOffset(node->parametersStart()) >+ , m_isCached(false) > , m_typeProfilingStartOffset(node->functionKeywordStart()) > , m_typeProfilingEndOffset(node->startStartOffset() + node->source().length() - 1) > , m_parameterCount(node->parameterCount()) > , m_features(0) > , m_sourceParseMode(node->parseMode()) >- , m_isInStrictContext(node->isInStrictContext()) >- , m_hasCapturedVariables(false) >- , m_isBuiltinFunction(kind == UnlinkedBuiltinFunction) >- , m_isBuiltinDefaultClassConstructor(isBuiltinDefaultClassConstructor) >- , m_constructAbility(static_cast<unsigned>(constructAbility)) > , m_constructorKind(static_cast<unsigned>(node->constructorKind())) > , m_functionMode(static_cast<unsigned>(node->functionMode())) >- , m_scriptMode(static_cast<unsigned>(scriptMode)) >- , m_superBinding(static_cast<unsigned>(node->superBinding())) > , m_derivedContextType(static_cast<unsigned>(derivedContextType)) >- , m_isCached(false) > , m_unlinkedCodeBlockForCall() > , m_unlinkedCodeBlockForConstruct() > , m_name(node->ident()) > , m_ecmaName(node->ecmaName()) >- , m_inferredName(node->inferredName()) > { > // Make sure these bitfields are adequately wide. > ASSERT(m_constructAbility == static_cast<unsigned>(constructAbility)); >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h >index 8e0abed5c26ae5c66acf941eb0429b6fbe3f0cc0..0c7f89cd4eb024fcf80d78836c3f43c0a7cd23c3 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h >+++ b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h >@@ -81,7 +81,6 @@ class UnlinkedFunctionExecutable final : public JSCell { > const Identifier& name() const { return m_name; } > const Identifier& ecmaName() const { return m_ecmaName; } > void setEcmaName(const Identifier& name) { m_ecmaName = name; } >- const Identifier& inferredName() const { return m_inferredName; } > unsigned parameterCount() const { return m_parameterCount; }; // Excluding 'this'! > SourceParseMode parseMode() const { return static_cast<SourceParseMode>(m_sourceParseMode); }; > >@@ -205,30 +204,30 @@ class UnlinkedFunctionExecutable final : public JSCell { > > void decodeCachedCodeBlocks(); > >- unsigned m_firstLineOffset; >- unsigned m_lineCount; >- unsigned m_unlinkedFunctionNameStart; >- unsigned m_unlinkedBodyStartColumn; >- unsigned m_unlinkedBodyEndColumn; >- unsigned m_startOffset; >- unsigned m_sourceLength; >- unsigned m_parametersStartOffset; >- unsigned m_typeProfilingStartOffset; >- unsigned m_typeProfilingEndOffset; >- unsigned m_parameterCount; >- CodeFeatures m_features; >- SourceParseMode m_sourceParseMode; >+ unsigned m_firstLineOffset : 31; > unsigned m_isInStrictContext : 1; >+ unsigned m_lineCount : 31; > unsigned m_hasCapturedVariables : 1; >+ unsigned m_unlinkedFunctionNameStart : 31; > unsigned m_isBuiltinFunction : 1; >+ unsigned m_unlinkedBodyStartColumn : 31; > unsigned m_isBuiltinDefaultClassConstructor : 1; >+ unsigned m_unlinkedBodyEndColumn : 31; > unsigned m_constructAbility: 1; >- unsigned m_constructorKind : 2; >- unsigned m_functionMode : 2; // FunctionMode >+ unsigned m_startOffset : 31; > unsigned m_scriptMode: 1; // JSParserScriptMode >+ unsigned m_sourceLength : 31; > unsigned m_superBinding : 1; >+ unsigned m_parametersStartOffset : 31; >+ unsigned m_isCached : 1; >+ unsigned m_typeProfilingStartOffset; >+ unsigned m_typeProfilingEndOffset; >+ unsigned m_parameterCount; >+ CodeFeatures m_features; >+ SourceParseMode m_sourceParseMode; >+ unsigned m_constructorKind : 2; >+ unsigned m_functionMode : 2; // FunctionMode > unsigned m_derivedContextType: 2; >- bool m_isCached : 1; > > union { > WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall; >@@ -245,7 +244,6 @@ class UnlinkedFunctionExecutable final : public JSCell { > > Identifier m_name; > Identifier m_ecmaName; >- Identifier m_inferredName; > > RareData& ensureRareData() > { >diff --git a/Source/JavaScriptCore/parser/ASTBuilder.h b/Source/JavaScriptCore/parser/ASTBuilder.h >index 104e59bac45d55c81f5cdf87ed754ddfcdf6168e..fd711f1d18534d7061ea55944f0e3d1326b509d4 100644 >--- a/Source/JavaScriptCore/parser/ASTBuilder.h >+++ b/Source/JavaScriptCore/parser/ASTBuilder.h >@@ -416,8 +416,10 @@ class ASTBuilder { > ExpressionNode* createGeneratorFunctionBody(const JSTokenLocation& location, const ParserFunctionInfo<ASTBuilder>& functionInfo, const Identifier& name) > { > FuncExprNode* result = static_cast<FuncExprNode*>(createFunctionExpr(location, functionInfo)); >- if (!name.isNull()) >+ if (!name.isNull()) { >+ result->metadata()->setEcmaName(name); > result->metadata()->setInferredName(name); >+ } > return result; > } > >diff --git a/Source/JavaScriptCore/runtime/CachedTypes.cpp b/Source/JavaScriptCore/runtime/CachedTypes.cpp >index 22f3c2ed21f15480392879f436ea5bafb7e7446b..a2a6fdbfacf863b8b75e5221dbe34eea77459f43 100644 >--- a/Source/JavaScriptCore/runtime/CachedTypes.cpp >+++ b/Source/JavaScriptCore/runtime/CachedTypes.cpp >@@ -1641,7 +1641,6 @@ class CachedFunctionExecutable : public CachedObject<UnlinkedFunctionExecutable> > > Identifier name(Decoder& decoder) const { return m_name.decode(decoder); } > 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.decode(decoder); } > >@@ -1677,7 +1676,6 @@ class CachedFunctionExecutable : public CachedObject<UnlinkedFunctionExecutable> > > CachedIdentifier m_name; > CachedIdentifier m_ecmaName; >- CachedIdentifier m_inferredName; > > CachedWriteBarrier<CachedFunctionCodeBlock, UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall; > CachedWriteBarrier<CachedFunctionCodeBlock, UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct; >@@ -2044,7 +2042,6 @@ ALWAYS_INLINE void CachedFunctionExecutable::encode(Encoder& encoder, const Unli > > m_name.encode(encoder, executable.name()); > m_ecmaName.encode(encoder, executable.ecmaName()); >- m_inferredName.encode(encoder, executable.inferredName()); > > m_unlinkedCodeBlockForCall.encode(encoder, executable.m_unlinkedCodeBlockForCall); > m_unlinkedCodeBlockForConstruct.encode(encoder, executable.m_unlinkedCodeBlockForConstruct); >@@ -2063,35 +2060,34 @@ ALWAYS_INLINE UnlinkedFunctionExecutable* CachedFunctionExecutable::decode(Decod > ALWAYS_INLINE UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(Decoder& decoder, const CachedFunctionExecutable& cachedExecutable) > : Base(decoder.vm(), decoder.vm().unlinkedFunctionExecutableStructure.get()) > , m_firstLineOffset(cachedExecutable.firstLineOffset()) >+ , m_isInStrictContext(cachedExecutable.isInStrictContext()) > , m_lineCount(cachedExecutable.lineCount()) >+ , m_hasCapturedVariables(cachedExecutable.hasCapturedVariables()) > , m_unlinkedFunctionNameStart(cachedExecutable.unlinkedFunctionNameStart()) >+ , m_isBuiltinFunction(cachedExecutable.isBuiltinFunction()) > , m_unlinkedBodyStartColumn(cachedExecutable.unlinkedBodyStartColumn()) >+ , m_isBuiltinDefaultClassConstructor(cachedExecutable.isBuiltinDefaultClassConstructor()) > , m_unlinkedBodyEndColumn(cachedExecutable.unlinkedBodyEndColumn()) >+ , m_constructAbility(cachedExecutable.constructAbility()) > , m_startOffset(cachedExecutable.startOffset()) >+ , m_scriptMode(cachedExecutable.scriptMode()) > , m_sourceLength(cachedExecutable.sourceLength()) >+ , m_superBinding(cachedExecutable.superBinding()) > , m_parametersStartOffset(cachedExecutable.parametersStartOffset()) >+ , m_isCached(false) > , m_typeProfilingStartOffset(cachedExecutable.typeProfilingStartOffset()) > , m_typeProfilingEndOffset(cachedExecutable.typeProfilingEndOffset()) > , m_parameterCount(cachedExecutable.parameterCount()) > , m_features(cachedExecutable.features()) > , m_sourceParseMode(cachedExecutable.sourceParseMode()) >- , m_isInStrictContext(cachedExecutable.isInStrictContext()) >- , m_hasCapturedVariables(cachedExecutable.hasCapturedVariables()) >- , m_isBuiltinFunction(cachedExecutable.isBuiltinFunction()) >- , m_isBuiltinDefaultClassConstructor(cachedExecutable.isBuiltinDefaultClassConstructor()) >- , m_constructAbility(cachedExecutable.constructAbility()) > , m_constructorKind(cachedExecutable.constructorKind()) > , m_functionMode(cachedExecutable.functionMode()) >- , m_scriptMode(cachedExecutable.scriptMode()) >- , m_superBinding(cachedExecutable.superBinding()) > , m_derivedContextType(cachedExecutable.derivedContextType()) >- , m_isCached(false) > , m_unlinkedCodeBlockForCall() > , m_unlinkedCodeBlockForConstruct() > > , m_name(cachedExecutable.name(decoder)) > , m_ecmaName(cachedExecutable.ecmaName(decoder)) >- , m_inferredName(cachedExecutable.inferredName(decoder)) > > , m_rareData(cachedExecutable.rareData(decoder)) > { >diff --git a/Source/JavaScriptCore/runtime/FunctionExecutable.h b/Source/JavaScriptCore/runtime/FunctionExecutable.h >index 6fb5ccd119ab8f93c4bbaeca0cadc1ec8df8a700..598803ce2afe08f5ecbb08268da466db4815ffa5 100644 >--- a/Source/JavaScriptCore/runtime/FunctionExecutable.h >+++ b/Source/JavaScriptCore/runtime/FunctionExecutable.h >@@ -161,7 +161,6 @@ class FunctionExecutable final : public ScriptExecutable { > bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); } > const Identifier& name() { return m_unlinkedExecutable->name(); } > const Identifier& ecmaName() { return m_unlinkedExecutable->ecmaName(); } >- const Identifier& inferredName() { return m_unlinkedExecutable->inferredName(); } > unsigned parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'! > SourceParseMode parseMode() const { return m_unlinkedExecutable->parseMode(); } > JSParserScriptMode scriptMode() const { return m_unlinkedExecutable->scriptMode(); } >diff --git a/Source/JavaScriptCore/runtime/FunctionExecutableDump.cpp b/Source/JavaScriptCore/runtime/FunctionExecutableDump.cpp >index 75845fad0ace33a9ce655696a5408c305cdad578..9956b2b185892b51447f859bbeda830a17a3c540 100644 >--- a/Source/JavaScriptCore/runtime/FunctionExecutableDump.cpp >+++ b/Source/JavaScriptCore/runtime/FunctionExecutableDump.cpp >@@ -34,7 +34,7 @@ namespace JSC { > > void FunctionExecutableDump::dump(PrintStream& out) const > { >- out.print(m_executable->inferredName().string(), "#"); >+ out.print(m_executable->ecmaName().string(), "#"); > if (m_executable->isGeneratedForCall()) > out.print(m_executable->codeBlockForCall()->hashAsStringIfPossible()); > else >diff --git a/Source/JavaScriptCore/runtime/JSFunction.cpp b/Source/JavaScriptCore/runtime/JSFunction.cpp >index 37ff4c8d6391284703fc2e7d3835e2799aca1043..f3a96d8556b76a18b7c1b413bd711c767d9f1721 100644 >--- a/Source/JavaScriptCore/runtime/JSFunction.cpp >+++ b/Source/JavaScriptCore/runtime/JSFunction.cpp >@@ -227,7 +227,7 @@ const String JSFunction::calculatedDisplayName(VM& vm) > if (!actualName.isEmpty() || isHostOrBuiltinFunction()) > return actualName; > >- return jsExecutable()->inferredName().string(); >+ return jsExecutable()->ecmaName().string(); > } > > const SourceCode* JSFunction::sourceCode() const >@@ -651,7 +651,7 @@ String getCalculatedDisplayName(VM& vm, JSObject* object) > if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) > return actualName; > >- return function->jsExecutable()->inferredName().string(); >+ return function->jsExecutable()->ecmaName().string(); > } > if (auto* function = jsDynamicCast<InternalFunction*>(vm, object)) > return function->name(); >diff --git a/Source/JavaScriptCore/runtime/SamplingProfiler.cpp b/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >index 3c2fb6f65d7ddd29d47bc84a22c05781effbbe71..e4746ca405c4c9f01f1d139ef4646524f7ac71e0 100644 >--- a/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >+++ b/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >@@ -779,7 +779,7 @@ String SamplingProfiler::StackFrame::displayName(VM& vm) > return static_cast<NativeExecutable*>(executable)->name(); > > if (executable->isFunctionExecutable()) >- return static_cast<FunctionExecutable*>(executable)->inferredName().string(); >+ return static_cast<FunctionExecutable*>(executable)->ecmaName().string(); > if (executable->isProgramExecutable() || executable->isEvalExecutable()) > return "(program)"_s; > if (executable->isModuleProgramExecutable()) >@@ -806,7 +806,7 @@ String SamplingProfiler::StackFrame::displayNameForJSONTests(VM& vm) > return static_cast<NativeExecutable*>(executable)->name(); > > if (executable->isFunctionExecutable()) { >- String result = static_cast<FunctionExecutable*>(executable)->inferredName().string(); >+ String result = static_cast<FunctionExecutable*>(executable)->ecmaName().string(); > if (result.isEmpty()) > return "(anonymous function)"_s; > return result; >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 524e3b321dc381d949d130c46476b202bdf5b8e9..6c4737e155c6d750ae8e2ff829dbdf0be012aaa0 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -2147,7 +2147,7 @@ String Internals::parserMetaData(JSC::JSValue code) > > if (executable->isFunctionExecutable()) { > FunctionExecutable* funcExecutable = reinterpret_cast<FunctionExecutable*>(executable); >- String inferredName = funcExecutable->inferredName().string(); >+ String inferredName = funcExecutable->ecmaName().string(); > result.appendLiteral("function \""); > result.append(inferredName); > result.append('"');
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 197833
:
369710
|
369712
|
369721
|
369722
|
369723
|
369814
|
369821