Add inline version of newArray#
It'd would be nice to have an inline version of newArray#
so that allocation of small arrays is cheaper (e.g. the heap check could be paired up with other heap checks.)
I see two possible designs:
- Add a branch to
newArray#
that checks the requested size and either allocates inline or out-of-line. - Add a new primop e.g.
newSmallArray#
that always allocates inline.
I would lean towards (2). While (1) is equal to (2) in the case when the size is statically known (assuming that GHC can discover that fact through enough inlining at the Cmm level), there are cases where the programmer knows that the size is small, without knowing the exact size. This happens e.g. when you use arrays to represent small variable-length tuples (e.g. in the unordered-containers
package.)
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | johan.tibell@gmail.com |
Operating system | |
Architecture |