The C code generated by GHC doesn't use higher-level features of C to be able to control as precisely as possible what code is generated. Moreover, it uses special features of gcc (such as, first class labels) to produce more efficient code.
STG C makes ample use of C's macro language to define idioms, which also
reduces the size of the generated C code (thus, reducing I/O times).
These macros are defined in the C headers located in GHC's includes
directory.
TailCalls.h
TailCalls.h
defines how tail calls are implemented - and in particular - optimised
in GHC generated code. The default case, for an architecture for which
GHC is not optimised, is to use the mini interpreter described in the STG paper.
For supported architectures, various tricks are used to generate
assembler implementing proper tail calls. On i386, gcc's first class
labels are used to directly jump to a function pointer. Furthermore,
markers of the form --- BEGIN ---
and --- END
---
are added to the assembly right after the function prologue
and before the epilogue. These markers are used by the Evil Mangler.
Last modified: Wed Aug 8 19:28:29 EST 2001