On Fri, Jan 17, 2003 at 12:40:49PM +0000, Nick Ing-Simmons wrote:
> The other main thing you need to keep in mind is that EXTEND (or the 
> implied one in XPUSHs) can re-allocate stack and so it may move wholesale 
> in memory. I think the XS macro ST(n) dodges this issue by working in offsets
> from _the_ global variable which holds bottom-of-stack. But dSP / PUTBACK 
> and PUSH are working with a "cached" local copy of top-of-stack pointer.

In both 5.005_03 5.9 the two definitions look like this:

#define PUSHs(s)        (*++sp = (s))
#define XPUSHs(s)       STMT_START { EXTEND(sp,1); (*++sp = (s)); } STMT_END

and EXTEND is defined to update the cached local copy sp:

#define EXTEND(p,n)     STMT_START { if (PL_stack_max - p < (n)) {      \
                            sp = stack_grow(sp,p, (int) (n));           \
                        } } STMT_END

so I think that there isn't actually a problem. But, obviously, I could be
wrong, as XS isn't really something I know that much about.

Nicholas Clark

Reply via email to