RESOLVED FIXED 224715
[JSC] Do not use Bag<> for DFG / FTL watchpoints
https://bugs.webkit.org/show_bug.cgi?id=224715
Summary [JSC] Do not use Bag<> for DFG / FTL watchpoints
Yusuke Suzuki
Reported 2021-04-17 01:07:10 PDT
[JSC] Do not use Bag<> for DFG / FTL watchpoints
Attachments
Patch (27.76 KB, patch)
2021-04-17 01:07 PDT, Yusuke Suzuki
no flags
Patch (33.11 KB, patch)
2021-04-17 01:29 PDT, Yusuke Suzuki
no flags
Patch (34.11 KB, patch)
2021-04-17 01:47 PDT, Yusuke Suzuki
no flags
Patch (34.28 KB, patch)
2021-04-17 01:56 PDT, Yusuke Suzuki
darin: review+
Yusuke Suzuki
Comment 1 2021-04-17 01:07:23 PDT
Yusuke Suzuki
Comment 2 2021-04-17 01:29:06 PDT
Yusuke Suzuki
Comment 3 2021-04-17 01:47:30 PDT
Yusuke Suzuki
Comment 4 2021-04-17 01:56:27 PDT
Darin Adler
Comment 5 2021-04-17 15:59:00 PDT
Comment on attachment 426327 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426327&action=review Title should say "for better memory efficiency" or something like that. While I’m not a deep expert on this code, it looks right to me. > Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.cpp:43 > +AdaptiveInferredPropertyValueWatchpointBase::AdaptiveInferredPropertyValueWatchpointBase() > + : m_key() > +{ > +} > + Why is this needed? Isn’t this what the default constructor would do if we just wrote "= default"? > Source/JavaScriptCore/bytecode/CodeBlockJettisoningWatchpoint.h:45 > + CodeBlockJettisoningWatchpoint() > + : CodeBlockJettisoningWatchpoint(nullptr) > + { > + } We could achieve this more economically by just writing "CodeBlock* codeBlock = nullptr" in the other constructor. > Source/JavaScriptCore/dfg/DFGAdaptiveInferredPropertyValueWatchpoint.cpp:46 > +AdaptiveInferredPropertyValueWatchpoint::AdaptiveInferredPropertyValueWatchpoint() > + : Base() > + , m_codeBlock(nullptr) > +{ > +} It would be more elegant to initialize m_codeBlock to nullptr in the header, and then use "= default" for this constructor. > Source/JavaScriptCore/dfg/DFGAdaptiveStructureWatchpoint.cpp:47 > + , m_codeBlock(nullptr) Can we initialize m_codeBlock in the class definition, and then omit this line? Maybe not because of JSC_WATCHPOINT_FIELD? > Source/JavaScriptCore/dfg/DFGAdaptiveStructureWatchpoint.cpp:48 > + , m_key() Can we omit this line? Pretty sure that this isn’t needed. Maybe not because of JSC_WATCHPOINT_FIELD? > Source/JavaScriptCore/dfg/DFGCommonData.cpp:151 > + for (AdaptiveStructureWatchpoint& watchpoint : m_adaptiveStructureWatchpoints) I think code like this is more readable with auto& rather than writing out a type name. Using "auto&" documents that the type is correct and does not slice or upcast. > Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h:49 > + WatchpointCollector() = default; I believe we can simply omit this entirely, and behavior should be the same. > Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h:60 > + template<typename Func> > + void addWatchpoint(const Func& func) Could we use a word instead of "func"?
Yusuke Suzuki
Comment 6 2021-04-18 00:58:03 PDT
Comment on attachment 426327 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426327&action=review Thanks >> Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.cpp:43 >> + > > Why is this needed? Isn’t this what the default constructor would do if we just wrote "= default"? Yeah, replaced with = default; >> Source/JavaScriptCore/bytecode/CodeBlockJettisoningWatchpoint.h:45 >> + } > > We could achieve this more economically by just writing "CodeBlock* codeBlock = nullptr" in the other constructor. Replaced. >> Source/JavaScriptCore/dfg/DFGAdaptiveInferredPropertyValueWatchpoint.cpp:46 >> +} > > It would be more elegant to initialize m_codeBlock to nullptr in the header, and then use "= default" for this constructor. Replaced. >> Source/JavaScriptCore/dfg/DFGAdaptiveStructureWatchpoint.cpp:47 >> + , m_codeBlock(nullptr) > > Can we initialize m_codeBlock in the class definition, and then omit this line? Maybe not because of JSC_WATCHPOINT_FIELD? Unfortunately it is not since JSC_WATCHPOINT_FIELD. >> Source/JavaScriptCore/dfg/DFGAdaptiveStructureWatchpoint.cpp:48 >> + , m_key() > > Can we omit this line? Pretty sure that this isn’t needed. Maybe not because of JSC_WATCHPOINT_FIELD? Yes, we can omit it. >> Source/JavaScriptCore/dfg/DFGCommonData.cpp:151 >> + for (AdaptiveStructureWatchpoint& watchpoint : m_adaptiveStructureWatchpoints) > > I think code like this is more readable with auto& rather than writing out a type name. Using "auto&" documents that the type is correct and does not slice or upcast. Replaced. >> Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h:49 >> + WatchpointCollector() = default; > > I believe we can simply omit this entirely, and behavior should be the same. Removed. >> Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h:60 >> + void addWatchpoint(const Func& func) > > Could we use a word instead of "func"? Replaced with function.
Yusuke Suzuki
Comment 7 2021-04-18 01:06:59 PDT
Yusuke Suzuki
Comment 8 2021-04-18 01:30:23 PDT
Comment on attachment 426327 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426327&action=review >>> Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h:49 >>> + WatchpointCollector() = default; >> >> I believe we can simply omit this entirely, and behavior should be the same. > > Removed. Ah, this was important. If we are using WTF_MAKE_NONCOPYABLE, we need this. Otherwise, this becomes compile error.
Yusuke Suzuki
Comment 9 2021-04-18 01:35:39 PDT
Ryan Haddad
Comment 10 2021-04-19 22:07:35 PDT
Note You need to log in before you can comment on or make changes to this bug.