-
Notifications
You must be signed in to change notification settings - Fork 16
Thoughts
Writing a code generator is nigh impossible and LLVM is the backend of choice. Unfortunately, LLVM is about 10 years behind current research. To be precise, LLVM has severe limitations when dealing with concurrency (green threads), garbage collection, and exceptions.
Accurate garbage collection isn't too difficult with LLVM, just a bit slow. I don't think it is worth investing must time here to find a better solution. The standard LLVM GC interface will have to do.
Green threads are nigh impossible to implement directly in LLVM but maybe we don't have to. And maybe we don't even want to. For a variety of reasons, I think it is desirable not to mutate the same heap from multiple cores. This simplifies things greatly and makes it feasible to implement the threading model completely in Haskell. This should play well with the garbage collector, it should be much easier to reason with (especially since it'll be written in Haskell), much easier to improve (it'll be a user level library instead of baked into the RTS), and, hopefully, very performant. A shared-nothing model will be used when work should be divided over several cores.
Zero cost exceptions are technically possible but very difficult to get right. I'm thinking that exceptional values would be passed around like normal values and then checked at each point in the call graph. Since all values are returned using either the stack or in registers, this check for exceptions should hopefully be nearly costless.
A Language-based Approach to Unifying Events and Threads: http://www.cis.upenn.edu/~stevez/papers/LZ06b.pdf