Cyrus Harmon <ch-sbcl@...> writes:
> Dear sbcl-devel,
> I have a couple, probably naive, questions regarding pseudo-alloc and
> align-csp on ppc:
> 1. What does the extra flag to pseudo-alloc do? I see that we
> subtract 4 from it and store it in flag-tn, but I'm not sure what the
> purpose of the extra argument is.
Pseudo-atomic (which is probably what I think you mean) is often used
around allocation: to protect sensitive bits of the system (the GC,
for instance) from seeing incomplete objects. The extra argument, I
think, is used to save one instruction in the sequence
turn pseudo-atomic on (set bit 2 of alloc-tn)
allocate some memory (manipulate alloc-tn)
turn pseudo-atomic off (unset bit 2 of alloc-tn)
and test for pending interrupts
but I should confess that at this time of the morning I'm no longer
sure how it all works. In any case, I don't think we're terribly
wedded to any particular implementation of pseudo-atomic.
> 2. In align-csp, it appears that we're attempting to align a block of
> memory allocated on the stack to some multiple, but it's not clear to
> me what the alignment is. It looks like we check the alignment by
> anding with lowtag-mask (which is 7, but I don't understand why
> lowtag-mask should have anything to do with stack alignment) and if
> it's not zero we add n-word-bytes, or 4 in this case, to csp-tn. I'm
> sure there's some method to this madness, but I don't see it.
the natural alignment for objects when we have three tag bits is eight
bytes, because given that the three lowest bits aren't pointer bits,
the addresses cannot express any granularity smaller than 2^3 = 8.
So we need to align the stack pointer to this granularity, which it so
happens can be punned (or at least expressed) as anding with the
lowtag mask. If the stack isn't aligned to a doubleword, it will be
aligned to a word, so to align it to a double word we add the number
of bytes in a word to the stack pointer; additionally, and this is
different from the heap, we need to be sure that if we've extended the
stack we store a safe value (zero) to the word that we've extended it
I hope that makes a bit more sense.