[MLton] Patch for x86-darwin
Matthew Fluet
fluet at cs.cornell.edu
Wed Sep 27 09:33:38 PDT 2006
> I copied the memory.x86-freebsd.mlb, renaming it to memory.x86-darwin.mlb.
> You'll have to do that since I don't have write access.
Done.
> Let me know if there are issues.
Here are a few questions:
-Word32 c_stackP;\
+/* The first element of this array is the stack pointer to be used by\
+ * sml (16-byte aligned). The second is the actual base of the stack,\
+ * which is used when returning to C.\
+ */\
+Word32 c_stackP[2];\
I don't understand why this change is necessary. There shouldn't be a
need to have two copies of the stack pointer around. I'm wondering if its
related to the issue below.
Otherwise, it looks pretty good. I think there is a (latent) bug in the
val (pushArgs, size_args) = ...
code, since the size_args is computed as the size of the unpromoted
values. That is, when calling a C function with the prototype:
int f (char c, short s);
it yields 3 (bytes) for size_args, although 8 bytes of stack are consumed
for the arguments. The size_args is only used for computing the suffix
for the stdcall calling convention (but that isn't used by much, and the
suffix would be correct for any function with all wordsize arguments) and
for adjusting the stack after a cdecl call. Again, this wouldn't hurt us
in the long run because we usually fetch the C stack pointer from a global
before each C function call; we only adjust %esp to avoid consuming stack
space when there are multiple C calls in a row.
More information about the MLton
mailing list