Changeset 260522 in webkit


Ignore:
Timestamp:
Apr 22, 2020 11:12:34 AM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] JSBigInt inc operation does not produce right HeapBigInt zero
https://bugs.webkit.org/show_bug.cgi?id=210860

Reviewed by Mark Lam.

JSTests:

  • stress/bigint-zero-canonicalized.js: Added.

(shouldBe):

Source/JavaScriptCore:

JSBigInt::inc can produce signed HeapBigInt zero, which is not meeting the invariant of JSBigInt.
This patch fixes it by checking zero status before setting setSign(true).

  • runtime/JSBigInt.cpp:

(JSC::JSBigInt::inc):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::dumpInContextAssumingStructure const):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r260517 r260522  
     12020-04-22  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] JSBigInt inc operation does not produce right HeapBigInt zero
     4        https://bugs.webkit.org/show_bug.cgi?id=210860
     5
     6        Reviewed by Mark Lam.
     7
     8        * stress/bigint-zero-canonicalized.js: Added.
     9        (shouldBe):
     10
    1112020-04-22  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r260520 r260522  
     12020-04-22  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] JSBigInt inc operation does not produce right HeapBigInt zero
     4        https://bugs.webkit.org/show_bug.cgi?id=210860
     5
     6        Reviewed by Mark Lam.
     7
     8        JSBigInt::inc can produce signed HeapBigInt zero, which is not meeting the invariant of JSBigInt.
     9        This patch fixes it by checking zero status before setting `setSign(true)`.
     10
     11        * runtime/JSBigInt.cpp:
     12        (JSC::JSBigInt::inc):
     13        * runtime/JSCJSValue.cpp:
     14        (JSC::JSValue::dumpInContextAssumingStructure const):
     15
    1162020-04-22  Devin Rousso  <drousso@apple.com>
    217
  • trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp

    r260358 r260522  
    447447        return absoluteAddOne(globalObject, x, SignOption::Unsigned);
    448448    JSBigInt* result = absoluteSubOne(globalObject, x, x->length());
     449    if (result->isZero())
     450        return result;
    449451    result->setSign(true);
    450452    return result;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r260331 r260522  
    313313            out.print("Structure: ", inContext(*jsCast<Structure*>(asCell()), context));
    314314        else if (isHeapBigInt())
    315             out.print("BigInt[heap-allocated]: addr=", RawPointer(asCell()));
     315            out.print("BigInt[heap-allocated]: addr=", RawPointer(asCell()), ", length=", jsCast<JSBigInt*>(asCell())->length(), ", sign=", jsCast<JSBigInt*>(asCell())->sign());
    316316        else if (structure->classInfo()->isSubClassOf(JSObject::info())) {
    317317            out.print("Object: ", RawPointer(asCell()));
Note: See TracChangeset for help on using the changeset viewer.