2009/4/24  <[email protected]>:
>
> http://codereview.appspot.com/8703/diff/1/17
> File
> src/com/google/caja/parser/quasiliteral/opt/ArrayIndexOptimization.java
> (right):
>
> http://codereview.appspot.com/8703/diff/1/17#newcode63
> Line 63: *   use-before-initialization.
> On 2009/04/25 01:49:14, MikeSamuel wrote:
>>
>> On 2008/12/20 00:22:30, MarkM wrote:
>> > If this is a dynamic check, I suspect we'd lose all the gains this
>
> CL is
>>
>> trying
>> > to gain. If it's a static check, it can't be accurate. If you agree,
>
> please
>>
>> > remove this line.
>
>> I disagree.  We can do conservative and fairly accurate use-before
>> initialization checks, and simply decline to optimize when we can't.
>> In the common idiom:
>>   for (var i = 0; i < array.length; ++i) {
>>     f(arr[i]);
>>   }
>> we can definitively say that the i in f(arr[i]) is not read before i
>
> has been
>>
>> initialized.  If f aliases eval, and arr[0] contains 'i = undefined',
>
> then we
>>
>> can't guarantee that i is a number, but we can say definitively that
>
> it has been
>>
>> initialized.
>
> What about if it says "delete i;" ?

delete of local variables returns false without any side effects.
(function () { var i = 0; return [delete i, i]; })() returns [false, 0]



>
> http://codereview.appspot.com/8703
>

Reply via email to