[MLton] Re: PIC in amd64 assembly

Matthew Fluet fluet at tti-c.org
Sun Aug 24 21:08:00 PDT 2008


On Fri, 22 Aug 2008, Wesley W. Terpstra wrote:
> Anyway, since MLton does a lot of symbol accessing, and since 'call' is
> expensive to get to work (we'd have to save %esp, restore it to the C stack,
> call, pop, restore %esp, ...), I think the only real option is to load the
> offset of the GOT into %ebx at MLton_jumpToSML time (while I can still
> easily use %esp) and make %ebx unavailable for use as a general purpose
> register. Yes this sucks for performance, but PIC code on i386 is always
> slower.

Seems reasonable. Since the MLton_jumpToSML code is generated assembly, 
you can do the 'pop %ebx' without another 'call'.

> So basically, all I need to know to get this whole mess to work on ELF is
> how to tell the x86-codegen that it can't touch %ebx when the output format
> is a library and the platform is ELF or darwin. As I mentioned, windows
> won't have this problem.

Mimic the uses of 'reserveEsp' in x86-generate-transfers.fun. You'll want 
to remove %ebx from the list of available registers for intra-procedural 
(inter-block) transfers (the 'transferRegs' value).  You'll also want to 
assume that %ebx is reserved at the beginning of each block (the 
'blockAssumes' function).




More information about the MLton mailing list