[webkit-reviews] review requested: [Bug 19408] Constant folding in parser : [Attachment 22302] Fold only *, +, <<, >>, ~ operators

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 16 03:49:12 PDT 2008

Gabor Loki <loki at inf.u-szeged.hu> has asked  for review:
Bug 19408: Constant folding in parser

Attachment 22302: Fold only *, +, <<, >>, ~ operators

------- Additional Comments from Gabor Loki <loki at inf.u-szeged.hu>
I have tried several implementations of constant folding, but I couldn't
achieve such as big speed-up as the first time. So I tried to determine why the
first patch was so good.

The first thing what I have noticed if an unused member (or non-member)
function left in the code it will easily change the result (in any direction).
For example: after I have placed an isString() function into ExpressionNode and
StringNode (and do nothing else). The result was about 1% slow down. In spite
of this, after an isBoolean() function was placed into ExpressionNode and
BooleanNode an 0.5% speed up was measured.

I guess the reason of this that the pointers of the objects and the target of
jumps have been changed in the generated object files.

The second thing: it is pointless to implement all constant folding cases in
the parser. In general the JavaScripts (or any other language) contain very
few constant folding opportunity at parser-time. In the most frequent cases the
following operators were used: *, +, <<, >>, ~. SunSpider contains very few
const. folding opportunity (only for * and + operators)

So the attached patch does constant folding for *, + (only for numbers), <<,
>>, ~ operators. I have also added a new test case for LayoutTests/fast/js
which covers all constant folding cases.

I have not measured any significant performance speed up in SunSpider, but the
end result is not worse than reference:
  ** TOTAL **:	FROM: 3201.4ms +/- 0.7%   TO: 3193.4ms +/- 0.7%

The patch is against rev. 35197.

More information about the webkit-reviews mailing list