<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[282828] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/282828">282828</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-09-21 11:04:20 -0700 (Tue, 21 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add LLVM/FLang's int128_t implementation to WTF
https://bugs.webkit.org/show_bug.cgi?id=230437

Source/WTF:

Added int128_t implementation from LLVM, and its dependency
LeadingZeroBitCount.h. Both reformatted according to WebKit style.

Patch by Philip Chimento <philip.chimento@gmail.com> on 2021-09-21
Reviewed by Yusuke Suzuki.

* LICENSE-LLVM.txt: Added.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Int128.h: Added.
(WTF::Int128Impl::Int128Impl):
(WTF::Int128Impl::operator+ const):
(WTF::Int128Impl::operator~ const):
(WTF::Int128Impl::operator- const):
(WTF::Int128Impl::operator! const):
(WTF::Int128Impl::operator bool const):
(WTF::Int128Impl::operator std::uint64_t const):
(WTF::Int128Impl::operator std::int64_t const):
(WTF::Int128Impl::operator int const):
(WTF::Int128Impl::high const):
(WTF::Int128Impl::low const):
(WTF::Int128Impl::operator++):
(WTF::Int128Impl::operator--):
(WTF::Int128Impl::operator& const):
(WTF::Int128Impl::operator |  const):
(WTF::Int128Impl::operator^ const):
(WTF::Int128Impl::operator<< const):
(WTF::Int128Impl::operator>> const):
(WTF::Int128Impl::operator* const):
(WTF::Int128Impl::operator/ const):
(WTF::Int128Impl::operator% const):
(WTF::Int128Impl::operator< const):
(WTF::Int128Impl::operator<= const):
(WTF::Int128Impl::operator== const):
(WTF::Int128Impl::operator!= const):
(WTF::Int128Impl::operator>= const):
(WTF::Int128Impl::operator> const):
(WTF::Int128Impl::operator&=):
(WTF::Int128Impl::operator|=):
(WTF::Int128Impl::operator^=):
(WTF::Int128Impl::operator<<=):
(WTF::Int128Impl::operator>>=):
(WTF::Int128Impl::operator+=):
(WTF::Int128Impl::operator-=):
(WTF::Int128Impl::operator*=):
(WTF::Int128Impl::operator/=):
(WTF::Int128Impl::operator%=):
(WTF::Int128Impl::leadingZeroes const):
* wtf/LeadingZeroBitCount.cpp: Added.
* wtf/LeadingZeroBitCount.h: Added.
(WTF::leadingZeroBitCount):
(WTF::bitsNeededFor):

Tools:

Added tests for Int128 and LeadingZeroBitCount copied from LLVM's tests,
reformatted according to WebKit style.

Patch by Philip Chimento <pchimento@igalia.com> on 2021-09-21
Reviewed by Yusuke Suzuki.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/Int128.cpp: Added.
(TestWebKitAPI::TestUnary):
(TestWebKitAPI::TestBinary):
(TestWebKitAPI::TEST):
(TestWebKitAPI::ToNative):
(TestWebKitAPI::FromNative):
(TestWebKitAPI::TestVsNative):
* TestWebKitAPI/Tests/WTF/LeadingZeroBitCount.cpp: Added.
(countWithTwoShiftedBits):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPICMakeListstxt">trunk/Tools/TestWebKitAPI/CMakeLists.txt</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFLICENSELLVMtxt">trunk/Source/WTF/LICENSE-LLVM.txt</a></li>
<li><a href="#trunkSourceWTFwtfInt128h">trunk/Source/WTF/wtf/Int128.h</a></li>
<li><a href="#trunkSourceWTFwtfLeadingZeroBitCountcpp">trunk/Source/WTF/wtf/LeadingZeroBitCount.cpp</a></li>
<li><a href="#trunkSourceWTFwtfLeadingZeroBitCounth">trunk/Source/WTF/wtf/LeadingZeroBitCount.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFInt128cpp">trunk/Tools/TestWebKitAPI/Tests/WTF/Int128.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFLeadingZeroBitCountcpp">trunk/Tools/TestWebKitAPI/Tests/WTF/LeadingZeroBitCount.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (282827 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-09-21 17:49:11 UTC (rev 282827)
+++ trunk/Source/WTF/ChangeLog  2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2021-09-21  Philip Chimento  <philip.chimento@gmail.com>
+
+        Add LLVM/FLang's int128_t implementation to WTF
+        https://bugs.webkit.org/show_bug.cgi?id=230437
+
+        Added int128_t implementation from LLVM, and its dependency
+        LeadingZeroBitCount.h. Both reformatted according to WebKit style.
+
+        Reviewed by Yusuke Suzuki.
+
+        * LICENSE-LLVM.txt: Added.
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/Int128.h: Added.
+        (WTF::Int128Impl::Int128Impl):
+        (WTF::Int128Impl::operator+ const):
+        (WTF::Int128Impl::operator~ const):
+        (WTF::Int128Impl::operator- const):
+        (WTF::Int128Impl::operator! const):
+        (WTF::Int128Impl::operator bool const):
+        (WTF::Int128Impl::operator std::uint64_t const):
+        (WTF::Int128Impl::operator std::int64_t const):
+        (WTF::Int128Impl::operator int const):
+        (WTF::Int128Impl::high const):
+        (WTF::Int128Impl::low const):
+        (WTF::Int128Impl::operator++):
+        (WTF::Int128Impl::operator--):
+        (WTF::Int128Impl::operator& const):
+        (WTF::Int128Impl::operator |  const):
+        (WTF::Int128Impl::operator^ const):
+        (WTF::Int128Impl::operator<< const):
+        (WTF::Int128Impl::operator>> const):
+        (WTF::Int128Impl::operator* const):
+        (WTF::Int128Impl::operator/ const):
+        (WTF::Int128Impl::operator% const):
+        (WTF::Int128Impl::operator< const):
+        (WTF::Int128Impl::operator<= const):
+        (WTF::Int128Impl::operator== const):
+        (WTF::Int128Impl::operator!= const):
+        (WTF::Int128Impl::operator>= const):
+        (WTF::Int128Impl::operator> const):
+        (WTF::Int128Impl::operator&=):
+        (WTF::Int128Impl::operator|=):
+        (WTF::Int128Impl::operator^=):
+        (WTF::Int128Impl::operator<<=):
+        (WTF::Int128Impl::operator>>=):
+        (WTF::Int128Impl::operator+=):
+        (WTF::Int128Impl::operator-=):
+        (WTF::Int128Impl::operator*=):
+        (WTF::Int128Impl::operator/=):
+        (WTF::Int128Impl::operator%=):
+        (WTF::Int128Impl::leadingZeroes const):
+        * wtf/LeadingZeroBitCount.cpp: Added.
+        * wtf/LeadingZeroBitCount.h: Added.
+        (WTF::leadingZeroBitCount):
+        (WTF::bitsNeededFor):
+
</ins><span class="cx"> 2021-09-20  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Reduce use of makeRefPtr() and use RefPtr { } directly
</span></span></pre></div>
<a id="trunkSourceWTFLICENSELLVMtxt"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/LICENSE-LLVM.txt (0 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/LICENSE-LLVM.txt                                (rev 0)
+++ trunk/Source/WTF/LICENSE-LLVM.txt   2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -0,0 +1,219 @@
</span><ins>+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+    1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+    2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+    3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+    4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+    5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+    6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+    7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+    8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+    9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+    END OF TERMS AND CONDITIONS
+
+    APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+    Copyright [yyyy] [name of copyright owner]
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+
+--- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
</ins></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (282827 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj   2021-09-21 17:49:11 UTC (rev 282827)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj      2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -189,6 +189,7 @@
</span><span class="cx">          E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
</span><span class="cx">          EB2C86D9267B275D0052CB9A /* CPUTimePOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB2C86D8267B275C0052CB9A /* CPUTimePOSIX.cpp */; };
</span><span class="cx">          EB61EDC72409CCC1001EFE36 /* SystemTracingCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */; };
</span><ins>+               F6D67D3426F90143006E0349 /* LeadingZeroBitCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6D67D3326F90143006E0349 /* LeadingZeroBitCount.cpp */; };
</ins><span class="cx">           FE032AD22463E43B0012D7C7 /* WTFConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE032AD02463E43B0012D7C7 /* WTFConfig.cpp */; };
</span><span class="cx">          FE05FAFF1FE5007500093230 /* WTFAssertions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */; };
</span><span class="cx">          FE1E2C3B2240C06600F6B729 /* PtrTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1E2C392240C05400F6B729 /* PtrTag.cpp */; };
</span><span class="lines">@@ -784,6 +785,9 @@
</span><span class="cx">          EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; };
</span><span class="cx">          EBFF67FC240D7D660078FF1B /* OSVariantSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSVariantSPI.h; sourceTree = "<group>"; };
</span><span class="cx">          EF7D6CD59D8642A8A0DA86AD /* StackTrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackTrace.h; sourceTree = "<group>"; };
</span><ins>+               F6D67D3126F90142006E0349 /* LeadingZeroBitCount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeadingZeroBitCount.h; sourceTree = "<group>"; };
+               F6D67D3226F90142006E0349 /* Int128.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Int128.h; sourceTree = "<group>"; };
+               F6D67D3326F90143006E0349 /* LeadingZeroBitCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LeadingZeroBitCount.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           F72BBDB107FA424886178B9E /* SymbolImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolImpl.cpp; sourceTree = "<group>"; };
</span><span class="cx">          FE032AD02463E43B0012D7C7 /* WTFConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WTFConfig.cpp; sourceTree = "<group>"; };
</span><span class="cx">          FE032AD12463E43B0012D7C7 /* WTFConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFConfig.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -1112,6 +1116,7 @@
</span><span class="cx">                          A8A472BC151A825A004123FF /* InlineASM.h */,
</span><span class="cx">                          A70DA0821799F04D00529A9B /* Insertion.h */,
</span><span class="cx">                          5182C22C1F2BC7E60059BA7C /* InstanceCounted.h */,
</span><ins>+                               F6D67D3226F90142006E0349 /* Int128.h */,
</ins><span class="cx">                           33FD4811265CB38000ABE4F4 /* InterferenceGraph.h */,
</span><span class="cx">                          0F7EB85B1FA8FF4100F1ABCB /* IsoMalloc.h */,
</span><span class="cx">                          0F7EB85C1FA8FF4200F1ABCB /* IsoMallocInlines.h */,
</span><span class="lines">@@ -1124,6 +1129,8 @@
</span><span class="cx">                          7C9692941F66306E00267A9E /* KeyValuePair.h */,
</span><span class="cx">                          C2BCFC3E1F61D13000C9222C /* Language.cpp */,
</span><span class="cx">                          C2BCFC3F1F61D13000C9222C /* Language.h */,
</span><ins>+                               F6D67D3326F90143006E0349 /* LeadingZeroBitCount.cpp */,
+                               F6D67D3126F90142006E0349 /* LeadingZeroBitCount.h */,
</ins><span class="cx">                           539EB0621D55284200C82EF7 /* LEBDecoder.h */,
</span><span class="cx">                          337B2D6826546EAA00DDFD3D /* LikelyDenseUnsignedIntegerSet.cpp */,
</span><span class="cx">                          337B2D6926546EAA00DDFD3D /* LikelyDenseUnsignedIntegerSet.h */,
</span><span class="lines">@@ -1760,6 +1767,7 @@
</span><span class="cx">                          C2BCFC401F61D13000C9222C /* Language.cpp in Sources */,
</span><span class="cx">                          C2BCFC421F61D61600C9222C /* LanguageCF.cpp in Sources */,
</span><span class="cx">                          1C503BE623AAE0AE0072E66B /* LanguageCocoa.mm in Sources */,
</span><ins>+                               F6D67D3426F90143006E0349 /* LeadingZeroBitCount.cpp in Sources */,
</ins><span class="cx">                           337B2D6A26546EB300DDFD3D /* LikelyDenseUnsignedIntegerSet.cpp in Sources */,
</span><span class="cx">                          E3B8E41D24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp in Sources */,
</span><span class="cx">                          C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (282827 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt      2021-09-21 17:49:11 UTC (rev 282827)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -103,6 +103,7 @@
</span><span class="cx">     InlineASM.h
</span><span class="cx">     Insertion.h
</span><span class="cx">     InstanceCounted.h
</span><ins>+    Int128.h
</ins><span class="cx">     InterferenceGraph.h
</span><span class="cx">     IsoMalloc.h
</span><span class="cx">     IsoMallocInlines.h
</span><span class="lines">@@ -113,6 +114,7 @@
</span><span class="cx">     KeyValuePair.h
</span><span class="cx">     LEBDecoder.h
</span><span class="cx">     Language.h
</span><ins>+    LeadingZeroBitCount.h
</ins><span class="cx">     LikelyDenseUnsignedIntegerSet.h
</span><span class="cx">     ListDump.h
</span><span class="cx">     ListHashSet.h
</span><span class="lines">@@ -423,6 +425,7 @@
</span><span class="cx">     JSONValues.cpp
</span><span class="cx">     JSValueMalloc.cpp
</span><span class="cx">     Language.cpp
</span><ins>+    LeadingZeroBitCount.cpp
</ins><span class="cx">     LikelyDenseUnsignedIntegerSet.cpp
</span><span class="cx">     Lock.cpp
</span><span class="cx">     LockedPrintStream.cpp
</span></span></pre></div>
<a id="trunkSourceWTFwtfInt128h"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/Int128.h (0 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Int128.h                            (rev 0)
+++ trunk/Source/WTF/wtf/Int128.h       2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -0,0 +1,297 @@
</span><ins>+// Taken from LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See Source/WTF/LICENSE-LLVM.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Portable 128-bit unsigned integer arithmetic for use in impoverished
+// C++ implementations lacking __uint128_t.
+
+// Based on:
+// https://github.com/llvm/llvm-project/blob/d480f968/flang/include/flang/Common/uint128.h
+
+#pragma once
+
+// Define AVOID_NATIVE_INT128_T to force the use of Int128Impl below instead of
+// the C++ compiler's native 128-bit unsigned integer type, if it has one.
+#ifndef AVOID_NATIVE_INT128_T
+#define AVOID_NATIVE_INT128_T 0
+#endif
+
+#include <cstdint>
+#include <type_traits>
+#include <wtf/LeadingZeroBitCount.h>
+
+namespace WTF {
+
+template <bool IS_SIGNED = false> class Int128Impl {
+public:
+    constexpr Int128Impl() { }
+    // This means of definition provides some portability for
+    // "size_t" operands.
+    constexpr Int128Impl(unsigned n) : low_ {n} { }
+    constexpr Int128Impl(unsigned long n) : low_ {n} { }
+    constexpr Int128Impl(unsigned long long n) : low_ {n} { }
+    constexpr Int128Impl(int n)
+        : low_ {static_cast<std::uint64_t>(n)}
+        , high_ {-static_cast<std::uint64_t>(n < 0)}
+    { }
+    constexpr Int128Impl(long n)
+        : low_ {static_cast<std::uint64_t>(n)}
+        , high_ {-static_cast<std::uint64_t>(n < 0)}
+    { }
+    constexpr Int128Impl(long long n)
+        : low_ {static_cast<std::uint64_t>(n)}
+        , high_ {-static_cast<std::uint64_t>(n < 0)}
+    { }
+    constexpr Int128Impl(const Int128Impl &) = default;
+    constexpr Int128Impl(Int128Impl &&) = default;
+    constexpr Int128Impl &operator=(const Int128Impl &) = default;
+    constexpr Int128Impl &operator=(Int128Impl &&) = default;
+
+    constexpr Int128Impl operator+() const { return *this; }
+    constexpr Int128Impl operator~() const { return {~high_, ~low_}; }
+    constexpr Int128Impl operator-() const { return ~*this + 1; }
+    constexpr bool operator!() const { return !low_ && !high_; }
+    constexpr explicit operator bool() const { return low_ || high_; }
+    constexpr explicit operator std::uint64_t() const { return low_; }
+    constexpr explicit operator std::int64_t() const { return low_; }
+    constexpr explicit operator int() const { return static_cast<int>(low_); }
+
+    constexpr std::uint64_t high() const { return high_; }
+    constexpr std::uint64_t low() const { return low_; }
+
+    constexpr Int128Impl operator++(/*prefix*/)
+    {
+        *this += 1;
+        return *this;
+    }
+    constexpr Int128Impl operator++(int /*postfix*/)
+    {
+        Int128Impl result {*this};
+        *this += 1;
+        return result;
+    }
+    constexpr Int128Impl operator--(/*prefix*/)
+    {
+        *this -= 1;
+        return *this;
+    }
+    constexpr Int128Impl operator--(int /*postfix*/)
+    {
+        Int128Impl result {*this};
+        *this -= 1;
+        return result;
+    }
+
+    constexpr Int128Impl operator&(Int128Impl that) const
+    {
+        return {high_ & that.high_, low_ & that.low_};
+    }
+    constexpr Int128Impl operator | (Int128Impl that) const
+    {
+        return {high_ | that.high_, low_ | that.low_};
+    }
+    constexpr Int128Impl operator^(Int128Impl that) const
+    {
+        return {high_ ^ that.high_, low_ ^ that.low_};
+    }
+
+    constexpr Int128Impl operator<<(Int128Impl that) const
+    {
+        if (that >= 128)
+            return { };
+        if (!that)
+            return *this;
+        std::uint64_t n {that.low_};
+        if (n >= 64)
+            return {low_ << (n - 64), 0};
+        return {(high_ << n) | (low_ >> (64 - n)), low_ << n};
+    }
+    constexpr Int128Impl operator>>(Int128Impl that) const
+    {
+        if (that >= 128)
+            return { };
+        if (!that)
+            return *this;
+        std::uint64_t n {that.low_};
+        if (n >= 64)
+            return {0, high_ >> (n - 64)};
+        return {high_ >> n, (high_ << (64 - n)) | (low_ >> n)};
+    }
+
+    constexpr Int128Impl operator+(Int128Impl that) const
+    {
+        std::uint64_t lower {(low_ & ~topBit) + (that.low_ & ~topBit)};
+        bool carry {((lower >> 63) + (low_ >> 63) + (that.low_ >> 63)) > 1};
+        return {high_ + that.high_ + carry, low_ + that.low_};
+    }
+    constexpr Int128Impl operator-(Int128Impl that) const { return *this + -that; }
+
+    constexpr Int128Impl operator*(Int128Impl that) const
+    {
+        std::uint64_t mask32 {0xffffffff};
+        if (!high_ && !that.high_) {
+            std::uint64_t x0 {low_ & mask32}, x1 {low_ >> 32};
+            std::uint64_t y0 {that.low_ & mask32}, y1 {that.low_ >> 32};
+            Int128Impl x0y0 {x0 * y0}, x0y1 {x0 * y1};
+            Int128Impl x1y0 {x1 * y0}, x1y1 {x1 * y1};
+            return x0y0 + ((x0y1 + x1y0) << 32) + (x1y1 << 64);
+        }
+
+        std::uint64_t x0 {low_ & mask32}, x1 {low_ >> 32}, x2 {high_ & mask32},
+            x3 {high_ >> 32};
+        std::uint64_t y0 {that.low_ & mask32}, y1 {that.low_ >> 32},
+            y2 {that.high_ & mask32}, y3 {that.high_ >> 32};
+        Int128Impl x0y0 {x0 * y0}, x0y1 {x0 * y1}, x0y2 {x0 * y2}, x0y3 {x0 * y3};
+        Int128Impl x1y0 {x1 * y0}, x1y1 {x1 * y1}, x1y2 {x1 * y2};
+        Int128Impl x2y0 {x2 * y0}, x2y1 {x2 * y1};
+        Int128Impl x3y0 {x3 * y0};
+        return x0y0 + ((x0y1 + x1y0) << 32) + ((x0y2 + x1y1 + x2y0) << 64) +
+            ((x0y3 + x1y2 + x2y1 + x3y0) << 96);
+    }
+
+    constexpr Int128Impl operator/(Int128Impl that) const
+    {
+        int j {leadingZeroes()};
+        Int128Impl bits {*this};
+        bits <<= j;
+        Int128Impl numerator { };
+        Int128Impl quotient { };
+        for (; j < 128; ++j) {
+            numerator <<= 1;
+            if (bits.high_ & topBit)
+                numerator.low_ |= 1;
+            bits <<= 1;
+            quotient <<= 1;
+            if (numerator >= that) {
+                ++quotient;
+                numerator -= that;
+            }
+        }
+        return quotient;
+    }
+
+    constexpr Int128Impl operator%(Int128Impl that) const
+    {
+        int j {leadingZeroes()};
+        Int128Impl bits {*this};
+        bits <<= j;
+        Int128Impl remainder { };
+        for (; j < 128; ++j) {
+            remainder <<= 1;
+            if (bits.high_ & topBit)
+                remainder.low_ |= 1;
+            bits <<= 1;
+            if (remainder >= that)
+                remainder -= that;
+        }
+        return remainder;
+    }
+
+    constexpr bool operator<(Int128Impl that) const
+    {
+        if (IS_SIGNED && (high_ ^ that.high_) & topBit)
+            return !!(high_ & topBit);
+
+        return high_ < that.high_ || (high_ == that.high_ && low_ < that.low_);
+    }
+    constexpr bool operator<=(Int128Impl that) const { return !(*this > that); }
+    constexpr bool operator==(Int128Impl that) const
+    {
+        return low_ == that.low_ && high_ == that.high_;
+    }
+    constexpr bool operator!=(Int128Impl that) const { return !(*this == that); }
+    constexpr bool operator>=(Int128Impl that) const { return that <= *this; }
+    constexpr bool operator>(Int128Impl that) const { return that < *this; }
+
+    constexpr Int128Impl &operator&=(const Int128Impl &that)
+    {
+        *this = *this & that;
+        return *this;
+    }
+    constexpr Int128Impl &operator|=(const Int128Impl &that)
+    {
+        *this = *this | that;
+        return *this;
+    }
+    constexpr Int128Impl &operator^=(const Int128Impl &that)
+    {
+        *this = *this ^ that;
+        return *this;
+    }
+    constexpr Int128Impl &operator<<=(const Int128Impl &that)
+    {
+        *this = *this << that;
+        return *this;
+    }
+    constexpr Int128Impl &operator>>=(const Int128Impl &that)
+    {
+        *this = *this >> that;
+        return *this;
+    }
+    constexpr Int128Impl &operator+=(const Int128Impl &that)
+    {
+        *this = *this + that;
+        return *this;
+    }
+    constexpr Int128Impl &operator-=(const Int128Impl &that)
+    {
+        *this = *this - that;
+        return *this;
+    }
+    constexpr Int128Impl &operator*=(const Int128Impl &that)
+    {
+        *this = *this * that;
+        return *this;
+    }
+    constexpr Int128Impl &operator/=(const Int128Impl &that)
+    {
+        *this = *this / that;
+        return *this;
+    }
+    constexpr Int128Impl &operator%=(const Int128Impl &that)
+    {
+        *this = *this % that;
+        return *this;
+    }
+
+private:
+    constexpr Int128Impl(std::uint64_t hi, std::uint64_t lo) : low_ {lo}, high_ {hi} { }
+    constexpr int leadingZeroes() const
+    {
+        if (!high_)
+            return 64 + leadingZeroBitCount(low_);
+        return leadingZeroBitCount(high_);
+    }
+    static constexpr std::uint64_t topBit {std::uint64_t {1} << 63};
+    std::uint64_t low_ {0}, high_ {0};
+};
+
+#if !AVOID_NATIVE_INT128_T && HAVE(INT128_T)
+using UInt128 = __uint128_t;
+using Int128 = __int128_t;
+#else
+using UInt128 = Int128Impl<false>;
+using Int128 = Int128Impl<true>;
+#endif
+
+template <int BITS> struct HostUnsignedIntTypeHelper {
+    using type = std::conditional_t<(BITS <= 8), std::uint8_t,
+        std::conditional_t<(BITS <= 16), std::uint16_t,
+        std::conditional_t<(BITS <= 32), std::uint32_t,
+        std::conditional_t<(BITS <= 64), std::uint64_t, UInt128>>>>;
+};
+template <int BITS> struct HostSignedIntTypeHelper {
+    using type = std::conditional_t<(BITS <= 8), std::int8_t,
+        std::conditional_t<(BITS <= 16), std::int16_t,
+        std::conditional_t<(BITS <= 32), std::int32_t,
+        std::conditional_t<(BITS <= 64), std::int64_t, Int128>>>>;
+};
+template <int BITS>
+using HostUnsignedIntType = typename HostUnsignedIntTypeHelper<BITS>::type;
+template <int BITS>
+using HostSignedIntType = typename HostSignedIntTypeHelper<BITS>::type;
+
+} // namespace WTF
+
+using WTF::Int128;
+using WTF::UInt128;
</ins></span></pre></div>
<a id="trunkSourceWTFwtfLeadingZeroBitCountcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/LeadingZeroBitCount.cpp (0 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/LeadingZeroBitCount.cpp                             (rev 0)
+++ trunk/Source/WTF/wtf/LeadingZeroBitCount.cpp        2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+// Taken from LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See Source/WTF/LICENSE-LLVM.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Based on:
+// https://github.com/llvm/llvm-project/blob/d480f968/flang/include/flang/Common/leading-zero-bit-count.h
+
+#include "config.h"
+#include "LeadingZeroBitCount.h"
+
+#include <cinttypes>
+
+namespace WTF {
+
+const 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};
+
+const 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};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWTFwtfLeadingZeroBitCounth"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/LeadingZeroBitCount.h (0 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/LeadingZeroBitCount.h                               (rev 0)
+++ trunk/Source/WTF/wtf/LeadingZeroBitCount.h  2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+// Taken from LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See Source/WTF/LICENSE-LLVM.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Based on:
+// https://github.com/llvm/llvm-project/blob/d480f968/flang/include/flang/Common/leading-zero-bit-count.h
+
+#pragma once
+
+// A fast and portable function that implements Fortran's LEADZ intrinsic
+// function, which counts the number of leading (most significant) zero bit
+// positions in an integer value. (If the most significant bit is set, the
+// leading zero count is zero; if no bit is set, the leading zero count is the
+// word size in bits; otherwise, it's the largest left shift count that
+// doesn't reduce the number of bits in the word that are set.)
+
+#include <cinttypes>
+
+namespace WTF {
+
+// The following magic constant is a binary deBruijn sequence.
+// It has the remarkable property that if one extends it
+// (virtually) on the right with 5 more zero bits, then all
+// of the 64 contiguous framed blocks of six bits in the
+// extended 69-bit sequence are distinct. Consequently,
+// if one shifts it left by any shift count [0..63] with
+// truncation and extracts the uppermost six bit field
+// of the shifted value, each shift count maps to a distinct
+// field value. That means that we can map those 64 field
+// values back to the shift counts that produce them,
+// and (the point) this means that we can shift this value
+// by an unknown bit count in [0..63] and then figure out
+// what that count must have been.
+//    0   7   e   d   d   5   e   5   9   a   4   e   2   8   c   2
+// 0000011111101101110101011110010110011010010011100010100011000010
+static constexpr std::uint64_t deBruijn {0x07edd5e59a4e28c2};
+extern WTF_EXPORT_PRIVATE const std::uint8_t mapping[64];
+
+extern WTF_EXPORT_PRIVATE const std::uint8_t eightBitLeadingZeroBitCount[256];
+
+inline constexpr int leadingZeroBitCount(std::uint64_t x)
+{
+    if (!x)
+        return 64;
+
+    x |= x >> 1;
+    x |= x >> 2;
+    x |= x >> 4;
+    x |= x >> 8;
+    x |= x >> 16;
+    x |= x >> 32;
+    // All of the bits below the uppermost set bit are now also set.
+    x -= x >> 1; // All of the bits below the uppermost are now clear.
+    // x now has exactly one bit set, so it is a power of two, so
+    // multiplication by x is equivalent to a left shift by its
+    // base-2 logarithm. We calculate that unknown base-2 logarithm
+    // by shifting the deBruijn sequence and mapping the framed value.
+    int base2Log {mapping[(x * deBruijn) >> 58]};
+    return 63 - base2Log; // convert to leading zero count
+}
+
+inline constexpr int leadingZeroBitCount(std::uint32_t x)
+{
+    return leadingZeroBitCount(static_cast<std::uint64_t>(x)) - 32;
+}
+
+inline constexpr int leadingZeroBitCount(std::uint16_t x)
+{
+    return leadingZeroBitCount(static_cast<std::uint64_t>(x)) - 48;
+}
+
+inline int leadingZeroBitCount(std::uint8_t x)
+{
+    return eightBitLeadingZeroBitCount[x];
+}
+
+template <typename A> inline constexpr int bitsNeededFor(A x)
+{
+    return 8 * sizeof x - leadingZeroBitCount(x);
+}
+
+} // namespace WTF
+
+using WTF::leadingZeroBitCount;
+using WTF::bitsNeededFor;
</ins></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (282827 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-09-21 17:49:11 UTC (rev 282827)
+++ trunk/Tools/ChangeLog       2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2021-09-21  Philip Chimento  <pchimento@igalia.com>
+
+        Add LLVM/FLang's int128_t implementation to WTF
+        https://bugs.webkit.org/show_bug.cgi?id=230437
+
+        Added tests for Int128 and LeadingZeroBitCount copied from LLVM's tests,
+        reformatted according to WebKit style.
+
+        Reviewed by Yusuke Suzuki.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/Int128.cpp: Added.
+        (TestWebKitAPI::TestUnary):
+        (TestWebKitAPI::TestBinary):
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::ToNative):
+        (TestWebKitAPI::FromNative):
+        (TestWebKitAPI::TestVsNative):
+        * TestWebKitAPI/Tests/WTF/LeadingZeroBitCount.cpp: Added.
+        (countWithTwoShiftedBits):
+        (TEST):
+
</ins><span class="cx"> 2021-09-21  Phillip Mates  <pmates@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Fix JSC test runner warnings and errors on linux
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPICMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (282827 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/CMakeLists.txt 2021-09-21 17:49:11 UTC (rev 282827)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt    2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -49,10 +49,12 @@
</span><span class="cx">     Tests/WTF/Hasher.cpp
</span><span class="cx">     Tests/WTF/HexNumber.cpp
</span><span class="cx">     Tests/WTF/IndexSparseSet.cpp
</span><ins>+    Tests/WTF/Int128.cpp
</ins><span class="cx">     Tests/WTF/IntegerToStringConversion.cpp
</span><span class="cx">     Tests/WTF/IteratorRange.cpp
</span><span class="cx">     Tests/WTF/JSONValue.cpp
</span><span class="cx">     Tests/WTF/LEBDecoder.cpp
</span><ins>+    Tests/WTF/LeadingZeroBitCount.cpp
</ins><span class="cx">     Tests/WTF/LifecycleLogger.cpp
</span><span class="cx">     Tests/WTF/LineEnding.cpp
</span><span class="cx">     Tests/WTF/ListHashSet.cpp
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (282827 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2021-09-21 17:49:11 UTC (rev 282827)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -1291,6 +1291,8 @@
</span><span class="cx">          F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */; };
</span><span class="cx">          F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */; };
</span><span class="cx">          F6B7BE9717469B96008A3445 /* associate-form-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6B7BE9617469B7E008A3445 /* associate-form-controls.html */; };
</span><ins>+               F6D67D3726F90206006E0349 /* LeadingZeroBitCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6D67D3526F90205006E0349 /* LeadingZeroBitCount.cpp */; };
+               F6D67D3826F90206006E0349 /* Int128.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6D67D3626F90206006E0349 /* Int128.cpp */; };
</ins><span class="cx">           F6F49C6B15545CA70007F39D /* DOMWindowExtensionNoCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */; };
</span><span class="cx">          F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6FDDDD514241C48004F1729 /* push-state.html */; };
</span><span class="cx">          FE2BCDC72470FDA300DEC33B /* StdLibExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE2BCDC62470FC7000DEC33B /* StdLibExtras.cpp */; };
</span><span class="lines">@@ -3164,6 +3166,8 @@
</span><span class="cx">          F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DidAssociateFormControls_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="cx">          F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DidAssociateFormControls.cpp; sourceTree = "<group>"; };
</span><span class="cx">          F6B7BE9617469B7E008A3445 /* associate-form-controls.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "associate-form-controls.html"; sourceTree = "<group>"; };
</span><ins>+               F6D67D3526F90205006E0349 /* LeadingZeroBitCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LeadingZeroBitCount.cpp; sourceTree = "<group>"; };
+               F6D67D3626F90206006E0349 /* Int128.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int128.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="cx">          F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache.cpp; sourceTree = "<group>"; };
</span><span class="cx">          F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -4498,9 +4502,11 @@
</span><span class="cx">                          26B2DFF815BDE599004F691D /* HashSet.cpp */,
</span><span class="cx">                          7C8BFF7023C0106700C009B3 /* HexNumber.cpp */,
</span><span class="cx">                          33976D8224DC479B00812304 /* IndexSparseSet.cpp */,
</span><ins>+                               F6D67D3626F90206006E0349 /* Int128.cpp */,
</ins><span class="cx">                           266FAFD215E5775200F61D5B /* IntegerToStringConversion.cpp */,
</span><span class="cx">                          7CEB62A92236086C0069CBB0 /* IteratorRange.cpp */,
</span><span class="cx">                          7A0509401FB9F04400B33FB8 /* JSONValue.cpp */,
</span><ins>+                               F6D67D3526F90205006E0349 /* LeadingZeroBitCount.cpp */,
</ins><span class="cx">                           531C1D8D1DF8EF72006E979F /* LEBDecoder.cpp */,
</span><span class="cx">                          A57D54F71F3397B400A97AA7 /* LifecycleLogger.cpp */,
</span><span class="cx">                          A57D54F81F3397B400A97AA7 /* LifecycleLogger.h */,
</span><span class="lines">@@ -5296,10 +5302,12 @@
</span><span class="cx">                          7C83DED41D0A590C00FEBCF3 /* HashSet.cpp in Sources */,
</span><span class="cx">                          7C8BFF7123C0107A00C009B3 /* HexNumber.cpp in Sources */,
</span><span class="cx">                          33976D8324DC479B00812304 /* IndexSparseSet.cpp in Sources */,
</span><ins>+                               F6D67D3826F90206006E0349 /* Int128.cpp in Sources */,
</ins><span class="cx">                           7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */,
</span><span class="cx">                          53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */,
</span><span class="cx">                          7CEB62AB223609DE0069CBB0 /* IteratorRange.cpp in Sources */,
</span><span class="cx">                          7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */,
</span><ins>+                               F6D67D3726F90206006E0349 /* LeadingZeroBitCount.cpp in Sources */,
</ins><span class="cx">                           531C1D8E1DF8EF72006E979F /* LEBDecoder.cpp in Sources */,
</span><span class="cx">                          A57D54F91F3397B400A97AA7 /* LifecycleLogger.cpp in Sources */,
</span><span class="cx">                          93E2C5551FD3204100E1DF6A /* LineEnding.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFInt128cpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/Int128.cpp (0 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/Int128.cpp                           (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Int128.cpp      2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -0,0 +1,145 @@
</span><ins>+// Taken from LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See Source/WTF/LICENSE-LLVM.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Based on:
+// https://github.com/llvm/llvm-project/blob/d480f968/flang/unittests/Evaluate/uint128.cpp
+
+#define AVOID_NATIVE_INT128_T 1
+
+#include "config.h"
+#include <wtf/Int128.h>
+
+#include <cinttypes>
+
+namespace TestWebKitAPI {
+
+static void TestUnary(std::uint64_t x)
+{
+    UInt128 n {x};
+    EXPECT_EQ(x, static_cast<std::uint64_t>(n));
+    EXPECT_EQ(~x, static_cast<std::uint64_t>(~n));
+    EXPECT_EQ(-x, static_cast<std::uint64_t>(-n));
+    EXPECT_EQ(!x, static_cast<std::uint64_t>(!n));
+    EXPECT_TRUE(n == n);
+    EXPECT_TRUE(n + n == n * static_cast<UInt128>(2));
+    EXPECT_TRUE(n - n == static_cast<UInt128>(0));
+    EXPECT_TRUE(n + n == n << static_cast<UInt128>(1));
+    EXPECT_TRUE(n + n == n << static_cast<UInt128>(1));
+    EXPECT_TRUE((n + n) - n == n);
+    EXPECT_TRUE(((n + n) >> static_cast<UInt128>(1)) == n);
+    if (x) {
+        EXPECT_TRUE(static_cast<UInt128>(0) / n == static_cast<UInt128>(0));
+        EXPECT_TRUE(static_cast<UInt128>(n - 1) / n == static_cast<UInt128>(0));
+        EXPECT_TRUE(static_cast<UInt128>(n) / n == static_cast<UInt128>(1));
+        EXPECT_TRUE(static_cast<UInt128>(n + n - 1) / n == static_cast<UInt128>(1));
+        EXPECT_TRUE(static_cast<UInt128>(n + n) / n == static_cast<UInt128>(2));
+    }
+}
+
+static void TestBinary(std::uint64_t x, std::uint64_t y)
+{
+    UInt128 m {x}, n {y};
+    EXPECT_EQ(x, static_cast<std::uint64_t>(m));
+    EXPECT_EQ(y, static_cast<std::uint64_t>(n));
+    EXPECT_EQ(x & y, static_cast<std::uint64_t>(m & n));
+    EXPECT_EQ(x | y, static_cast<std::uint64_t>(m | n));
+    EXPECT_EQ(x ^ y, static_cast<std::uint64_t>(m ^ n));
+    EXPECT_EQ(x + y, static_cast<std::uint64_t>(m + n));
+    EXPECT_EQ(x - y, static_cast<std::uint64_t>(m - n));
+    EXPECT_EQ(x * y, static_cast<std::uint64_t>(m * n));
+    if (n)
+        EXPECT_EQ(x / y, static_cast<std::uint64_t>(m / n));
+}
+
+TEST(WTF_Int128, Basic)
+{
+    for (std::uint64_t j {0}; j < 64; ++j) {
+        TestUnary(j);
+        TestUnary(~j);
+        TestUnary(std::uint64_t(1) << j);
+        for (std::uint64_t k {0}; k < 64; ++k)
+            TestBinary(j, k);
+    }
+}
+
+#if HAVE(INT128_T)
+static __uint128_t ToNative(UInt128 n)
+{
+    return static_cast<__uint128_t>(static_cast<std::uint64_t>(n >> 64)) << 64 |
+        static_cast<std::uint64_t>(n);
+}
+
+static UInt128 FromNative(__uint128_t n)
+{
+    return UInt128 {static_cast<std::uint64_t>(n >> 64)} << 64 |
+        UInt128 {static_cast<std::uint64_t>(n)};
+}
+
+static void TestVsNative(__uint128_t x, __uint128_t y)
+{
+    UInt128 m {FromNative(x)}, n {FromNative(y)};
+    EXPECT_TRUE(ToNative(m) == x);
+    EXPECT_TRUE(ToNative(n) == y);
+    EXPECT_TRUE(ToNative(~m) == ~x);
+    EXPECT_TRUE(ToNative(-m) == -x);
+    EXPECT_TRUE(ToNative(!m) == !x);
+    EXPECT_TRUE(ToNative(m < n) == (x < y));
+    EXPECT_TRUE(ToNative(m <= n) == (x <= y));
+    EXPECT_TRUE(ToNative(m == n) == (x == y));
+    EXPECT_TRUE(ToNative(m != n) == (x != y));
+    EXPECT_TRUE(ToNative(m >= n) == (x >= y));
+    EXPECT_TRUE(ToNative(m > n) == (x > y));
+    EXPECT_TRUE(ToNative(m & n) == (x & y));
+    EXPECT_TRUE(ToNative(m | n) == (x | y));
+    EXPECT_TRUE(ToNative(m ^ n) == (x ^ y));
+    if (y < 128) {
+        EXPECT_TRUE(ToNative(m << n) == (x << y));
+        EXPECT_TRUE(ToNative(m >> n) == (x >> y));
+    }
+    EXPECT_TRUE(ToNative(m + n) == (x + y));
+    EXPECT_TRUE(ToNative(m - n) == (x - y));
+    EXPECT_TRUE(ToNative(m * n) == (x * y));
+    if (y > 0) {
+        EXPECT_TRUE(ToNative(m / n) == (x / y));
+        EXPECT_TRUE(ToNative(m % n) == (x % y));
+        EXPECT_TRUE(ToNative(m - n * (m / n)) == (x % y));
+    }
+}
+
+TEST(WTF_Int128, VsNative)
+{
+    GTEST_LOG_(INFO) << "Environment has native __uint128_t";
+
+    for (int j {0}; j < 128; ++j) {
+        for (int k {0}; k < 128; ++k) {
+            __uint128_t m {1}, n {1};
+            m <<= j;
+            n <<= k;
+            TestVsNative(m, n);
+            TestVsNative(~m, n);
+            TestVsNative(m, ~n);
+            TestVsNative(~m, ~n);
+            TestVsNative(m ^ n, n);
+            TestVsNative(m, m ^ n);
+            TestVsNative(m ^ ~n, n);
+            TestVsNative(m, ~m ^ n);
+            TestVsNative(m ^ ~n, m ^ n);
+            TestVsNative(m ^ n, ~m ^ n);
+            TestVsNative(m ^ ~n, ~m ^ n);
+            TestBinary(m, 10000000000000000); // important case for decimal conversion
+            TestBinary(~m, 10000000000000000);
+        }
+    }
+}
+
+#else // !HAVE(INT128_T)
+
+TEST(WTF_Int128, VsNative)
+{
+    GTEST_LOG_(INFO) << "Environment lacks native __uint128_t";
+}
+
+#endif // !HAVE(INT128_T)
+
+} // namespace TestWebKitAPI
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFLeadingZeroBitCountcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/LeadingZeroBitCount.cpp (0 => 282828)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/LeadingZeroBitCount.cpp                              (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/LeadingZeroBitCount.cpp 2021-09-21 18:04:20 UTC (rev 282828)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+// Taken from LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See Source/WTF/LICENSE-LLVM.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Based on:
+// https://github.com/llvm/llvm-project/blob/d480f968/flang/unittests/Evaluate/leading-zero-bit-count.cpp
+
+#include "config.h"
+#include <wtf/LeadingZeroBitCount.h>
+
+#include <limits>
+
+template <typename IntType>
+static bool countWithTwoShiftedBits(int j, int k)
+{
+    IntType x = (IntType {1} << j) | (IntType {1} << k);
+    return leadingZeroBitCount(x) == std::numeric_limits<IntType>::digits - 1 - j;
+}
+
+TEST(WTF_LeadingZeroBitCount, Basic)
+{
+    EXPECT_EQ(leadingZeroBitCount(std::uint64_t {0}), 64);
+    for (int j {0}; j < 64; ++j) {
+        for (int k {0}; k < j; ++k)
+            EXPECT_PRED2(countWithTwoShiftedBits<std::uint64_t>, j, k);
+    }
+
+    EXPECT_EQ(leadingZeroBitCount(std::uint32_t {0}), 32);
+    for (int j {0}; j < 32; ++j) {
+        for (int k {0}; k < j; ++k)
+            EXPECT_PRED2(countWithTwoShiftedBits<std::uint32_t>, j, k);
+    }
+
+    EXPECT_EQ(leadingZeroBitCount(std::uint16_t {0}), 16);
+    for (int j {0}; j < 16; ++j) {
+        for (int k {0}; k < j; ++k)
+            EXPECT_PRED2(countWithTwoShiftedBits<std::uint16_t>, j, k);
+    }
+
+    EXPECT_EQ(leadingZeroBitCount(std::uint8_t {0}), 8);
+    for (int j {0}; j < 8; ++j) {
+        for (int k {0}; k < j; ++k)
+            EXPECT_PRED2(countWithTwoShiftedBits<std::uint8_t>, j, k);
+    }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>