[Webkit-unassigned] [Bug 26014] Declaring an unused variable outside an empty loop speeds up the loop

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Mar 12 13:40:00 PDT 2012


Gavin Barraclough <barraclough at apple.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME
                 CC|                            |barraclough at apple.com

--- Comment #2 from Gavin Barraclough <barraclough at apple.com>  2012-03-12 13:40:00 PST ---
time /WebKitBuild/Release/jsc  -e "function e() { var a = 0; for (var i = 0; i < 99999999; ++i) { } } e();"

real    0m0.300s
user    0m0.293s
sys    0m0.006s

time /WebKitBuild/Release/jsc  -e "function e() { for (var i = 0; i < 99999999; ++i) { } } e();"

real    0m0.301s
user    0m0.293s
sys    0m0.006s

This doesn't reproduce for me.  As Mark says, this kind of effect can be caused by cache effects as stack layout changes, and is not necessarily unexpected.  We don't currently optimize to remove unused variables; we could do so, but every additional optimization pass comes at a runtime cost in JIT, and we would only want to do so if there is a demonstrable value in doing so (real programs tend not to declare lots of unused variables, and as your numbers show, it's not necessarily a performance regression even if they do!)

I don't think there is anything we need to fix here.

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list