>
> var array = new Array(1000);  // packed backing store with capacity 1000, 
> array.length == 1000
> for (var i = 0; i < 1000; ++i) array[i] = i;  // no allocation
> array[1000] = 1000;  // array must be grown, new backing store is 
> allocated with capacity ~1500, a.length = 1001. Elements are copied from 
> old to new backing store, old backing store will be discarded by next GC.
> for (var i = 1001; i < 1500; ++i) array[i] = i;  // no further allocation 
> as we already have the backing store
> array[1600] = 1600;  // new backing store allocated, capacity about 
> 1600*1.5 = 2400
>
> // Additional fun to be had:
> array[0] = 1.5;  // the first double! New double backing store is 
> allocated, all integer elements are converted and copied over.
> array[1000000] = 1;  // array is no longer dense -> dictionary backing 
> store is allocated, all elements are copied over.
>

Very cool, thank you for the writeup! 

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to