[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] FFI and stack use
From: |
John Cowan |
Subject: |
Re: [Chicken-users] FFI and stack use |
Date: |
Tue, 21 Jul 2009 23:37:06 -0400 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Thomas Bushnell BSG scripsit:
> So this raises a question. Scheme functions get compiled into code that
> carefully checks stack bounds before allocating, and bangs off to the
> garbage collector if necessary.
>
> The FFI doesn't do this. So I'm assuming that in fact, I have the full
> C stack available, and can just go ahead and use it. When I invoke the
> return continuation, it will go just fine, and presumably if I've
> exceeded the Chicken stack size, it will just trigger a gc and proceed
> happily as before.
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.
--
John Cowan address@hidden http://ccil.org/~cowan
Heckler: "Go on, Al, tell 'em all you know. It won't take long."
Al Smith: "I'll tell 'em all we *both* know. It won't take any longer."