On Dec 4, 2012, at 1:28 PM, Brendan Eich wrote:

> Mark S. Miller wrote:
>> ...
> 
>>> * It deoptimizes, e.g. a strict-mode function must be optimized to copy
>>> actual parameter values into arguments if it could use the arguments object.
>> 
>> This one I just don't buy at all. In a strict function f, f.arguments
>> is poisoned. f's arguments would only need to be reified if f
>> statically mentions "arguments" or if f has a statically apparent use
>> of the direct eval operator. For all other cases, no arguments object
>> need be created, and therefore no copying is needed.
> 
> Right, that's what I tried to say by "could use the arguments object". 
> Nothing to do with hated f.arguments.
> 
> So every strict function that uses arguments pays a copying price on entry in 
> a naive implementation. Pushing the copies out till just before there might 
> be an aliasing store is an optimization that could be done in a more 
> sophisticated implementation, but engines don't do it currently and feel 
> little pressure to do so. Chicken and egg.

The timing of copying is only an issue if the function actually assigns to a 
formal parameter.  Such assignments should be pretty easy to (conservatively) 
statically check for.

So, you should be able to avoid copying on entry if there is no direct eval and 
no assignments to formal parameters.  A pretty common case.

If there is a reference to arguments (and no assignment to formals), you should 
only need to copy if a Put is actually made to the arguments object.  This is 
also rare and potentially optimizable in various ways.

So, I guess I agree with Mark on this one.  Implementations could do a pretty 
good job of optimizing strict mode function parameters if they thought it was 
necessary.  It probably needs to be driven by benchmarks.

Allen


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to