Changeset 260720 in webkit


Ignore:
Timestamp:
Apr 25, 2020 9:44:22 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Handle BigInt32 INT32_MIN shift amount
https://bugs.webkit.org/show_bug.cgi?id=211030

Reviewed by Darin Adler.

JSTests:

  • stress/bigint-int32-min-shift.js: Added.

(shouldBe):
(shouldThrow):

Source/JavaScriptCore:

Our BigInt shift-operation does not correctly handle INT32_MIN shift amount, and producing a wrong result.
This patch fixes it.

  • runtime/Operations.h:

(JSC::shift):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r260711 r260720  
     12020-04-25  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Handle BigInt32 INT32_MIN shift amount
     4        https://bugs.webkit.org/show_bug.cgi?id=211030
     5
     6        Reviewed by Darin Adler.
     7
     8        * stress/bigint-int32-min-shift.js: Added.
     9        (shouldBe):
     10        (shouldThrow):
     11
    1122020-04-25  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r260712 r260720  
     12020-04-25  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Handle BigInt32 INT32_MIN shift amount
     4        https://bugs.webkit.org/show_bug.cgi?id=211030
     5
     6        Reviewed by Darin Adler.
     7
     8        Our BigInt shift-operation does not correctly handle INT32_MIN shift amount, and producing a wrong result.
     9        This patch fixes it.
     10
     11        * runtime/Operations.h:
     12        (JSC::shift):
     13
    1142020-04-25  Darin Adler  <darin@apple.com>
    215
  • trunk/Source/JavaScriptCore/runtime/Operations.h

    r260711 r260720  
    763763        if (rightInt32 < 0) {
    764764            isLeft = !isLeft;
    765             rightInt32 = -rightInt32;
     765            if (rightInt32 == INT32_MIN)
     766                rightInt32 = INT32_MAX; // Shifts one less than requested, but makes no observable difference.
     767            else
     768                rightInt32 = -rightInt32;
    766769        }
    767770        ASSERT(rightInt32 >= 0);
Note: See TracChangeset for help on using the changeset viewer.