From: Godmar Back (gback@cs.utah.edu)
Date: Thu Dec 17 1998 - 12:29:34 EST
>
> > Besides, the interpreter loop uses alloca and it works.
> Realy ? with witch implementation of alloca() ?
>
> If I'm not wrong, GNU alloca() use the stack pointer
> and keep a global link list of all allocated block.
> If sp < sp-when-allocated, it frees the block.
> (change 'less than' by 'greater than' with the other
> stack direction)
>
> The problem is:
> all the stack of Thread-A < all the stack of Thread-B
>
> So if alloca() is called in Thread-B, next alloca() called
> in Thread-A free all block allocated by Thread-B because
> sp < sp-when-allocated.
>
> [When I write sp, it's the stack frame aka ebp for i386]
>
You must be talking about a different alloca.
The one I have in mind is the one that simply moves the
stackpointer down, and voila:
ENTRY(alloca)
popl %edx /* pop return addr */
popl %eax /* pop amount to allocate */
movl %esp,%ecx
addl $3,%eax /* round up to next word */
andl $0xfffffffc,%eax
subl %eax,%esp
movl %esp,%eax /* base of newly allocated space */
pushl 8(%ecx) /* copy possible saved registers */
pushl 4(%ecx)
pushl 0(%ecx)
pushl %eax /* dummy to pop at callsite */
jmp %edx /* "return" */
If GNU alloca cannot handle switching stack frames, I'd say we must
avoid it.
- Godmar
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:20 EDT