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)
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.
Created attachment 186745 [details]
Landed in http://trac.webkit.org/changeset/142162