%ebp vs. %esp

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Tue, 18 Sep 2001 11:42:38 -0400 (EDT)


> No, offsets from %ebp take one less from %ebp, and so the choice you used is
> probably optimal.  

Confusion growing by leaps and bounds. ;)  

But, assuming my choice was the "right" one, then I think we're in
agreement that offsets from %ebp are smaller than offsets from %esp.

> I could imagine (but this may be bogus) that some routines
> do more frontier accesses than stack accesses (initializing a big heap object)

Well, that's certainly true in initGlobals.  It's probably also true in
some tight allocating loops, where we can get all stack slots into
registers (in the sense that there are more memory references relative to
the frontier than there are memory references relative to the stack top).

> but even when that happens you probably move a pointer to the start of the
> object into some register before initializing it any way.

That's true.  Object allocation right now just looks like
	movl $0x80000002,(%esp)
	leal (4*1)(%esp),%eax
	movl %ecx,(%eax)
	movl %esi,(4*1)(%eax)
	addl $12,%esp
One other alternative that wouldn't be too hard, would be to use push's to
fill in the object:
	pushl $0x80000002
	movl %esp,%eax
	pushl %ecx
	pushl %esi
That saved two instructions, plus I would guess that pushl %ecx is smaller
than movl %ecx,(%eax).
The only difficulties are with floats and chars; in the former, we can't
do a pushl, need to do a fst and addl %esp,8; in the latter, we may need
to do an addl %esp,3 to get the alignment right for the next tuple
element.