很长一段时间以来,我一直将 LLVM 视为我目前正在实现的语言的新后端。它似乎具有良好的性能,相当高级的生成 API,足够的低级支持来优化奇特的优化。此外,虽然我自己没有检查过,但苹果似乎已经成功地演示了将 LLVM 用于垃圾收集的多核程序。
到现在为止还挺好。因为我对垃圾收集和多核都感兴趣,所以下一步是选择一个 LLVM 多核垃圾收集器。这让我想到了一个问题:什么是可用的?我知道 Jon Harrop的 HLVM 工作,但仅此而已。
请注意,我需要跨平台,所以 Apple 的 GC 可能不是我想要的(除非有跨平台版本)。另请注意,我不反对 stop-the-world 垃圾收集器。
提前致谢,
约里克
最佳答案
LLVM docs say that it does not support multi-threaded collectors然而。
As the matrix indicates, LLVM's garbage collection infrastructure is already suitable for a wide variety of collectors, but does not currently extend to multithreaded programs. This will be added in the future as there is interest.
文档确实说要进行多线程垃圾收集,您需要停止世界,并且这是不可移植的东西:
Threaded Denotes a multithreaded mutator; the collector must still stop the mutator ("stop the world") before beginning reachability analysis. Stopping a multithreaded mutator is a complicated problem. It generally requires highly platform specific code in the runtime, and the production of carefully designed machine code at safe points.
然而,线程之间的共享状态是一个令人讨厌的缩放问题。如果您的语言仅通过“任务”之间的消息传递进行通信,因此在工作线程之间没有共享状态,那么您可以对每线程堆使用每线程收集器吗?
关于multicore - 多核 llvm 的垃圾收集器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2271140/