Comment #2 on issue 4223 by [email protected]: Incorrect operation
order in Array.prototype.reverse
https://code.google.com/p/v8/issues/detail?id=4223#c2
The following revision refers to this bug:
https://chromium.googlesource.com/v8/v8.git/+/f76dfee9dfa56a0a3ca3c95d17c244cd5cc6753d
commit f76dfee9dfa56a0a3ca3c95d17c244cd5cc6753d
Author: littledan <[email protected]>
Date: Thu Jul 16 23:12:06 2015
Array.prototype.reverse should call [[HasProperty]] on elements before
[[Get]]
This is a change from ES5 to ES6: When reversing an array, first it is
checked
whether the element exists, before the element is looked up. The order in
ES6
is
[[HasElement]] lower
[[Get]] lower (if present)
[[HasElement]] upper
[[Get]] upper (if present)
In ES5, on the other hand, the order was
[[Get]] lower
[[Get]] upper
[[HasElement]] lower
[[HasElement]] upper
To mitigate the performance impact, this patch implements a new, third copy
of reversing arrays if %_HasPackedElements. This allows us to skip all
membership tests, and a quick and dirty benchmark shows that the new version
is faster:
Over 4 runs, the slowest for the new version:
d8> var start = Date.now(); for (var i = 0; i < 100000000; i++) [1, 2, 3,
4, 5].reverse(); Date.now() - start
4658
Over 3 runs, the fastest for the old version:
d8> var start = Date.now(); for (var i = 0; i < 100000000; i++) [1, 2, 3,
4, 5].reverse(); Date.now() - start
5176
BUG=v8:4223
R=adamk
LOG=Y
Review URL: https://codereview.chromium.org/1238593003
Cr-Commit-Position: refs/heads/master@{#29716}
[modify]
http://crrev.com/f76dfee9dfa56a0a3ca3c95d17c244cd5cc6753d/src/array.js
[modify]
http://crrev.com/f76dfee9dfa56a0a3ca3c95d17c244cd5cc6753d/src/harmony-typedarray.js
[add]
http://crrev.com/f76dfee9dfa56a0a3ca3c95d17c244cd5cc6753d/test/mjsunit/es6/array-reverse-order.js
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" 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/d/optout.