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

Changeset 284809 in webkit


Ignore:
Timestamp:
Oct 25, 2021, 12:10:03 PM (5 years ago)
Author:
Alan Coon
Message:

Cherry-pick r284585. rdar://problem/84338648

[JSC] ArithAbs should care about INT32_MIN
https://bugs.webkit.org/show_bug.cgi?id=232051
rdar://84338648

Reviewed by Michael Saboff.

ArithAbs (without overflow check) can return negative value if the input is INT32_MIN with Int32Use.

  • dfg/DFGIntegerRangeOptimizationPhase.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284585 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612-branch/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/Source/JavaScriptCore/ChangeLog

    r284808 r284809  
     12021-10-25  Null  <null@apple.com>
     2
     3        Cherry-pick r284585. rdar://problem/84338648
     4
     5    [JSC] ArithAbs should care about INT32_MIN
     6    https://bugs.webkit.org/show_bug.cgi?id=232051
     7    rdar://84338648
     8   
     9    Reviewed by Michael Saboff.
     10   
     11    ArithAbs (without overflow check) can return negative value if the input is INT32_MIN with Int32Use.
     12   
     13    * dfg/DFGIntegerRangeOptimizationPhase.cpp:
     14   
     15    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284585 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     16
     17    2021-10-20  Yusuke Suzuki  <ysuzuki@apple.com>
     18
     19            [JSC] ArithAbs should care about INT32_MIN
     20            https://bugs.webkit.org/show_bug.cgi?id=232051
     21            rdar://84338648
     22
     23            Reviewed by Michael Saboff.
     24
     25            ArithAbs (without overflow check) can return negative value if the input is INT32_MIN with Int32Use.
     26
     27            * dfg/DFGIntegerRangeOptimizationPhase.cpp:
     28
    1292021-10-25  Null  <null@apple.com>
    230
  • branches/safari-612-branch/Source/JavaScriptCore/dfg/DFGIntegerRangeOptimizationPhase.cpp

    r284807 r284809  
    14011401            if (node->child1().useKind() != Int32Use)
    14021402                break;
    1403             setRelationship(Relationship(node, m_zero, Relationship::GreaterThan, -1));
     1403
     1404            // If ArithAbs cares about overflow, then INT32_MIN input will cause OSR exit.
     1405            // Thus we can safely say `x >= 0`.
     1406            if (shouldCheckOverflow(node->arithMode())) {
     1407                setRelationship(Relationship(node, m_zero, Relationship::GreaterThan, -1));
     1408                break;
     1409            }
     1410
     1411            // If ArithAbs does not care about overflow, it can return INT32_MIN if the input is INT32_MIN.
     1412            // If minValue is not INT32_MIN, we can still say it is `x >= 0`.
     1413            int minValue = std::numeric_limits<int>::min();
     1414            auto iter = m_relationships.find(node->child1().node());
     1415            if (iter != m_relationships.end()) {
     1416                for (Relationship relationship : iter->value)
     1417                    minValue = std::max(minValue, relationship.minValueOfLeft());
     1418            }
     1419
     1420            if (minValue > std::numeric_limits<int>::min())
     1421                setRelationship(Relationship(node, m_zero, Relationship::GreaterThan, -1));
    14041422            break;
    14051423        }
Note: See TracChangeset for help on using the changeset viewer.