Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c60baa450f96b48f6db64fd49c53a30611854017
https://github.com/WebKit/WebKit/commit/c60baa450f96b48f6db64fd49c53a30611854017
Author: Yusuke Suzuki <[email protected]>
Date: 2026-05-27 (Wed, 27 May 2026)
Changed paths:
A JSTests/stress/bigint-in-place-thresholds.js
M Source/JavaScriptCore/runtime/CachedTypes.cpp
M Source/JavaScriptCore/runtime/JSBigInt.cpp
M Source/JavaScriptCore/runtime/JSBigInt.h
M Source/JavaScriptCore/runtime/VM.cpp
M Source/JavaScriptCore/runtime/VM.h
Log Message:
-----------
[JSC] Use in-place JSBigInt for small-size calculation (or when only one
digit is wasteful)
https://bugs.webkit.org/show_bug.cgi?id=315628
rdar://178003514
Reviewed by Yijia Huang.
Using Vector and copying the result to JSBigInt is costly if size is
enough small. This patch attempts to use allocated JSBigInt's storage
directly.
1. Add case is at most only one digit space is wasteful, so just using
JSBigInt always makes sense in terms of tradeoff.
2. We add this optimization to cachedMod / sub only when potential
result size is small (8 or 16).
3. Also, cache 0n in VM.
* JSTests/stress/bigint-in-place-thresholds.js: Added.
(shouldBe):
(throw.new.Error.pow2):
(throw.new.Error.topDigitBit):
(throw.new.Error):
(divisorWithLength):
(neg.0n.shouldBe):
* Source/JavaScriptCore/runtime/CachedTypes.cpp:
(JSC::CachedBigInt::decode const):
* Source/JavaScriptCore/runtime/JSBigInt.cpp:
(JSC::JSBigInt::createZero):
(JSC::JSBigInt::tryCreateZero):
(JSC::JSBigInt::createFrom):
(JSC::JSBigInt::tryCreateFromImpl):
(JSC::zeroImpl):
(JSC::JSBigInt::divideImpl):
(JSC::JSBigInt::unaryMinusImpl):
(JSC::JSBigInt::remainderImpl):
(JSC::JSBigInt::absoluteAdd):
(JSC::JSBigInt::absoluteSub):
(JSC::JSBigInt::rightShiftByMaximum):
(JSC::JSBigInt::parseInt):
(JSC::JSBigInt::asIntNImpl):
(JSC::JSBigInt::asUintNImpl):
* Source/JavaScriptCore/runtime/JSBigInt.h:
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::visitAggregateImpl):
* Source/JavaScriptCore/runtime/VM.h:
Canonical link: https://commits.webkit.org/313977@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications