Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 13a1f2916933547024ee020d94031096a41eb7cb
      
https://github.com/WebKit/WebKit/commit/13a1f2916933547024ee020d94031096a41eb7cb
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-10-03 (Sat, 03 Oct 2026)

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

  Log Message:
  -----------
  [JSC] `JSBigInt::divideSchoolbook` should not allocate for Burnikel-Ziegler 
leaves
https://bugs.webkit.org/show_bug.cgi?id=326174

Reviewed by Yusuke Suzuki.

divideSchoolbook copies the dividend into a Vector<Digit, 16> that is one
digit longer than the dividend. Burnikel-Ziegler division, added in
322437@main, calls it once per leaf of its recursion. A leaf has a divisor of
8 to 15 digits and a dividend of up to twice that, so the copy has 17 to 31
digits and is allocated on the heap every time: 32 times for 512 / 256 digits,
4 times for 71 / 24.

Give the Vector an inline capacity of 32, which covers every leaf. A
schoolbook division with a dividend of 16 to 31 digits, which does not go
through Burnikel-Ziegler division, no longer allocates either.

x % y in nanoseconds, median of 15 runs on x86-64:

digits                Before         After

71 / 24               2467.1        2414.7    (-2.1%)
200 / 24              9199.8        8972.7    (-2.5%)
2000 / 24           111833.7      108852.7    (-2.7%)
2000 / 40           148339.3      144653.4    (-2.5%)
8000 / 24           471837.7      460385.6    (-2.4%)
512 / 256            70299.3       69657.7    (-0.9%)
4096 / 2048        1842756.3     1836428.6    (-0.3%)
24 / 12                406.8         385.4    (-5.3%)
30 / 8                 494.2         475.9    (-3.7%)
12 / 6                 152.5         152.9    (+0.3%)

* Source/JavaScriptCore/runtime/JSBigInt.cpp:
(JSC::JSBigInt::divideSchoolbook):
(JSC::JSBigInt::burnikelZieglerBasecase):

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



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

Reply via email to