Updates:
Summary: Crankshaft should generate special case code for Array.prototype.append where the receiver is not live after the call
        Labels: Priority-Low Type-FeatureRequest

Comment #1 on issue 2117 by erik.corry: Crankshaft should generate special case code for Array.prototype.append where the receiver is not live after the call
http://code.google.com/p/v8/issues/detail?id=2117

Push will modify an existing array, while append creates a new one. This bug report is thus complaining about the difference between an algorithm that is O(n2) and one that is O(n log n) amortized. In order for the VM to convert one algorithm to another it would have to recognize that the old version of 'one' does not escape and is dead when you do

one = one.concat(record.one)

this is a pretty difficult optimization to do in JS, since any access to an array element can at any time trigger a getter which can cause the old 'one' array to be captured. But with the correct map checks I think it could be done in Crankshaft.

Given that the bug report contains a reasonable workaround I don't think this should have high priority. Note that apply has limits on the array length (long arrays will trigger a stack overflow) so you may have to use a loop if the input arrays have arbitrary length.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to