Changeset 200645 in webkit


Ignore:
Timestamp:
May 10, 2016, 2:35:32 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] FTL can produce GetByVal nodes without proper bounds checking
https://bugs.webkit.org/show_bug.cgi?id=157502
rdar://problem/26027027

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-05-10
Reviewed by Filip Pizlo.

It was possible for FTL to generates GetByVal on arbitrary offsets
without any bounds checking.

The bug is caused by the order of optimization phases:
-First, the Integer Range Optimization proves that a CheckInBounds

test can never fail.
This proof is based on control flow or preceeding instructions
inside a loop.

-The Loop Invariant Code Motion phase finds that the GetByVal does not

depend on anything in the loop and hoist it out of the loop.

-> As a result, the conditions that were necessary to eliminate

the CheckInBounds are no longer met before the GetByVal.

This patch just moves the Integer Range Optimization phase after
Loop Invariant Code Motion to make sure no code is moved after
its integer ranges bounds proofs have been used.

  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::compileInThreadImpl):

  • tests/stress/bounds-check-not-eliminated-by-licm.js: Added.

(testInLoopTests):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r200634 r200645  
     12016-05-10  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] FTL can produce GetByVal nodes without proper bounds checking
     4        https://bugs.webkit.org/show_bug.cgi?id=157502
     5        rdar://problem/26027027
     6
     7        Reviewed by Filip Pizlo.
     8
     9        It was possible for FTL to generates GetByVal on arbitrary offsets
     10        without any bounds checking.
     11
     12        The bug is caused by the order of optimization phases:
     13        -First, the Integer Range Optimization proves that a CheckInBounds
     14         test can never fail.
     15         This proof is based on control flow or preceeding instructions
     16         inside a loop.
     17        -The Loop Invariant Code Motion phase finds that the GetByVal does not
     18         depend on anything in the loop and hoist it out of the loop.
     19        -> As a result, the conditions that were necessary to eliminate
     20           the CheckInBounds are no longer met before the GetByVal.
     21
     22        This patch just moves the Integer Range Optimization phase after
     23        Loop Invariant Code Motion to make sure no code is moved after
     24        its integer ranges bounds proofs have been used.
     25
     26        * dfg/DFGPlan.cpp:
     27        (JSC::DFG::Plan::compileInThreadImpl):
     28        * tests/stress/bounds-check-not-eliminated-by-licm.js: Added.
     29        (testInLoopTests):
     30
    1312016-05-10  Joseph Pecoraro  <pecoraro@apple.com>
    232
  • trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp

    r200531 r200645  
    400400        performGlobalCSE(dfg);
    401401        performLivenessAnalysis(dfg);
    402         performIntegerRangeOptimization(dfg);
    403         performLivenessAnalysis(dfg);
    404402        performCFA(dfg);
    405403        performConstantFolding(dfg);
     
    425423        // then we'd need to do some simple SSA fix-up.
    426424        performLICM(dfg);
     425
     426        // FIXME: Currently: IntegerRangeOptimization *must* be run after LICM.
     427        //
     428        // IntegerRangeOptimization makes changes on nodes based on preceding blocks
     429        // and nodes. LICM moves nodes which can invalidates assumptions used
     430        // by IntegerRangeOptimization.
     431        //
     432        // Ideally, the dependencies should be explicit. See https://bugs.webkit.org/show_bug.cgi?id=157534.
     433        performLivenessAnalysis(dfg);
     434        performIntegerRangeOptimization(dfg);
    427435       
    428436        performCleanUp(dfg);
Note: See TracChangeset for help on using the changeset viewer.