Closed
Bug 565729
Opened 15 years ago
Closed 9 years ago
Implement a specialized array iterator
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 505818
People
(Reporter: gal, Assigned: gal)
Details
a = [...]
for (i in a) ... a[i] ...
stringifies i, only to apply GETELEM on a using i, which turns it into an integer index again (in particular for dense arrays).
Creating the native iterator is also mildly inefficient since we make a vector of numbers, basically: iterator = [id(0), id(1), id(2) ...].
Instead, I will do the following:
- add a native ArrayIteratorClass object
- it has no malloced part, just a cursor and a length
- FOR* pull from the iterator the next id (cursor) until length, so on the trace this is a simple integer load
- the integer is stringified
- GETELEM sees the stringify call, and will peek through it, use the number directly, generating very efficient code
As a follow-up bug, we will eliminate the stringification. Nick is already working on guarded calls that can be eliminated (Nick, can you link the bug?) when they are dead. Thats needed to get read of the i2s call (its dead, but the guard keeps it alive for now).
Assignee | ||
Updated•15 years ago
|
OS: Mac OS X → All
Hardware: x86 → All
Assignee | ||
Updated•15 years ago
|
Assignee: general → gal
![]() |
||
Comment 1•15 years ago
|
||
(In reply to comment #0)
>
> As a follow-up bug, we will eliminate the stringification. Nick is already
> working on guarded calls that can be eliminated (Nick, can you link the bug?)
> when they are dead.
Conditionally-live guards are in bug 560994.
Is eliminate-the-stringification in bug 560995?
Updated•9 years ago
|
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•