RESOLVED FIXED 207087
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock)
https://bugs.webkit.org/show_bug.cgi?id=207087
Summary [JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock)
Yusuke Suzuki
Reported 2020-02-01 00:19:09 PST
UnlinkedCodeBlock has many Vectors while they are already frozen. We should introduce UnlinkedCodeBlockWriter, and use Vector in it. And when creating UnlinkedCodeBlock, we should use RefCountedArray for Vectors.
Attachments
Patch (95.20 KB, patch)
2020-02-04 01:08 PST, Yusuke Suzuki
no flags
Patch (96.16 KB, patch)
2020-02-04 01:48 PST, Yusuke Suzuki
no flags
Patch (96.14 KB, patch)
2020-02-04 01:50 PST, Yusuke Suzuki
no flags
Patch (100.59 KB, patch)
2020-02-04 02:29 PST, Yusuke Suzuki
tzagallo: review+
Yusuke Suzuki
Comment 1 2020-02-04 01:08:20 PST
Yusuke Suzuki
Comment 2 2020-02-04 01:11:27 PST
I think this can offer sub-1% memory reduction in Gmail.
Yusuke Suzuki
Comment 3 2020-02-04 01:40:18 PST
Ah,dead-lock! Fixing
Yusuke Suzuki
Comment 4 2020-02-04 01:48:48 PST
Yusuke Suzuki
Comment 5 2020-02-04 01:50:55 PST
Yusuke Suzuki
Comment 6 2020-02-04 02:29:13 PST
Tadeu Zagallo
Comment 7 2020-02-04 10:43:05 PST
Comment on attachment 389645 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=389645&action=review Nice! > Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.cpp:150 > + if (!m_codeBlock->m_rareData) { Why would the code block have rare data at this point? > Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:291 > + m_codeBlock->finalize(m_writer.finalize()); Not necessarily on this patch, but ideally I think UnlinkedCodeBlockGenerator should own the UnlinkedCodeBlock and return it from finalize. > Source/WTF/wtf/RefCountedArray.h:201 > + T& front() { return (*this)[0]; } > + const T& front() const { return (*this)[0]; } I believe this called `first` in Vector, should we just call the same here?
Yusuke Suzuki
Comment 8 2020-02-04 11:03:35 PST
Comment on attachment 389645 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=389645&action=review Thanks! >> Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.cpp:150 >> + if (!m_codeBlock->m_rareData) { > > Why would the code block have rare data at this point? If `NeedsClassFieldInitializer::Yes` is specified, we create a rareData in UnlinkedCodeBlock's constructor. >> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:291 >> + m_codeBlock->finalize(m_writer.finalize()); > > Not necessarily on this patch, but ideally I think UnlinkedCodeBlockGenerator should own the UnlinkedCodeBlock and return it from finalize. Right! Filed a issue here. https://bugs.webkit.org/show_bug.cgi?id=207212 >> Source/WTF/wtf/RefCountedArray.h:201 >> + const T& front() const { return (*this)[0]; } > > I believe this called `first` in Vector, should we just call the same here? Nice, fixed.
Yusuke Suzuki
Comment 9 2020-02-04 11:05:25 PST
Radar WebKit Bug Importer
Comment 10 2020-02-04 11:06:18 PST
Note You need to log in before you can comment on or make changes to this bug.