[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] code suggestion
From: |
Jörg F . Wittenberger |
Subject: |
Re: [Chicken-hackers] code suggestion |
Date: |
Mon, 1 Feb 2016 19:53:41 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux armv7l; rv:38.0) Gecko/20100101 Icedove/38.4.0 |
Sure I had to forget the attachment.
In the meantime I tried the last thought and it worked. Even less code now:
void C_ccall C_make_vector(C_word c, C_word *av)
{
C_word av2[2], *v=av+1;
av2[0] = av[1];
*v = C_VECTOR_TYPE | (c-2);
av2[1] = (C_word) v;
C_do_apply(2, av2);
}
(define vector (##core#primitive "C_make_vector"))
This time with test attached.
Cheers
/Jörg
Am 01.02.2016 um 19:27 schrieb Jörg F. Wittenberger:
> Hi all,
>
> given argvector's in place I wonder if we should change some things.
>
> If this code would be correct. If so, it could simplify library.scm
> (list->vector and vector->list would become one-liners, vector a
> ##core#primitive) and save runtime.
....
> -------
>
> we could rewrite dynamic-wind like this:
>
> --- library.scm ---
> (define (dynamic-wind before thunk after)
> (before)
> (set! ##sys#dynamic-winds (cons (cons before after) ##sys#dynamic-winds))
> (let ((results (##sys#call-with-values thunk vector)))
> (set! ##sys#dynamic-winds (##sys#slot ##sys#dynamic-winds 1))
> (after)
> (apply-vector/unsafe ##sys#values results)))
> -------
>
> The attached test does some simple benchmarking on this. Depending on
> optimization (-O2 or more) results on my desktop machine indicate
> anything between 10-30% gain.
>
> Having written this, I wonder: maybe we could simply put the tag into
> av[1] in the C_make_vector above and return av+1. Should have the same
> effect and save all the memcpy.
>
> Cheers
>
> /Jörg
multivalencapts.scm
Description: Text Data