RESOLVED FIXED 206343
Compact sizeof(HTMLAnchorElement) and sizeof(HTMLLinkElement)
https://bugs.webkit.org/show_bug.cgi?id=206343
Summary Compact sizeof(HTMLAnchorElement) and sizeof(HTMLLinkElement)
Yusuke Suzuki
Reported 2020-01-16 02:49:20 PST
I noticed that HTMLAnchorElement is relatively frequently allocated, while it has not squeezed
Attachments
Patch (9.70 KB, patch)
2020-01-16 03:01 PST, Yusuke Suzuki
no flags
Patch (9.84 KB, patch)
2020-01-16 03:05 PST, Yusuke Suzuki
no flags
Patch (20.15 KB, patch)
2020-01-16 17:40 PST, Yusuke Suzuki
no flags
Patch (11.50 KB, patch)
2020-01-16 17:53 PST, Yusuke Suzuki
rniwa: review+
Yusuke Suzuki
Comment 1 2020-01-16 03:01:03 PST
Yusuke Suzuki
Comment 2 2020-01-16 03:05:18 PST
Yusuke Suzuki
Comment 3 2020-01-16 17:40:20 PST
Created attachment 387996 [details] Patch Uploading just to ensure that SharedStringHash is not modified
Yusuke Suzuki
Comment 4 2020-01-16 17:53:15 PST
Yusuke Suzuki
Comment 5 2020-01-16 17:54:08 PST
The first patch is demonstrating that upper 32bit is never used.
Ryosuke Niwa
Comment 6 2020-01-16 23:24:09 PST
No need to say WebCore. It's pretty obvious from class names.
Ryosuke Niwa
Comment 7 2020-01-16 23:27:43 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review > Source/WebCore/ChangeLog:3 > + [WebCore] Compact sizeof(HTMLAnchorElement) and sizeof(HTMLLinkElement) Please correct the bug title in the change log accordingly.
Yusuke Suzuki
Comment 8 2020-01-16 23:28:12 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review >> Source/WebCore/ChangeLog:3 >> + [WebCore] Compact sizeof(HTMLAnchorElement) and sizeof(HTMLLinkElement) > > Please correct the bug title in the change log accordingly. Thanks, fixed.
Yusuke Suzuki
Comment 9 2020-01-16 23:32:15 PST
Radar WebKit Bug Importer
Comment 10 2020-01-16 23:33:20 PST
Darin Adler
Comment 11 2020-01-17 08:58:13 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review > Source/WebCore/html/HTMLLinkElement.h:140 > String m_type; > String m_media; > + String m_integrityMetadataForPendingSheetRequest; > std::unique_ptr<DOMTokenList> m_sizes; > + std::unique_ptr<DOMTokenList> m_relList; Seems like we could make HTMLinkElement significantly smaller given that it has many different purposes and we have separate data members for each of those purposes. Something like the rare data pattern perhaps? Even unclear why we need members like m_type and m_media at all, just to cache computed attribute values. > Source/WebCore/html/LinkRelAttribute.cpp:45 > + : iconType() Why is this needed? It won’t get initialized unless we specify it explicitly? I kind of wish Markable had a side effect of initializing things to zero when constructed. Not sure we have any use cases for scalars that don’t get initialized.
Emilio Cobos Álvarez (:emilio)
Comment 12 2020-01-17 09:13:37 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review > Source/WebCore/html/HTMLLinkElement.cpp:305 > + makeScopeExit([&] { m_isHandlingBeforeLoad = previous; }); FWIW, this doesn't look right. This will instantly run the callback, as it's not kept alive by any variable.
Chris Dumez
Comment 13 2020-01-17 09:26:59 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review >> Source/WebCore/html/HTMLLinkElement.cpp:305 >> + makeScopeExit([&] { m_isHandlingBeforeLoad = previous; }); > > FWIW, this doesn't look right. This will instantly run the callback, as it's not kept alive by any variable. lol, good catch! Not the first time we get caught by that. The return value of makeScopeExit should really be marked as never ignored.
Chris Dumez
Comment 14 2020-01-17 09:28:32 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review >>> Source/WebCore/html/HTMLLinkElement.cpp:305 >>> + makeScopeExit([&] { m_isHandlingBeforeLoad = previous; }); >> >> FWIW, this doesn't look right. This will instantly run the callback, as it's not kept alive by any variable. > > lol, good catch! Not the first time we get caught by that. The return value of makeScopeExit should really be marked as never ignored. I mean WARN_UNUSED_RETURN.
Yusuke Suzuki
Comment 15 2020-02-24 15:44:15 PST
(In reply to Chris Dumez from comment #14) > Comment on attachment 387998 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=387998&action=review > > >>> Source/WebCore/html/HTMLLinkElement.cpp:305 > >>> + makeScopeExit([&] { m_isHandlingBeforeLoad = previous; }); > >> > >> FWIW, this doesn't look right. This will instantly run the callback, as it's not kept alive by any variable. > > > > lol, good catch! Not the first time we get caught by that. The return value of makeScopeExit should really be marked as never ignored. > > I mean WARN_UNUSED_RETURN. Oops, nice. I'm creating a patch for this now.
Yusuke Suzuki
Comment 16 2020-02-24 15:51:38 PST
Comment on attachment 387998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387998&action=review >>>>> Source/WebCore/html/HTMLLinkElement.cpp:305 >>>>> + makeScopeExit([&] { m_isHandlingBeforeLoad = previous; }); >>>> >>>> FWIW, this doesn't look right. This will instantly run the callback, as it's not kept alive by any variable. >>> >>> lol, good catch! Not the first time we get caught by that. The return value of makeScopeExit should really be marked as never ignored. >> >> I mean WARN_UNUSED_RETURN. > > Oops, nice. I'm creating a patch for this now. Opened for this https://bugs.webkit.org/show_bug.cgi?id=208162
Note You need to log in before you can comment on or make changes to this bug.