This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Help/suggestions for conservative gc problems


Greg Harvey wrote:
>   SCM test_val, *velts;  
>   register int i;
>   test_val = scm_make_vector(SCM_MAKINUM(1000), SCM_EOL);
>   velts = SCM_VELTS(test_val);
> /*do some stuff with velts*/
> 
> which becomes:
> 
> 	pushl $10612
> 	pushl $4002
> 	call scm_make_vector
> 	movl 4(%eax),%esi
>         /* Explanation here: scheme cells are 
>          { SCM car, cdr}; for a vector, the cdr is a pointer
>                           to mallocated memory*/
> 
> This is a pretty big problem, since the garbage collector uses the
> stack to get at roots for the collection; if a collection occurs
> during the code following the above snippet, the vector will be freed,
> since there's no pointer to the actual scheme object. 

I don't see a problem.  If you use the stack and registers to get roots,
then eax points to the vector and velts to the elements.  Once eax is
clobbered, you still have velts as long as you're using it.  If velts as
a root isn't enough for correct behaviour, that's a bug in Guile's
garbage collector.

Forcing the call-saved registers onto the stack before the stack scan is
easy enough in the GC routine using setjmp.

-- Jamie

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]