object allocation

Stephen Weeks MLton@sourcelight.com
Fri, 10 Aug 2001 14:48:58 -0700


> Note, that there are several alternative ways to initialize  an  object.   If
> you  used  %edi instead of %esi for the frontier, then you could use the stos
> instruction, which SML/NJ uses.

Would the code you have in mind look like

movl tag, %eax
stosd
movl value0, %eax
stosd
...
movl valueN, %eax
stosd

> Note, that the really right thing to  do  is
> probably  to  have  the heap running in the opposite direction (frontier gets
> decreased).  Then you fill in an object from end to start, and are left  with
> the starting address.

I don't see why this is better than Matthew's

movl tag,(%esi)
leal (4*1)(%esi),%eax
movl value0,(0*1)(%eax)
movl value1,(4*1)(%eax)
...
movl valueN,(4*N*1)(%eax)
addl (4+4*(N+1)*1),%esi

His seems pretty minimal, in that there is one statement per object field, and
one statement each for the store of the frontier and the object.

Also, Matthew, did you ever figure out why as wasn't saving your byte?