Bug 109000

Summary: DFG::ByteCodeParser should do surgical constant folding to reduce load on the optimization fixpoint
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, ggaren, mark.lam, mhahnenberg, msaboff, oliver, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 108414    
Attachments:
Description Flags
the patch oliver: review+

Description Filip Pizlo 2013-02-05 19:31:00 PST
Currently our source parser's ASTBuilder does some surgical constant folding, but it doesn't cover some cases.  It is particularly incapable of doing constant folding for cases where we do some minimal loop peeling in the bytecode generator - since it won't "see" those constants prior to the peeling.  Example:

for (var i = 0; i < 4; ++i)
    things;

This will get peeled just a bit by the bytecode generator, so that the "i < 4" is duplicated both at the top of the loop and the bottom.  This means that we have a constant comparison: "0 < 4", which the bytecode generator emits without any further thought.

The DFG optimization fixpoint of course folds this and simplifies the CFG accordingly, but this incurs a compile-time cost.  The purpose of this bug is to do some surgical constant folding in the DFG's bytecode parser, so that such constructs reduce load on the CFG simplifier and the optimization fixpoint.  The goal is not to cover all cases, since the DFG CFA and CFG simplifier have a really powerful sparse conditional constant propagation that we can always fall back on.  Instead the goal is to cover enough cases that for common small functions we don't have to perform such transformations, thereby reducing compile times.
Comment 1 Filip Pizlo 2013-02-05 19:36:03 PST
Created attachment 186745 [details]
the patch
Comment 2 Filip Pizlo 2013-02-07 12:24:39 PST
Landed in http://trac.webkit.org/changeset/142162