On 24 May 2012 12:10, James M. Lawrence <llmjjmll@...> wrote:
> (define-array-dispatch vector-subseq-dispatch (array start end)
+;;; Store some saetp fields for DEFINE-ARRAY-DISPATCH since
+;;; sb!vm:*specialized-array-element-type-properties* is not always
This sounds odd. Do you mean it's not there during some stage of the build?
Otherwise the code is lovely.
> However it's not clear whether it is appropriate to do this
> optimization inside SBCL since a time/space trade-off is involved. Is
> an 86K core size increase (uncompressed) worth it? This is only for
Almost certainly, since it means less open coding in user-code:
the MAP-INTO transform can then be made conditional on eg. SPEED=3, or
> It would be nice to have something like
> (defmacro with-declared-array-type (array &body body)
> available in userland. This would make it easier to do such
> optimizations without depending upon internals. Ideally it would have
> constant lookup, although the linear search with TYPEP is quick enough
> for most purposes.
> (Out of curiosity I implemented WITH-DECLARED-ARRAY-TYPE using a
> stack-allocated vector of FLET functions, but this was slower than
> TYPECASE even for the worst-case TYPEP search.
Putting functions in the vector means you get full call overhead, and
disables local call analysis -- so it's not entirely surprising, even
if the dispatch worked fast.
> WITH-DECLARED-ARRAY-TYPE seems possible in principle, though it would
> presumably require new special operator(s) and/or magic.)
We /could/ make big typecases with array-types use binary search
on the widetag...
> Getting back to SBCL innards, considering that SUBSEQ and FILL already
> use widetag dispatch there may be another place which would benefit
> from it. If so then  will help. If not then it may be needless
I think most sequence functions would benefit from it. Aside from SUBSEQ
and FILL we're currently relying excessively on inlining to make them
fast -- fast out-of-line implementations would be better, IMO.
Unless someone gets there first, I plan on merging these over the weekend.