new register allocator and calling convention
Stephen Weeks
sweeks@intertrust.com
Fri, 3 Dec 1999 15:20:08 -0800 (PST)
> Why is it hard to return values from calls to the runtime system? The gmp
> stuff does it.
If a MLton primitive returns a value, then its call will appear on the
right hand side of a C assignment statement. It's hard to fit C
statements inside of expressions -- the comma operator only allows
assignments before a comma. Also, I have one macro which is used for
all runtime system invocations now, and it would be hard to put this
on the rhs of a C assignment.
#define MLTON_invokeRuntime(call, frameSize, ret) \
do { \
stackTop += (frameSize); \
*(uint*)stackTop = (ret ## _index); \
MLTON_flushGC(); \
call; \
MLTON_cacheGC(); \
MLTON_return(); \
ret: \
stackTop -= (frameSize); \
} while (0)