RESOLVED FIXED 237262
Adopt the modern Hasher more widely
https://bugs.webkit.org/show_bug.cgi?id=237262
Summary Adopt the modern Hasher more widely
Chris Dumez
Reported 2022-02-27 17:56:55 PST
Adopt the modern Hasher more widely.
Attachments
Patch (22.07 KB, patch)
2022-02-27 18:07 PST, Chris Dumez
no flags
Patch (22.26 KB, patch)
2022-02-28 07:40 PST, Chris Dumez
no flags
Patch (22.44 KB, patch)
2022-02-28 09:24 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2022-02-27 18:07:49 PST
Darin Adler
Comment 2 2022-02-27 22:47:52 PST
Comment on attachment 453364 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453364&action=review review- because Color’s hashing is wrong. > Source/WebCore/platform/graphics/Color.h:262 > + add(hasher, color.m_colorAndFlags); When the color is out of line, this is wrong. We need to hash the data in the out-of-line color, not the pointer, since two colors with different pointers can have the same value. That’s what the old Color::hash function did, and this needs to do the same. Also, this should take const Color& since it’s expensive to copy a Color when it’s out-of-line.
Chris Dumez
Comment 3 2022-02-28 07:27:50 PST
Comment on attachment 453364 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453364&action=review >> Source/WebCore/platform/graphics/Color.h:262 >> + add(hasher, color.m_colorAndFlags); > > When the color is out of line, this is wrong. We need to hash the data in the out-of-line color, not the pointer, since two colors with different pointers can have the same value. That’s what the old Color::hash function did, and this needs to do the same. > > Also, this should take const Color& since it’s expensive to copy a Color when it’s out-of-line. My bad, I did look at the previous hasher but missed the fact that we could end up with a pointer. I'll re-introduce the previous hasher behavior.
Chris Dumez
Comment 4 2022-02-28 07:40:00 PST
Sam Weinig
Comment 5 2022-02-28 08:20:57 PST
Comment on attachment 453392 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453392&action=review Love seeing this. > Source/WebKit/Platform/IPC/StringReference.cpp:62 > + return computeHash(a); This parameter names could be better. string? reference? stringReference?
Chris Dumez
Comment 6 2022-02-28 09:24:57 PST
EWS
Comment 7 2022-02-28 12:00:44 PST
Committed r290610 (247883@main): <https://commits.webkit.org/247883@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 453397 [details].
Radar WebKit Bug Importer
Comment 8 2022-02-28 12:01:18 PST
Darin Adler
Comment 9 2022-02-28 13:28:50 PST
Comment on attachment 453397 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453397&action=review > Source/WebCore/platform/graphics/Color.h:265 > + if (color.isOutOfLine()) > + add(hasher, color.asOutOfLine().unresolvedComponents(), color.colorSpace(), color.flags().toRaw()); > + else > + add(hasher, color.asPackedInline().value, color.flags().toRaw()); Surprised calling toRaw was needed. We should fix the Hasher mechanism so we don’t need that.
Chris Dumez
Comment 10 2022-02-28 14:02:35 PST
(In reply to Darin Adler from comment #9) > Comment on attachment 453397 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=453397&action=review > > > Source/WebCore/platform/graphics/Color.h:265 > > + if (color.isOutOfLine()) > > + add(hasher, color.asOutOfLine().unresolvedComponents(), color.colorSpace(), color.flags().toRaw()); > > + else > > + add(hasher, color.asPackedInline().value, color.flags().toRaw()); > > Surprised calling toRaw was needed. We should fix the Hasher mechanism so we > don’t need that. Oh, I don’t know for sure that it was needed, I copied from the pre-existing hashing function.
Chris Dumez
Comment 11 2022-02-28 15:09:57 PST
(In reply to Chris Dumez from comment #10) > (In reply to Darin Adler from comment #9) > > Comment on attachment 453397 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=453397&action=review > > > > > Source/WebCore/platform/graphics/Color.h:265 > > > + if (color.isOutOfLine()) > > > + add(hasher, color.asOutOfLine().unresolvedComponents(), color.colorSpace(), color.flags().toRaw()); > > > + else > > > + add(hasher, color.asPackedInline().value, color.flags().toRaw()); > > > > Surprised calling toRaw was needed. We should fix the Hasher mechanism so we > > don’t need that. > > Oh, I don’t know for sure that it was needed, I copied from the pre-existing > hashing function. It wasn't needed. I fixed it in <https://commits.webkit.org/r290616>.
Note You need to log in before you can comment on or make changes to this bug.