[Ecls-list] Mail delivery failed: returning message to sender
Waldek Hebisch
hebisch at math.uni.wroc.pl
Sat Nov 14 23:19:02 UTC 2009
Juan Jose Garcia-Ripoll wrote:
> On Mon, Nov 9, 2009 at 12:24 AM, Waldek Hebisch
> <hebisch at math.uni.wroc.pl> wrote:
> > I wander when exactly I need to keep such references and what is
> > the best way to to this.[...] ?It seems
> > that safe way is like this:
>
> I edited the following (put the assignement first, just in case).
>
Well, I have deliberatly put it last: when it is first IIUC
'trash' has to be explicitely registered as GC root (the
C compiler is still free to eliminate x a variable). And I need
a separate variable for each Lisp obect that I want to reference.
When it is last I hope that compiler will store x in the stack
(my impression is that all current compilers will do it),
so that GC will automatically find it, without registering
'trash' as GC root. That way single trash can be used in all
routines.
> > volatile cl_object trash = x;
> >
> > .....
> >
> > ? ? ecl_uint32_t * ptr = x->array.self.b32;
> > ? ? /* Do something with ptr */
> >
> > However, is it really necessary? ?At first glance it looks that
> > ECL itself does not take special measures to protect original
> > references from elimination by C compiler.
>
> It is necessary to keep references unless the object is stored in a
> local variable that the compiler is not going to eliminate, such as a
> function argument.
Why do you think that compiler will not eliminate arguments?
AFAIK C compiler treat arguments like all other variables and
will re-use space if value of argument is no longer needed
and some other value would fit in the same place. Especially
on x86_64, since registers used for argument passing are likely
to be re-used.
--
Waldek Hebisch
hebisch at math.uni.wroc.pl
More information about the ecl-devel
mailing list