RESOLVED FIXED 230437
Add LLVM/FLang's int128_t implementation to WTF
https://bugs.webkit.org/show_bug.cgi?id=230437
Summary Add LLVM/FLang's int128_t implementation to WTF
Philip Chimento
Reported 2021-09-17 17:33:37 PDT
Add LLVM/FLang's int128_t implementation to WTF
Attachments
Patch (26.39 KB, patch)
2021-09-17 17:37 PDT, Philip Chimento
no flags
Patch (48.90 KB, patch)
2021-09-20 12:19 PDT, Philip Chimento
ews-feeder: commit-queue-
Patch (48.91 KB, patch)
2021-09-20 12:52 PDT, Philip Chimento
no flags
Philip Chimento
Comment 1 2021-09-17 17:34:35 PDT
This will be necessary for implementing Temporal.Instant.
Philip Chimento
Comment 2 2021-09-17 17:37:29 PDT
Philip Chimento
Comment 3 2021-09-17 17:38:04 PDT
(The style checker is going to fail because the source files contain no copyright notices; I'm not sure what to do about that, because there are none in the original code.)
Yusuke Suzuki
Comment 4 2021-09-18 00:09:15 PDT
Comment on attachment 438537 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=438537&action=review r=me with comments > Source/WTF/wtf/CMakeLists.txt:106 > + Int128.h Add this header to xcodeproj. > Source/WTF/wtf/CMakeLists.txt:117 > + LeadingZeroBitCount.h Add this header to xcodeproj. > Source/WTF/wtf/LeadingZeroBitCount.h:41 > +static constexpr std::uint64_t deBruijn {0x07edd5e59a4e28c2}; > +static constexpr std::uint8_t mapping[64] {63, 0, 58, 1, 59, 47, 53, 2, 60, 39, > + 48, 27, 54, 33, 42, 3, 61, 51, 37, 40, 49, 18, 28, 20, 55, 30, 34, 11, 43, > + 14, 22, 4, 62, 57, 46, 52, 38, 26, 32, 41, 50, 36, 17, 19, 29, 10, 13, 21, > + 56, 45, 25, 31, 35, 16, 9, 12, 44, 24, 15, 8, 23, 7, 6, 5}; > +} // namespace You should create cpp file, and putting these constant arrays in C++ side. Otherwise, each translation unit will materialize this duplicate array, and enlarging binary size. > Source/WTF/wtf/LeadingZeroBitCount.h:43 > +inline constexpr int LeadingZeroBitCount(std::uint64_t x) Rename it to leadingZeroBitCount > Source/WTF/wtf/LeadingZeroBitCount.h:64 > +inline constexpr int LeadingZeroBitCount(std::uint32_t x) Ditto. > Source/WTF/wtf/LeadingZeroBitCount.h:69 > +inline constexpr int LeadingZeroBitCount(std::uint16_t x) Ditto > Source/WTF/wtf/LeadingZeroBitCount.h:86 > +namespace detail { > +static constexpr std::uint8_t eightBitLeadingZeroBitCount[256] {8, 7, 6, 6, 5, 5, > + 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, > + 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, > + 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, > + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; > +} Ditto. > Source/WTF/wtf/LeadingZeroBitCount.h:88 > +inline constexpr int LeadingZeroBitCount(std::uint8_t x) Ditto. > Source/WTF/wtf/LeadingZeroBitCount.h:93 > +template <typename A> inline constexpr int BitsNeededFor(A x) Rename it to bitsNeededFor. > Tools/TestWebKitAPI/CMakeLists.txt:57 > + Tests/WTF/Int128.cpp > Tests/WTF/IntegerToStringConversion.cpp > Tests/WTF/IteratorRange.cpp > Tests/WTF/JSONValue.cpp > Tests/WTF/LEBDecoder.cpp > + Tests/WTF/LeadingZeroBitCount.cpp Add them to xcodeproj to run these tests on macOS / iOS too.
Alexey Proskuryakov
Comment 5 2021-09-19 12:47:37 PDT
If the license is not known, then we cannot accept this code in WebKit. I suspect that these projects do have licenses though.
Philip Chimento
Comment 6 2021-09-19 13:44:09 PDT
The license is known (and listed in the first lines of each source file), but the copyright is not.
Yusuke Suzuki
Comment 7 2021-09-19 16:01:13 PDT
(In reply to Alexey Proskuryakov from comment #5) > If the license is not known, then we cannot accept this code in WebKit. I > suspect that these projects do have licenses though. It is LLVM, from where, we already have some files (B3ComputeDivisionMagic.h, old wtf/StdFilesystem.{cpp,h}, wtf/Span.h). Let's just include https://llvm.org/LICENSE.txt file as WTF/LICENSE-LLVM.txt as https://trac.webkit.org/changeset/268020/webkit did.
Philip Chimento
Comment 8 2021-09-20 12:19:32 PDT
Philip Chimento
Comment 9 2021-09-20 12:52:07 PDT
Radar WebKit Bug Importer
Comment 10 2021-09-21 10:19:42 PDT
EWS
Comment 11 2021-09-21 11:04:27 PDT
Committed r282828 (241959@main): <https://commits.webkit.org/241959@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 438712 [details].
Note You need to log in before you can comment on or make changes to this bug.