⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 246332 in webkit


Ignore:
Timestamp:
Jun 11, 2019, 2:06:45 PM (7 years ago)
Author:
Tadeu Zagallo
Message:

AI BitURShift's result should not be unsigned
https://bugs.webkit.org/show_bug.cgi?id=198689
<rdar://problem/51550063>

Reviewed by Saam Barati.

JSTests:

  • stress/urshift-int32-overflow.js: Added.

(foo.):
(foo):

Source/JavaScriptCore:

Treating BitURShift's result as unsigned in the abstract interpreter incorrectly overflows it.
This breaks the DFG and FTL, since they assume that BitURShift's result is an int32 value, but
get a double constant from AI. Since the result will be converted to unsigned by UInt32ToNumber,
all we have to do is store the result as a signed int32.

  • dfg/DFGAbstractInterpreterInlines.h:
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r246321 r246332  
     12019-06-10  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        AI BitURShift's result should not be unsigned
     4        https://bugs.webkit.org/show_bug.cgi?id=198689
     5        <rdar://problem/51550063>
     6
     7        Reviewed by Saam Barati.
     8
     9        * stress/urshift-int32-overflow.js: Added.
     10        (foo.):
     11        (foo):
     12
    1132019-06-11  Guillaume Emont  <guijemont@igalia.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r246328 r246332  
     12019-06-10  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        AI BitURShift's result should not be unsigned
     4        https://bugs.webkit.org/show_bug.cgi?id=198689
     5        <rdar://problem/51550063>
     6
     7        Reviewed by Saam Barati.
     8
     9        Treating BitURShift's result as unsigned in the abstract interpreter incorrectly overflows it.
     10        This breaks the DFG and FTL, since they assume that BitURShift's result is an int32 value, but
     11        get a double constant from AI. Since the result will be converted to unsigned by UInt32ToNumber,
     12        all we have to do is store the result as a signed int32.
     13
     14        * dfg/DFGAbstractInterpreterInlines.h:
     15
    1162019-06-11  Michael Catanzaro  <mcatanzaro@igalia.com>
    217
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r246210 r246332  
    500500                break;
    501501            case BitRShift:
    502                 setConstant(node, JSValue(a >> static_cast<uint32_t>(b)));
     502                setConstant(node, JSValue(a >> (static_cast<uint32_t>(b) & 0x1f)));
    503503                break;
    504504            case BitLShift:
    505                 setConstant(node, JSValue(a << static_cast<uint32_t>(b)));
     505                setConstant(node, JSValue(a << (static_cast<uint32_t>(b) & 0x1f)));
    506506                break;
    507507            case BitURShift:
    508                 setConstant(node, JSValue(static_cast<uint32_t>(a) >> static_cast<uint32_t>(b)));
     508                setConstant(node, JSValue(static_cast<int32_t>(static_cast<uint32_t>(a) >> (static_cast<uint32_t>(b) & 0x1f))));
    509509                break;
    510510            default:
Note: See TracChangeset for help on using the changeset viewer.