Closed
Bug 497795
Opened 16 years ago
Closed 15 years ago
Introduce a fast byte array type
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bzbarsky, Unassigned)
References
Details
For canvas imagedata, we could really use a fast byte array type. It should have the following properties:
1) All access to it is traced. Index access is Very Fast.
2) The values stored are uint8.
3) Set can do clamp+round semantics as required for imagedata (if we feel like
we want an alternate mode that throws, that's fine too).
4) The length needs to be optionally readonly (needed for canvas).
5) If length is readonly, sets outside the length must be normal JS property
sets.
6) Easy to initialize with given image data without memcpy. Ideally we could
just fill it in in the loop when we undo the premultiply from cairo in the
canvas code.
It's not clear whether it needs to be typeof Array from the point of view of JS consumers; given the current IDL in the HTML5 spec, in fact, we'd want to be able to make it be typeof CanvasPixelArray.
Comment 1•16 years ago
|
||
I think this is very doable for little effort with the array storage framework I introduced in the type specialized arrays patch with the exception of item 6. SpiderMonkey memory management mechanics are tricky and sometimes nonlocal.
Although I think that I've found all the hooks with the type specialized arrays patch, what you're proposing would have the JS array reference an externally allocated array which is a different issue, right? This complicates some of the memory management.
We can definitely add a new JS_FRIEND_API constructor to get an uninitialized array.
I'll defer to someone else on the external appearance of the class.
Depends on: 486356
![]() |
Reporter | |
Comment 2•16 years ago
|
||
What we need here is somewhat different from specialized arrays due to points 3, 4, 5 above. We never want to de-specialize byte arrays; the storage will always be bytes. We don't want to store properties outside the length as part of the array buffer (or at least we want to not despecialize the properties up to length when we do, and not change the length).
We don't need to init with an external buffer if we can get access to the internal buffer and fill it in directly.
![]() |
Reporter | |
Comment 3•15 years ago
|
||
This is so fixed, with typed arrays. ;)
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•