Repository navigation
[4.x] Give BigInt shifts and asIntN/asUintN their spec results for any count (backport of #4443) - #4467
Open
michaelthyregod wants to merge 1 commit into
Conversation
…y count (backport of sebastienros#4443) (cherry picked from commit f6035e5)
Contributor
Author
|
The If it's useful, I can send #3140 as a |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #4443. Fixes #4432 on 4.x.
On 4.17.0, a script can make the host receive a CLR exception from BigInt arithmetic (the first two also re-checked on
4.xat dfccb4d):1n >> (2n ** 32n)throwsOverflowException("Value was either too large or too small for an Int32"),BigInt.asUintN(2 ** 31 - 1, 5n)throwsOverflowException, andBigInt.asUintN(2 ** 31 - 2, 5n)throwsOutOfMemoryException, where the spec has a result (0n,5n,5n). The change is #4443's:BigIntLeftShiftimplements BigInt::leftShift/signedRightShift with the sameJsBigInt.MaxBitLengthcap**uses,asIntN/asUintNreturn a value that already fits and otherwise mask instead ofBigInteger.Pow, andEvaluateBitwiseOperationtakes theEngineand reads.Realmonly to throw.The library files applied cleanly. Left out:
Jint.Tests/SpecAnchors.txt, which4.xdoes not have. The tests inBigIntTestsare converted from NUnit to xUnit; as on main,FixedWidthBigIntOperationsRejectUnsupportedBitCountsbecomesFixedWidthBigIntOperationsReturnAValueThatFitsUnchanged, sinceasIntN(2 ** 31, 1n)now returns1ninstead ofRangeError: Invalid bit count. TheGetBitLengthpolyfill coversnet462and bothnetstandardtargets.Observable changes on
4.x, the same as on main: those cases return the spec result instead of throwing; a negativeasUintNwider than 1,000,000 bits and a left shift whose result would exceed 1,000,000 bits throwRangeError: Maximum BigInt size exceeded(V8 allows 2^30 bits), consistent with**.Verified locally: Jint.Tests 8054 passed / 4 skipped (net10.0) and 7969 / 4 (net472); Jint.Tests.PublicInterface 1967 passed / 9 skipped (net10.0) and 1959 / 9 (net472); Jint.Tests.Test262 102513 passed / 171 skipped; 0 failures.
🤖 Generated with Claude Code