Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f52d0e486a0e85e1f7f6bd41c5bb2a939a9da1c3
      
https://github.com/WebKit/WebKit/commit/f52d0e486a0e85e1f7f6bd41c5bb2a939a9da1c3
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-09-09 (Wed, 09 Sep 2026)

  Changed paths:
    M Source/JavaScriptCore/runtime/JSBigInt.cpp
    M Source/JavaScriptCore/runtime/JSBigInt.h

  Log Message:
  -----------
  [JSC] Attempt to remove many bound-check assertions inside loop via 
RELEASE_ASSERT etc.
https://bugs.webkit.org/show_bug.cgi?id=323699
rdar://186956345

Reviewed by Yijia Huang.

std::span uses release-assert for bound-check. While clang is having
analysis to remove unnecessary bound-check, it is not sufficient in many
cases and it ends up emitting it in the middle of loop. We can remove
this if we emit RELEASE_ASSERT explicitly out of the loop with a
specific condition as a hint to clang to prove that this bound-check is
unnecessary. This patch systematically analyze JSBigInt compiled binary
to detect brk generated from std::span, and puts the right precondition
etc. to remove this from the loop. Sometimes, we replace int32_t to
size_t for index as int32_t is hard to prove for clang about
bound-check. Since std::span::size is size_t and it is unsigned, the
behavior is fully specified in C++ spec, and clang can relatively easily
prove the value's bound.

* Source/JavaScriptCore/runtime/JSBigInt.cpp:
(JSC::JSBigInt::karatsubaMain):
(JSC::JSBigInt::greaterThanOrEqual):
(JSC::JSBigInt::leftShift):
(JSC::JSBigInt::divideSchoolbook):
(JSC::JSBigInt::cachedModFixed):
(JSC::JSBigInt::cachedMod):
(JSC::JSBigInt::addSchoolbook):
(JSC::JSBigInt::absoluteBitwiseOp):
(JSC::JSBigInt::absoluteAddOne):
(JSC::JSBigInt::absoluteSubOne):
(JSC::JSBigInt::leftShiftByAbsolute):
(JSC::JSBigInt::rightShiftByAbsolute):
(JSC::JSBigInt::toStringGeneric):
(JSC::JSBigInt::parseInt):
(JSC::JSBigInt::asIntNImpl):
(JSC::JSBigInt::asUintNImpl):
(JSC::JSBigInt::truncateToNBits):
(JSC::JSBigInt::truncateAndSubFromPowerOfTwo):
* Source/JavaScriptCore/runtime/JSBigInt.h:

Canonical link: https://commits.webkit.org/320745@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to