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

Changeset 246071 in webkit


Ignore:
Timestamp:
Jun 4, 2019, 10:56:59 AM (7 years ago)
Author:
Tadeu Zagallo
Message:

Argument elimination should check for negative indices in GetByVal
https://bugs.webkit.org/show_bug.cgi?id=198302
<rdar://problem/51188095>

Reviewed by Filip Pizlo.

JSTests:

  • stress/eliminate-arguments-negative-rest-access.js: Added.

(inlinee):
(opt):

Source/JavaScriptCore:

In DFG::ArgumentEliminationPhase, the index is treated as unsigned, but there's no check
for overflow in the addition. In compileGetMyArgumentByVal, there's a check for overflow,
but the index is treated as signed, resulting in an index lower than numberOfArgumentsToSkip.

  • dfg/DFGArgumentsEliminationPhase.cpp:
  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r246041 r246071  
     12019-06-04  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        Argument elimination should check for negative indices in GetByVal
     4        https://bugs.webkit.org/show_bug.cgi?id=198302
     5        <rdar://problem/51188095>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        * stress/eliminate-arguments-negative-rest-access.js: Added.
     10        (inlinee):
     11        (opt):
     12
    1132019-06-03  Caio Lima  <ticaiolima@gmail.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r246060 r246071  
     12019-06-04  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        Argument elimination should check for negative indices in GetByVal
     4        https://bugs.webkit.org/show_bug.cgi?id=198302
     5        <rdar://problem/51188095>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        In DFG::ArgumentEliminationPhase, the index is treated as unsigned, but there's no check
     10        for overflow in the addition. In compileGetMyArgumentByVal, there's a check for overflow,
     11        but the index is treated as signed, resulting in an index lower than numberOfArgumentsToSkip.
     12
     13        * dfg/DFGArgumentsEliminationPhase.cpp:
     14        * ftl/FTLLowerDFGToB3.cpp:
     15        (JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal):
     16
    1172019-06-04  Tadeu Zagallo  <tzagallo@apple.com>
    218
  • trunk/Source/JavaScriptCore/dfg/DFGArgumentsEliminationPhase.cpp

    r243232 r246071  
    763763                        index += numberOfArgumentsToSkip;
    764764                       
    765                         bool safeToGetStack;
     765                        bool safeToGetStack = index >= numberOfArgumentsToSkip;
    766766                        if (inlineCallFrame)
    767                             safeToGetStack = index < inlineCallFrame->argumentCountIncludingThis - 1;
     767                            safeToGetStack &= index < inlineCallFrame->argumentCountIncludingThis - 1;
    768768                        else {
    769                             safeToGetStack =
     769                            safeToGetStack &=
    770770                                index < static_cast<unsigned>(codeBlock()->numParameters()) - 1;
    771771                        }
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r246041 r246071  
    44624462        LValue numberOfArgs = m_out.sub(numberOfArgsIncludingThis, m_out.int32One);
    44634463        LValue indexToCheck = originalIndex;
     4464        LValue numberOfArgumentsToSkip = m_out.int32Zero;
    44644465        if (m_node->numberOfArgumentsToSkip()) {
    4465             CheckValue* check = m_out.speculateAdd(indexToCheck, m_out.constInt32(m_node->numberOfArgumentsToSkip()));
     4466            numberOfArgumentsToSkip = m_out.constInt32(m_node->numberOfArgumentsToSkip());
     4467            CheckValue* check = m_out.speculateAdd(indexToCheck, numberOfArgumentsToSkip);
    44664468            blessSpeculation(check, Overflow, noValue(), nullptr, m_origin);
    44674469            indexToCheck = check;
    44684470        }
    44694471
    4470         LValue isOutOfBounds = m_out.aboveOrEqual(indexToCheck, numberOfArgs);
     4472        LValue isOutOfBounds = m_out.bitOr(m_out.aboveOrEqual(indexToCheck, numberOfArgs), m_out.below(indexToCheck, numberOfArgumentsToSkip));
    44714473        LBasicBlock continuation = nullptr;
    44724474        LBasicBlock lastNext = nullptr;
Note: See TracChangeset for help on using the changeset viewer.