Skip to content

Commit 56ea256

Browse files
committed
[JSC] Shrink sizeof(CodeBlock) more
https://bugs.webkit.org/show_bug.cgi?id=194419 Reviewed by Mark Lam. Source/JavaScriptCore: This patch further shrinks the size of CodeBlock, from 352 to 296 (304). 1. CodeBlock copies so many data from ScriptExecutable even if ScriptExecutable has the same information. These data is not touched in CodeBlock::~CodeBlock, so we can just use the data in ScriptExecutable instead of holding it in CodeBlock. 2. We remove m_instructions pointer since the ownership is managed by UnlinkedCodeBlock. And we do not touch it in CodeBlock::~CodeBlock. 3. We move m_calleeSaveRegisters from CodeBlock to CodeBlock::JITData. For baseline and LLInt cases, this patch offers RegisterAtOffsetList::llintBaselineCalleeSaveRegisters() which returns singleton to `const RegisterAtOffsetList*` usable for LLInt and Baseline JIT CodeBlocks. 4. Move m_catchProfiles to RareData and materialize only when op_catch's slow path is called. 5. Drop ownerScriptExecutable. ownerExecutable() returns ScriptExecutable*. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::hash const): (JSC::CodeBlock::sourceCodeForTools const): (JSC::CodeBlock::dumpAssumingJITType const): (JSC::CodeBlock::dumpSource): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::setCalleeSaveRegisters): (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeOffset): (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeOffsetSlow): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset const): (JSC::CodeBlock::hasOpDebugForLineAndColumn): (JSC::CodeBlock::newReplacement): (JSC::CodeBlock::replacement): (JSC::CodeBlock::computeCapabilityLevel): (JSC::CodeBlock::jettison): (JSC::CodeBlock::calleeSaveRegisters const): (JSC::CodeBlock::calleeSaveSpaceAsVirtualRegisters): (JSC::CodeBlock::updateOSRExitCounterAndCheckIfNeedToReoptimize): (JSC::CodeBlock::getArrayProfile): (JSC::CodeBlock::updateAllPredictionsAndCountLiveness): (JSC::CodeBlock::notifyLexicalBindingUpdate): (JSC::CodeBlock::tryGetValueProfileForBytecodeOffset): (JSC::CodeBlock::validate): (JSC::CodeBlock::outOfLineJumpTarget): (JSC::CodeBlock::arithProfileForBytecodeOffset): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::specializationKind const): (JSC::CodeBlock::isStrictMode const): (JSC::CodeBlock::isConstructor const): (JSC::CodeBlock::codeType const): (JSC::CodeBlock::isKnownNotImmediate): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::ownerExecutable const): (JSC::CodeBlock::thisRegister const): (JSC::CodeBlock::source const): (JSC::CodeBlock::sourceOffset const): (JSC::CodeBlock::firstLineColumnOffset const): (JSC::CodeBlock::createRareDataIfNecessary): (JSC::CodeBlock::ownerScriptExecutable const): Deleted. (JSC::CodeBlock::setThisRegister): Deleted. (JSC::CodeBlock::calleeSaveRegisters const): Deleted. * bytecode/EvalCodeBlock.h: * bytecode/FunctionCodeBlock.h: * bytecode/GlobalCodeBlock.h: (JSC::GlobalCodeBlock::GlobalCodeBlock): * bytecode/ModuleProgramCodeBlock.h: * bytecode/ProgramCodeBlock.h: * debugger/Debugger.cpp: (JSC::Debugger::toggleBreakpoint): * debugger/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::sourceID const): (JSC::DebuggerCallFrame::sourceIDForCallFrame): * debugger/DebuggerScope.cpp: (JSC::DebuggerScope::location const): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::InlineStackEntry::executable): (JSC::DFG::ByteCodeParser::inliningCost): (JSC::DFG::ByteCodeParser::parseCodeBlock): * dfg/DFGCapabilities.cpp: (JSC::DFG::isSupportedForInlining): (JSC::DFG::mightCompileEval): (JSC::DFG::mightCompileProgram): (JSC::DFG::mightCompileFunctionForCall): (JSC::DFG::mightCompileFunctionForConstruct): (JSC::DFG::canUseOSRExitFuzzing): * dfg/DFGGraph.h: (JSC::DFG::Graph::executableFor): * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::compileFunction): * dfg/DFGOSREntry.cpp: (JSC::DFG::prepareOSREntry): * dfg/DFGOSRExit.cpp: (JSC::DFG::restoreCalleeSavesFor): (JSC::DFG::saveCalleeSavesFor): (JSC::DFG::saveOrCopyCalleeSavesFor): * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::handleExitCounts): * dfg/DFGOperations.cpp: * dfg/DFGToFTLDeferredCompilationCallback.cpp: (JSC::DFG::ToFTLDeferredCompilationCallback::compilationDidComplete): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLink.cpp: (JSC::FTL::link): * ftl/FTLOSRExitCompiler.cpp: (JSC::FTL::compileStub): * interpreter/CallFrame.cpp: (JSC::CallFrame::callerSourceOrigin): * interpreter/Interpreter.cpp: (JSC::eval): (JSC::UnwindFunctor::copyCalleeSavesToEntryFrameCalleeSavesBuffer const): * interpreter/StackVisitor.cpp: (JSC::StackVisitor::Frame::calleeSaveRegisters): (JSC::StackVisitor::Frame::sourceURL const): (JSC::StackVisitor::Frame::sourceID): (JSC::StackVisitor::Frame::computeLineAndColumn const): * interpreter/StackVisitor.h: * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::emitSaveCalleeSavesFor): (JSC::AssemblyHelpers::emitSaveOrCopyCalleeSavesFor): (JSC::AssemblyHelpers::emitRestoreCalleeSavesFor): * jit/CallFrameShuffleData.cpp: (JSC::CallFrameShuffleData::setupCalleeSaveRegisters): * jit/JIT.cpp: (JSC::JIT::compileWithoutLinking): * jit/JITToDFGDeferredCompilationCallback.cpp: (JSC::JITToDFGDeferredCompilationCallback::compilationDidComplete): * jit/JITWorklist.cpp: (JSC::JITWorklist::Plan::finalize): (JSC::JITWorklist::compileNow): * jit/RegisterAtOffsetList.cpp: (JSC::RegisterAtOffsetList::llintBaselineCalleeSaveRegisters): * jit/RegisterAtOffsetList.h: (JSC::RegisterAtOffsetList::at const): * runtime/ErrorInstance.cpp: (JSC::appendSourceToError): * runtime/ScriptExecutable.cpp: (JSC::ScriptExecutable::newCodeBlockFor): * runtime/StackFrame.cpp: (JSC::StackFrame::sourceID const): (JSC::StackFrame::sourceURL const): (JSC::StackFrame::computeLineAndColumn const): Source/WebCore: * testing/Internals.cpp: (WebCore::Internals::parserMetaData): Canonical link: https://commits.webkit.org/208881@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241222 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 45eba1a commit 56ea256

39 files changed

Lines changed: 370 additions & 209 deletions

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,155 @@
1+
2019-02-08 Yusuke Suzuki <ysuzuki@apple.com>
2+
3+
[JSC] Shrink sizeof(CodeBlock) more
4+
https://bugs.webkit.org/show_bug.cgi?id=194419
5+
6+
Reviewed by Mark Lam.
7+
8+
This patch further shrinks the size of CodeBlock, from 352 to 296 (304).
9+
10+
1. CodeBlock copies so many data from ScriptExecutable even if ScriptExecutable
11+
has the same information. These data is not touched in CodeBlock::~CodeBlock,
12+
so we can just use the data in ScriptExecutable instead of holding it in CodeBlock.
13+
14+
2. We remove m_instructions pointer since the ownership is managed by UnlinkedCodeBlock.
15+
And we do not touch it in CodeBlock::~CodeBlock.
16+
17+
3. We move m_calleeSaveRegisters from CodeBlock to CodeBlock::JITData. For baseline and LLInt
18+
cases, this patch offers RegisterAtOffsetList::llintBaselineCalleeSaveRegisters() which returns
19+
singleton to `const RegisterAtOffsetList*` usable for LLInt and Baseline JIT CodeBlocks.
20+
21+
4. Move m_catchProfiles to RareData and materialize only when op_catch's slow path is called.
22+
23+
5. Drop ownerScriptExecutable. ownerExecutable() returns ScriptExecutable*.
24+
25+
* bytecode/CodeBlock.cpp:
26+
(JSC::CodeBlock::hash const):
27+
(JSC::CodeBlock::sourceCodeForTools const):
28+
(JSC::CodeBlock::dumpAssumingJITType const):
29+
(JSC::CodeBlock::dumpSource):
30+
(JSC::CodeBlock::CodeBlock):
31+
(JSC::CodeBlock::finishCreation):
32+
(JSC::CodeBlock::propagateTransitions):
33+
(JSC::CodeBlock::finalizeLLIntInlineCaches):
34+
(JSC::CodeBlock::setCalleeSaveRegisters):
35+
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeOffset):
36+
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeOffsetSlow):
37+
(JSC::CodeBlock::lineNumberForBytecodeOffset):
38+
(JSC::CodeBlock::expressionRangeForBytecodeOffset const):
39+
(JSC::CodeBlock::hasOpDebugForLineAndColumn):
40+
(JSC::CodeBlock::newReplacement):
41+
(JSC::CodeBlock::replacement):
42+
(JSC::CodeBlock::computeCapabilityLevel):
43+
(JSC::CodeBlock::jettison):
44+
(JSC::CodeBlock::calleeSaveRegisters const):
45+
(JSC::CodeBlock::calleeSaveSpaceAsVirtualRegisters):
46+
(JSC::CodeBlock::updateOSRExitCounterAndCheckIfNeedToReoptimize):
47+
(JSC::CodeBlock::getArrayProfile):
48+
(JSC::CodeBlock::updateAllPredictionsAndCountLiveness):
49+
(JSC::CodeBlock::notifyLexicalBindingUpdate):
50+
(JSC::CodeBlock::tryGetValueProfileForBytecodeOffset):
51+
(JSC::CodeBlock::validate):
52+
(JSC::CodeBlock::outOfLineJumpTarget):
53+
(JSC::CodeBlock::arithProfileForBytecodeOffset):
54+
(JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler):
55+
* bytecode/CodeBlock.h:
56+
(JSC::CodeBlock::specializationKind const):
57+
(JSC::CodeBlock::isStrictMode const):
58+
(JSC::CodeBlock::isConstructor const):
59+
(JSC::CodeBlock::codeType const):
60+
(JSC::CodeBlock::isKnownNotImmediate):
61+
(JSC::CodeBlock::instructions const):
62+
(JSC::CodeBlock::ownerExecutable const):
63+
(JSC::CodeBlock::thisRegister const):
64+
(JSC::CodeBlock::source const):
65+
(JSC::CodeBlock::sourceOffset const):
66+
(JSC::CodeBlock::firstLineColumnOffset const):
67+
(JSC::CodeBlock::createRareDataIfNecessary):
68+
(JSC::CodeBlock::ownerScriptExecutable const): Deleted.
69+
(JSC::CodeBlock::setThisRegister): Deleted.
70+
(JSC::CodeBlock::calleeSaveRegisters const): Deleted.
71+
* bytecode/EvalCodeBlock.h:
72+
* bytecode/FunctionCodeBlock.h:
73+
* bytecode/GlobalCodeBlock.h:
74+
(JSC::GlobalCodeBlock::GlobalCodeBlock):
75+
* bytecode/ModuleProgramCodeBlock.h:
76+
* bytecode/ProgramCodeBlock.h:
77+
* debugger/Debugger.cpp:
78+
(JSC::Debugger::toggleBreakpoint):
79+
* debugger/DebuggerCallFrame.cpp:
80+
(JSC::DebuggerCallFrame::sourceID const):
81+
(JSC::DebuggerCallFrame::sourceIDForCallFrame):
82+
* debugger/DebuggerScope.cpp:
83+
(JSC::DebuggerScope::location const):
84+
* dfg/DFGByteCodeParser.cpp:
85+
(JSC::DFG::ByteCodeParser::InlineStackEntry::executable):
86+
(JSC::DFG::ByteCodeParser::inliningCost):
87+
(JSC::DFG::ByteCodeParser::parseCodeBlock):
88+
* dfg/DFGCapabilities.cpp:
89+
(JSC::DFG::isSupportedForInlining):
90+
(JSC::DFG::mightCompileEval):
91+
(JSC::DFG::mightCompileProgram):
92+
(JSC::DFG::mightCompileFunctionForCall):
93+
(JSC::DFG::mightCompileFunctionForConstruct):
94+
(JSC::DFG::canUseOSRExitFuzzing):
95+
* dfg/DFGGraph.h:
96+
(JSC::DFG::Graph::executableFor):
97+
* dfg/DFGJITCompiler.cpp:
98+
(JSC::DFG::JITCompiler::compileFunction):
99+
* dfg/DFGOSREntry.cpp:
100+
(JSC::DFG::prepareOSREntry):
101+
* dfg/DFGOSRExit.cpp:
102+
(JSC::DFG::restoreCalleeSavesFor):
103+
(JSC::DFG::saveCalleeSavesFor):
104+
(JSC::DFG::saveOrCopyCalleeSavesFor):
105+
* dfg/DFGOSRExitCompilerCommon.cpp:
106+
(JSC::DFG::handleExitCounts):
107+
* dfg/DFGOperations.cpp:
108+
* dfg/DFGToFTLDeferredCompilationCallback.cpp:
109+
(JSC::DFG::ToFTLDeferredCompilationCallback::compilationDidComplete):
110+
* ftl/FTLCapabilities.cpp:
111+
(JSC::FTL::canCompile):
112+
* ftl/FTLLink.cpp:
113+
(JSC::FTL::link):
114+
* ftl/FTLOSRExitCompiler.cpp:
115+
(JSC::FTL::compileStub):
116+
* interpreter/CallFrame.cpp:
117+
(JSC::CallFrame::callerSourceOrigin):
118+
* interpreter/Interpreter.cpp:
119+
(JSC::eval):
120+
(JSC::UnwindFunctor::copyCalleeSavesToEntryFrameCalleeSavesBuffer const):
121+
* interpreter/StackVisitor.cpp:
122+
(JSC::StackVisitor::Frame::calleeSaveRegisters):
123+
(JSC::StackVisitor::Frame::sourceURL const):
124+
(JSC::StackVisitor::Frame::sourceID):
125+
(JSC::StackVisitor::Frame::computeLineAndColumn const):
126+
* interpreter/StackVisitor.h:
127+
* jit/AssemblyHelpers.h:
128+
(JSC::AssemblyHelpers::emitSaveCalleeSavesFor):
129+
(JSC::AssemblyHelpers::emitSaveOrCopyCalleeSavesFor):
130+
(JSC::AssemblyHelpers::emitRestoreCalleeSavesFor):
131+
* jit/CallFrameShuffleData.cpp:
132+
(JSC::CallFrameShuffleData::setupCalleeSaveRegisters):
133+
* jit/JIT.cpp:
134+
(JSC::JIT::compileWithoutLinking):
135+
* jit/JITToDFGDeferredCompilationCallback.cpp:
136+
(JSC::JITToDFGDeferredCompilationCallback::compilationDidComplete):
137+
* jit/JITWorklist.cpp:
138+
(JSC::JITWorklist::Plan::finalize):
139+
(JSC::JITWorklist::compileNow):
140+
* jit/RegisterAtOffsetList.cpp:
141+
(JSC::RegisterAtOffsetList::llintBaselineCalleeSaveRegisters):
142+
* jit/RegisterAtOffsetList.h:
143+
(JSC::RegisterAtOffsetList::at const):
144+
* runtime/ErrorInstance.cpp:
145+
(JSC::appendSourceToError):
146+
* runtime/ScriptExecutable.cpp:
147+
(JSC::ScriptExecutable::newCodeBlockFor):
148+
* runtime/StackFrame.cpp:
149+
(JSC::StackFrame::sourceID const):
150+
(JSC::StackFrame::sourceURL const):
151+
(JSC::StackFrame::computeLineAndColumn const):
152+
1153
2019-02-08 Robin Morisset <rmorisset@apple.com>
2154

3155
B3LowerMacros wrongly sets m_changed to true in the case of AtomicWeakCAS on x86

0 commit comments

Comments
 (0)