guile-devel
[Top][All Lists]
Advanced

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

Re: GC + Java finalization


From: Maxime Devos
Subject: Re: GC + Java finalization
Date: Fri, 19 Nov 2021 14:21:08 +0000
User-agent: Evolution 3.38.3-1

Jonas Hahnfeld schreef op vr 19-11-2021 om 14:35 [+0100]:
> Am Freitag, dem 19.11.2021 um 13:15 +0000 schrieb Maxime Devos:
> > Jonas Hahnfeld schreef op do 15-07-2021 om 20:44 [+0200]:
> > > +  SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT,
> > > "smobs");
> > > +
> > >    int i;
> > >    mark_call_count = 0;
> > >    for (i = 0; i < SMOBS_COUNT; i++)
> > > -    make_x ();
> > > +    smobs[i] = make_x ();
> > >    scm_gc ();
> > 
> > smobs doesn't need to be protected for the whole function call,
> > until after the scm_gc() should be sufficient I think. 
> 
> That's what the patch does, no? For reference, the whole function
> (after this patch) looks like:
> 
> SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs");
> 
> int i;
> mark_call_count = 0;
> for (i = 0; i < SMOBS_COUNT; i++)
>   smobs[i] = make_x (); 
> scm_gc (); 
> if (mark_call_count < SMOBS_COUNT)
>   {   
>     fprintf (stderr, "FAIL: SMOB mark function called for each
> SMOB\n");
>     exit (EXIT_FAILURE);
>   }   
> scm_remember_upto_here_1 (smobs);
> 
> While we could move the remember_upto_here immediately after the call
> to scm_gc(), the current version ensures that the memory is still
> available when the error is checked.

The error checking code (I'm thinking of the if (mark_call_count ...)
fprintf(...) exit(...) here) isn't using 'smobs', so the error checking
code doesn't need the memory to be available AFAIK.

Greetings,
Maxime Devos.




reply via email to

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