Possible to optimize out for(var x = 0; x < 500; x++) in JSC?
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.
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!
How would you account for x being referenced inside an eval?
Any use of "eval" would count as a reference to "x" and would break this optimization. This would obviously require our planned eval tainting.
Note that a reference to x could be anywhere inside the same function or in nested function declarations or expressions.
Which would mean we'd need to find the enclosing ScopeNode and walk the entire subtree. ick.
This is no longer relevant after SquirrelFish.