Bug 232129 - [WTF] Replace current LLVM flang's Int128 with abseil-cpp's Int128
Summary: [WTF] Replace current LLVM flang's Int128 with abseil-cpp's Int128
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-21 20:21 PDT by Yusuke Suzuki
Modified: 2021-10-23 14:36 PDT (History)
11 users (show)

See Also:


Attachments
Patch (132.81 KB, patch)
2021-10-21 20:24 PDT, Yusuke Suzuki
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (133.06 KB, patch)
2021-10-21 20:42 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (133.06 KB, patch)
2021-10-21 20:44 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (133.06 KB, patch)
2021-10-21 20:46 PDT, Yusuke Suzuki
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (133.06 KB, patch)
2021-10-21 21:08 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (154.09 KB, patch)
2021-10-23 00:29 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2021-10-21 20:21:24 PDT
[WTF] Replace current LLVM flang's Int128 with abseil-cpp's Int128
Comment 1 Yusuke Suzuki 2021-10-21 20:24:45 PDT
Created attachment 442107 [details]
Patch
Comment 2 Yusuke Suzuki 2021-10-21 20:42:24 PDT
Created attachment 442109 [details]
Patch
Comment 3 Yusuke Suzuki 2021-10-21 20:44:03 PDT
Created attachment 442110 [details]
Patch
Comment 4 Yusuke Suzuki 2021-10-21 20:46:24 PDT
Created attachment 442111 [details]
Patch
Comment 5 Yusuke Suzuki 2021-10-21 21:08:36 PDT
Created attachment 442116 [details]
Patch
Comment 6 Philip Chimento 2021-10-22 16:56:24 PDT
Comment on attachment 442116 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=442116&action=review

Thanks for doing this so quickly! This int128 implementation looks more comprehensive than the Flang one anyway.

I would suggest removing WTF/LeadingZeroBitCount.{h,cpp} as well, because this implementation uses the clz() from WTF/MathExtras.h (which I didn't realize existed!) for counting leading zeros, and WTF::LeadingZeroBitCount was only added because the Flang int128 pulled it in.

(I don't have reviewer privileges, so I can't mark this r+, but otherwise LGTM)

> Source/WTF/wtf/Int128.h:81
> +// Additionally, if your compiler supports `__int128`, `UInt128Impl` is

If this functionality was removed when copying from Abseil, it's probably good to remove the comment as well, to avoid confusion.

> Source/WTF/wtf/Int128.h:100
> +//     float y = absl::UInt128Max();  // Error. UInt128Impl cannot be implicitly

Probably good to remove `absl::` here and in line 103 as well

> Source/WTF/wtf/Int128.h:292
> +// Additionally, if your compiler supports `__int128`, `Int128Impl` is

Same as earlier comment.

> Source/WTF/wtf/Int128.h:830
> +#else   // ABSL_HAVE_INTRINSIC128

This is a bit confusing. Although looking in the original source I see the code is actually correct when you remove the ABSL_HAVE_INTRINSIC128 case, because the MSVC&&x86_64 case was originally an #elif. So no need to change, but maybe consider just removing the comment.

> Tools/TestWebKitAPI/Tests/WTF/Int128.cpp:-79
> -static void TestVsNative(__uint128_t x, __uint128_t y)

I would suggest keeping the VsNative tests, and actually adding similar ones for the signed int128. These are probably the best indicator if something is wrong in the implementation. That's what originally alerted me to the Flang implementation's signed int128 operator>> not extending the sign.
Comment 7 Yusuke Suzuki 2021-10-23 00:29:00 PDT
Comment on attachment 442116 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=442116&action=review

>> Source/WTF/wtf/Int128.h:81
>> +// Additionally, if your compiler supports `__int128`, `UInt128Impl` is
> 
> If this functionality was removed when copying from Abseil, it's probably good to remove the comment as well, to avoid confusion.

Done.

>> Source/WTF/wtf/Int128.h:100
>> +//     float y = absl::UInt128Max();  // Error. UInt128Impl cannot be implicitly
> 
> Probably good to remove `absl::` here and in line 103 as well

Done.

>> Source/WTF/wtf/Int128.h:292
>> +// Additionally, if your compiler supports `__int128`, `Int128Impl` is
> 
> Same as earlier comment.

Done.

>> Source/WTF/wtf/Int128.h:830
>> +#else   // ABSL_HAVE_INTRINSIC128
> 
> This is a bit confusing. Although looking in the original source I see the code is actually correct when you remove the ABSL_HAVE_INTRINSIC128 case, because the MSVC&&x86_64 case was originally an #elif. So no need to change, but maybe consider just removing the comment.

Removed.

>> Tools/TestWebKitAPI/Tests/WTF/Int128.cpp:-79
>> -static void TestVsNative(__uint128_t x, __uint128_t y)
> 
> I would suggest keeping the VsNative tests, and actually adding similar ones for the signed int128. These are probably the best indicator if something is wrong in the implementation. That's what originally alerted me to the Flang implementation's signed int128 operator>> not extending the sign.

Done.
Comment 8 Yusuke Suzuki 2021-10-23 00:29:52 PDT
Created attachment 442255 [details]
Patch
Comment 9 Yusuke Suzuki 2021-10-23 14:15:37 PDT
Comment on attachment 442255 [details]
Patch

Thank you!
Comment 10 EWS 2021-10-23 14:35:34 PDT
Committed r284748 (243457@main): <https://commits.webkit.org/243457@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 442255 [details].
Comment 11 Radar WebKit Bug Importer 2021-10-23 14:36:18 PDT
<rdar://problem/84582748>