This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: New: SCM_DEBUG_CELL_ACCESSES
- To: Michael Livshin <mlivshin at bigfoot dot com>
- Subject: Re: New: SCM_DEBUG_CELL_ACCESSES
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Tue, 23 May 2000 15:00:49 +0200 (MEST)
- cc: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>, Guile Mailing List <guile at sourceware dot cygnus dot com>
On 23 May 2000, Michael Livshin wrote:
> > However, for the sake of generalization it may be better to make
> > span be the number of SCM/scm_bits_t words: This would even allow
> > for cells with 3 entries etc.
>
> what would 3-word (or 5-word) cells be useful for? (they are a bad
> idea from the alignment and mark-bit space consumption points of view,
> but still).
You're right. That was a stupid suggestion. Nowhere in guile could we
use a pointer to somthing that was not 8-Byte-aligned.
> > - The initial number of stack frames when guile has started seems to be
> > very large. As soon as the repl is reached, there are about 70 stack
> > frames (with the debugging evaluator, I haven't checked the other
> > one). Since the size of the stack defines the time for conservative
> > stack scanning, continuation creation and calling, this is something
> > that we also should try to reduce, if possible.
>
> I doubt that continuations go that deep, but it's worth checking...
I checked it: Continuations go _very_ deep, at least if I understand the
comments in scm_boot_guile in init.c right. After all, that is the reason
for guile stealing the main function.
> > I have instrumented the code of scm_mark_locations with counters to see
> > the relative frequencies of the different execution paths.
>
> very interesting. could you send your instrumentation so I can play
> with it? or maybe even check it in, conditionally?
It's attached. Checking it in would be overkill. It's only a quick and
dirty hack.
> generally, I don't know if it's a good idea to try to minimize the
> number of initial stack frames (it may distort the code too much), but
> I do know that the `scm_cellp' logic could be a little streamlined
> (the binary search could be replaced with two array lookups,
> basically).
I agree with you that we should not tweak the code here. It's just that I
assume that there is something going on which could need some improvement
anyway. Thus, it may well be that the way it is currently done is OK, but
a careful look might also exhibit some suboptimal code. In any case,
cleanlyness goes first.
Best regards
Dirk
/* Mark a Region Conservatively
*/
void
scm_mark_locations (SCM_STACKITEM x[], scm_sizet n)
{
unsigned long xa = 0;
unsigned long xb = 0;
unsigned long xc = 0;
unsigned long xd = 0;
unsigned long xe = 0;
unsigned long xf = 0;
unsigned long xg = 0;
unsigned long xh = 0;
unsigned long xi = 0;
unsigned long xj = 0;
unsigned long xk = 0;
unsigned long xl = 0;
unsigned long xm = 0;
unsigned long xn = 0;
unsigned long xo = 0;
unsigned long xp = 0;
unsigned long xq = 0;
register long m = n;
register int i, j;
register SCM_CELLPTR ptr;
while (0 <= --m) {
++xa;
if (SCM_CELLP (* (SCM *) &x[m]))
{
++xb;
ptr = SCM2PTR (* (SCM *) &x[m]);
i = 0;
j = scm_n_heap_segs - 1;
if ( SCM_PTR_LE (scm_heap_table[i].bounds[0], ptr)
&& SCM_PTR_GT (scm_heap_table[j].bounds[1], ptr))
{
++xc;
while (i <= j)
{
int seg_id;
++xd;
seg_id = -1;
if ( (i == j)
|| SCM_PTR_GT (scm_heap_table[i].bounds[1], ptr))
{
++xe;
seg_id = i;
}
else if (SCM_PTR_LE (scm_heap_table[j].bounds[0], ptr))
{
++xf;
seg_id = j;
}
else
{
int k;
++xg;
k = (i + j) / 2;
if (k == i)
{
++xh;
break;
}
else if (SCM_PTR_GT (scm_heap_table[k].bounds[1], ptr))
{
++xi;
j = k;
++i;
if (SCM_PTR_LE (scm_heap_table[i].bounds[0], ptr))
{
++xj;
continue;
}
else
{
++xk;
break;
}
}
else if (SCM_PTR_LE (scm_heap_table[k].bounds[0], ptr))
{
++xl;
i = k;
--j;
if (SCM_PTR_GT (scm_heap_table[j].bounds[1], ptr))
{
++xm;
continue;
}
else
{
++xn;
break;
}
}
else
{
++xo;
break;
}
}
++xp;
if (!scm_heap_table[seg_id].valid
|| scm_heap_table[seg_id].valid (ptr,
&scm_heap_table[seg_id]))
{
if (scm_heap_table[seg_id].span == 1
|| SCM_DOUBLE_CELLP (* (SCM *) &x[m]))
{
++xq;
scm_gc_mark (* (SCM *) &x[m]);
}
}
break;
}
}
}
}
fprintf (stderr, "(%i %li %li %li %li %li %li %li %li %li %li %li %li %li %li %li %li %li)\n",
scm_n_heap_segs, xa, xb, xc, xd, xe, xf, xg, xh, xi, xj, xk, xl, xm, xn, xo, xp, xq);
}