WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
295171
Padding bits defeat intended HTMLEntityTableEntry size optimization
https://bugs.webkit.org/show_bug.cgi?id=295171
Summary
Padding bits defeat intended HTMLEntityTableEntry size optimization
squeek502
Reported
2025-06-28 23:30:28 PDT
In
https://github.com/WebKit/WebKit/pull/11089
, HTMLEntityTableEntry was converted to a bit-field in order to decrease the size of kStaticEntityTable. HTMLEntityTableEntry theoretically uses 57 bits, but, due to padding bits, the size of HTMLEntityTableEntry is actually 12 bytes instead of 8 bytes (the same size it was before the bit-field change). Test code: struct HTMLEntityTableEntry { unsigned firstCharacter : 21; unsigned optionalSecondCharacter : 16; unsigned nameCharactersOffset : 14; unsigned nameLengthExcludingSemicolon : 5; unsigned nameIncludesTrailingSemicolon : 1; }; static_assert(sizeof(HTMLEntityTableEntry) == 8); Clang 20.1.3: HTMLEntityTableEntry.cpp:8:15: error: static assertion failed due to requirement 'sizeof(HTMLEntityTableEntry) == 8' 8 | static_assert(sizeof(HTMLEntityTableEntry) == 8); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HTMLEntityTableEntry.cpp:8:44: note: expression evaluates to '12 == 8' 8 | static_assert(sizeof(HTMLEntityTableEntry) == 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ 1 error generated. GCC 11.4.0: HTMLEntityTableEntry.cpp:8:44: error: static assertion failed 8 | static_assert(sizeof(HTMLEntityTableEntry) == 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ (for context, this was found while I was writing
https://www.ryanliptak.com/blog/better-named-character-reference-tokenization/
)
Attachments
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2025-07-01 14:50:14 PDT
I tried moving optionalSecondCharacter to be the last member of the HTMLEntityTableEntry structure and that worked; just have to revise the code that builds the table to write out the members in the right order.
Radar WebKit Bug Importer
Comment 2
2025-07-05 23:31:13 PDT
<
rdar://problem/155138028
>
Ahmad Saleem
Comment 3
2026-06-29 22:07:59 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/68277
EWS
Comment 4
2026-06-30 18:41:47 PDT
Committed
316220@main
(4b3bf5aaf43d): <
https://commits.webkit.org/316220@main
> Reviewed commits have been landed. Closing PR #68277 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug