chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] FFI and stack use


From: Francisco Rafael Leon
Subject: Re: [Chicken-users] FFI and stack use
Date: Wed, 22 Jul 2009 03:27:06 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

John Cowan <address@hidden> writes:

> In fact, it's unpredictable how much C stack you have, because each compiled
> Scheme function invokes its successor, leaving garbage return addresses,
> saved registers, etc. on the C stack.  So just before calling a function
> that allocates lots of C stack, call (gc #f) to force a minor GC.  
> Alternatively,
> use the -nursery switch at compile time or the -:s switch at run time to
> force a large stack.

Ah, I see now that I was totally wrong about my understanding of the
difference between the heap and the stack, about lexical scope and about
garbage collection. I read through Cheney and Baker and now I understand that:

1) There is no difference between the heap and the stack. Everything I
know about everything is just totally wrong.

2) There is no such thing as lexical scope. If I make something with
(let ...) and then get a pointer to it with (location ...), I can only
use that pointer until my recursion level triggers a GC. The closing ")"
has nothing to do with the scope of my pointer.  

3) I need to evict all my objects before using them in my FFI
calls. Otherwise, I might do something and trigger a GC call before 
pushing the FFI call onto the C/scheme/stack/heap thing. After the call, 
I can unevict them.

4) I am too lazy to do 3), and don't want the performance hit, so I will
just make a note of all this and fix it later if it ever breaks. I call
(location ...) within the argument list of the foreign-lambda, so the
chance of a GC trigger is small.

     -Rafael

   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]