
I've recently browsed some assembly code generated by GHC (via gcc). It appeared that most values were accessed via memory, because the stack is managed by GHC explicity. Even intermediate results seem accessed via memory, probably due to shortcomings of aliasing analysis in gcc. (?)
This brings on the topic of eval/apply vs push/enter. In the eval/apply model, the stack management can (possibly) be left to an underlying compiler, which would remove most memory accesses, and leave most of the alignment issue to the back-end. (http://research.microsoft.com/Users/simonpj/papers/eval-apply/)
From that article, I can only assume that GHC will switch to the eval/apply model. Can we expect that soon? The "alignment" thing would become easier to deal with...
We've already made the switch to eval/apply for the next release of GHC. However, deferring the entirety of stack management to an underlying compiler is not that easy: we do accurate garbage collection, so we need to retain enough information about the compiler's idea of stack layout in order to be able to find all the pointers during GC. We therefore can't compile via C using an ordinary C compiler and leave the stack management up to the C compiler. C-- has a solution to this problem, but there is neither a C-- compiler or a C-- back end for GHC (yet). Cheers, Simon

Simon Marlow wrote:
We've already made the switch to eval/apply for the next release of GHC. However, deferring the entirety of stack management to an underlying compiler is not that easy: we do accurate garbage collection, so we need to retain enough information about the compiler's idea of stack layout in order to be able to find all the pointers during GC. We therefore can't compile via C using an ordinary C compiler and leave the stack management up to the C compiler.
Is there anything published/unofficially available about it? I have pure academic interest in all that. I must say that rarely had I the occasion to learn something more crunchy about the implementation of Haskell and FP than from the description of concrete solutions, such as STG (and the implementation of Clean, and Appel's paper on the imple- mentation of ML). Now, my white/bald hair tell me that the eval/apply model is something quite oriented towards strict evaluation paradigms, and I would enjoy very much a thorough discussion of the implementation of laziness. Jerzy Karczmarczuk
participants (2)
-
Jerzy Karczmarczuk
-
Simon Marlow