Bug 109000 - DFG::ByteCodeParser should do surgical constant folding to reduce load on the optimization fixpoint
Summary: DFG::ByteCodeParser should do surgical constant folding to reduce load on the...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on:
Blocks: 108414
  Show dependency treegraph
 
Reported: 2013-02-05 19:31 PST by Filip Pizlo
Modified: 2013-02-07 12:24 PST (History)
7 users (show)

See Also:


Attachments
the patch (38.67 KB, patch)
2013-02-05 19:36 PST, Filip Pizlo
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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