RESOLVED FIXED 235872
[WTF] Add GenericHashKey
https://bugs.webkit.org/show_bug.cgi?id=235872
Summary [WTF] Add GenericHashKey
Yusuke Suzuki
Reported 2022-01-30 11:40:07 PST
[WTF] Add GenericHashKey
Attachments
Patch (26.15 KB, patch)
2022-01-30 11:43 PST, Yusuke Suzuki
no flags
Patch (27.04 KB, patch)
2022-01-30 11:53 PST, Yusuke Suzuki
no flags
Patch (27.65 KB, patch)
2022-01-30 22:20 PST, Yusuke Suzuki
darin: review+
Yusuke Suzuki
Comment 1 2022-01-30 11:43:44 PST
Yusuke Suzuki
Comment 2 2022-01-30 11:53:50 PST
Darin Adler
Comment 3 2022-01-30 21:42:31 PST
I like this idea, helping fit any type into our hash table that requires empty and deleted values, not as sure about the name. If I think of a better name I will suggest it.
Yusuke Suzuki
Comment 4 2022-01-30 22:20:33 PST
Yusuke Suzuki
Comment 5 2022-01-30 22:21:09 PST
(In reply to Darin Adler from comment #3) > I like this idea, helping fit any type into our hash table that requires > empty and deleted values, not as sure about the name. If I think of a better > name I will suggest it. Nice!
Darin Adler
Comment 6 2022-01-30 22:35:53 PST
Comment on attachment 450380 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=450380&action=review Can’t help thinking how much better some of this code would look with more use of auto, auto*, and auto&. > Source/JavaScriptCore/dfg/DFGIntegerCheckCombiningPhase.cpp:195 > + Range& range = m_map.add(data.m_key, Range { }).iterator->value; When I see call sites like this, I wonder if we should overload add to have the empty value as the default. It’s annoying to have to write Range { } here. > Source/JavaScriptCore/runtime/TypeLocationCache.cpp:59 > + } else > + location = iterator->value; I often like to reverse these things so that the shorter half of the if statement goes first. But really, this looks like it should be rewritten to use ensure to me. > Source/WTF/wtf/GenericHashKey.h:77 > + if (m_value.index() != 0) > + return true; Why not write this using holds_alternative instead of index? I think it would compile to the exact same code, but it would not depend on the ordering of the alternative types in the variant.
Yusuke Suzuki
Comment 7 2022-01-30 23:21:50 PST
Comment on attachment 450380 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=450380&action=review >> Source/JavaScriptCore/dfg/DFGIntegerCheckCombiningPhase.cpp:195 >> + Range& range = m_map.add(data.m_key, Range { }).iterator->value; > > When I see call sites like this, I wonder if we should overload add to have the empty value as the default. It’s annoying to have to write Range { } here. For now, in this patch, I'll just use the existing interface. >> Source/JavaScriptCore/runtime/TypeLocationCache.cpp:59 >> + location = iterator->value; > > I often like to reverse these things so that the shorter half of the if statement goes first. > > But really, this looks like it should be rewritten to use ensure to me. Sounds good! Changed. >> Source/WTF/wtf/GenericHashKey.h:77 >> + return true; > > Why not write this using holds_alternative instead of index? I think it would compile to the exact same code, but it would not depend on the ordering of the alternative types in the variant. Sounds good, changed!
Yusuke Suzuki
Comment 8 2022-01-31 00:49:01 PST
Radar WebKit Bug Importer
Comment 9 2022-01-31 00:49:17 PST
Note You need to log in before you can comment on or make changes to this bug.