[Ecls-list] Arrays to C and C to Arrays....

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sun Nov 15 08:53:53 UTC 2009


On Sun, Nov 15, 2009 at 12:17 AM, Waldek Hebisch
<hebisch at math.uni.wroc.pl> wrote:
> 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).

Volatile variables can NOT be eliminated by the compiler, because
"volatile" means it could be changed by an external source (other
thread)

> And I need
> a separate variable for each Lisp obect that I want to reference.

Again, non-eliminated automatic variables may be used for that purpose.

> 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.

I would say so.

> 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.

My experience is that in many cases arguments may be passed in
registers _and_ in the stack. Specially vararg functions. Also, if the
value of the argument is used more than once and it was in a register,
it is also saved on the stack. Finally, if you declare them volatile I
think they also get allocated in the stack.

Juanjo

--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list