[JSC] Shrink sizeof(UnlinkedFunctionExecutable) more
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 May 2019 17:31:53 +0000 (17:31 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 May 2019 17:31:53 +0000 (17:31 +0000)
commitcc0b0eaefb182404fca1dc0b5aa5040282144ea4
treefc10cd70d055c7ee7afda5e66032c0be315ae550
parent3db749a035dbce9f9a83e40fe1964a21a2f648dd
[JSC] Shrink sizeof(UnlinkedFunctionExecutable) more
https://bugs.webkit.org/show_bug.cgi?id=197833

Reviewed by Darin Adler.

JSTests:

* stress/generator-name.js: Added.
(shouldBe):
(gen):
(catch):

Source/JavaScriptCore:

It turns out that Gmail creates so many JSFunctions, FunctionExecutables, and UnlinkedFunctionExecutables.
So we should shrink size of them to save memory. As a first step, this patch reduces the sizeof(UnlinkedFunctionExecutable) more by 16 bytes.

1. We reorder some fields to get 8 bytes. And we use 31 bits for xxx offset things since their maximum size should be within 31 bits due to
   String's length & int32_t representation in our parser.

2. We drop m_inferredName and prefer m_ecmaName. The inferred name is used to offer better function name when the function expression lacks
   the name, but now ECMAScript has a specified semantics to name those functions with intuitive names. We should use ecmaName consistently,
   and should not eat 8 bytes for inferred names in UnlinkedFunctionExecutable.

We also fix generator ecma name.

* 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::createAssignResolve):
(JSC::ASTBuilder::createGeneratorFunctionBody):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::tryInferNameInPatternWithIdentifier):
(JSC::ASTBuilder::makeAssignNode):
* parser/Nodes.cpp:
(JSC::FunctionMetadataNode::operator== const):
(JSC::FunctionMetadataNode::dump const):
* parser/Nodes.h:
* 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):

Source/WebCore:

* testing/Internals.cpp:
(WebCore::Internals::parserMetaData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
JSTests/ChangeLog
JSTests/stress/generator-name.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/InlineCallFrame.cpp
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/Nodes.cpp
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/runtime/CachedTypes.cpp
Source/JavaScriptCore/runtime/FunctionExecutable.h
Source/JavaScriptCore/runtime/FunctionExecutableDump.cpp
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/SamplingProfiler.cpp
Source/WebCore/ChangeLog
Source/WebCore/testing/Internals.cpp