RESOLVED INVALID 16525
Possible to optimize out for(var x = 0; x < 500; x++) in JSC?
https://bugs.webkit.org/show_bug.cgi?id=16525
Summary Possible to optimize out for(var x = 0; x < 500; x++) in JSC?
Eric Seidel (no email)
Reported 2007-12-20 04:39:21 PST
Possible to optimize out for(var x = 0; x < 500; x++) in JSC? I wonder if it wouldn't be possible to completely optimize out the variable handling for "x" in the above statement in JavaScriptCore. Meaning, pull x completely out of JS and make it be only on c-stack. This would require two things: 1. Walk the for subtree and make sure x is never referenced. 2. Assure that "x < 500" is a statement involving only x and constants. Requirement #1 could be relaxed if we actually exposed x in the scope chain. This sort of optimization might be way overly complicated at this point. But I saw LessNode::evaluateToNumber() as 1.2% as well as LocalVarAccessNode::evaluateToNumber() as 1.6% on the sample tonight, and started to wonder.
Attachments
Eric Seidel (no email)
Comment 1 2007-12-20 04:49:28 PST
Along this same vein: our time spent in LocalVarAccessNode ::evaluateToNumber() in pushing the float value onto the stack for return. We could avoid calling evaluateToNumber() entirely if we could know that evaluateToInt32() would be sufficient. Yay x68 calling conventions!
Mark Rowe (bdash)
Comment 2 2007-12-20 07:35:16 PST
How would you account for x being referenced inside an eval?
Eric Seidel (no email)
Comment 3 2007-12-20 08:25:10 PST
Any use of "eval" would count as a reference to "x" and would break this optimization. This would obviously require our planned eval tainting.
Maciej Stachowiak
Comment 4 2007-12-23 21:11:29 PST
Note that a reference to x could be anywhere inside the same function or in nested function declarations or expressions.
Eric Seidel (no email)
Comment 5 2007-12-24 00:10:41 PST
Which would mean we'd need to find the enclosing ScopeNode and walk the entire subtree. ick.
Cameron Zwarich (cpst)
Comment 6 2008-09-02 23:49:38 PDT
This is no longer relevant after SquirrelFish.
Note You need to log in before you can comment on or make changes to this bug.