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

Changeset 284585 in webkit


Ignore:
Timestamp:
Oct 20, 2021, 5:00:20 PM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[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:
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r284576 r284585  
     12021-10-20  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] ArithAbs should care about INT32_MIN
     4        https://bugs.webkit.org/show_bug.cgi?id=232051
     5        rdar://84338648
     6
     7        Reviewed by Michael Saboff.
     8
     9        ArithAbs (without overflow check) can return negative value if the input is INT32_MIN with Int32Use.
     10
     11        * dfg/DFGIntegerRangeOptimizationPhase.cpp:
     12
    1132021-10-20  Justin Michaud  <justin_michaud@apple.com>
    214
  • trunk/Source/JavaScriptCore/dfg/DFGIntegerRangeOptimizationPhase.cpp

    r284573 r284585  
    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.