Bug 16595

Summary: Add evaluateToVoid() and LoopNode subclasses which ignore completion type
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: ggaren, mjs
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.4   

Description Eric Seidel (no email) 2007-12-24 00:58:48 PST
Add evaluateToVoid() and LoopNode subclasses which ignore completion type

Loop nodes are spending time updating a completion value to be returned (and generally ignored).  For example, most for loops never have their returned completion type examined.  I've never seen code like this:

function bar() {
  for(var x = 0; x < 10; x++)
       x;
}

alert(bar());

Only in cases like that do we need to care what the loop completion value was.

In the common case, we can use a reverse execution walk through the node tree to keep track of when completion values are ignored:

var x = 2; // the fact that this updates the last completion value is completely ignored
var y = 4;

and use evaluateToVoid() calls instead.  We could even swap out entire BlockNodes which call void executeToVoid(exec) instead.
Comment 1 Eric Seidel (no email) 2007-12-24 01:01:55 PST
actually, the only way to access a completion value is from a function w/o a return value or an eval statement so you don't even need to walk, you just look at the last statement.  in the global context you can always evaluate to void
Comment 2 Cameron Zwarich (cpst) 2008-09-03 02:41:38 PDT
This is now irrelevant after SquirrelFish.