我找不到任何可以描述 SBCL 编译器各个阶段的来源。哪些资源(例如论文)描述了 SBCL 编译器的这些阶段?
最佳答案
Phil Khong 的文章 Starting to Hack on SBCL包括如何开始在 SBCL 内部工作的很好的描述。在关于编译器的一节中,他写道,
Finding where the compiler lives
Working on the compiler itself is a bit more work. I think the best approach is to go in
src/compiler/main.lisp
and look forcompile-component
.ir1-phases
loops on a component and performs high-level optimisations until fixpoint (or we get tired of waiting), while%compile-component
handles the conversion to IR2 and then to machine code. The compilation pipeline hasn’t really changed since the Python paper was written, and the subphases each have their own function (and file). M-. on stuff that sounds interesting is probably the best approach at the IR2 level.
那里提到的 Python 论文在文章前面有链接:
Exploring the source
I often see newcomers try to read the source like a book, and, once they realise there’s a lot of code, try to figure out a good order to read the source. I don’t think that’s the best approach. SBCL is pretty huge, and I doubt anyone ever simultaneously holds the complete system in their head. RAM’s “The Python Compiler for CMU Common Lisp” is still useful as an overview, and SBCL’s internals manual is a good supplement. Once you get close to bootstrapping logic, Christophe Rhodes’s “SBCL: a Sanely-Bootstrappable Common Lisp” helps understand the exclamation marks. Past that, I believe it’s preferrable [sic]preferrable to start out small, learn just enough to get the current task done, and accept that some things just work, without asking how (for now).
您可能会对 特别感兴趣第 8 节,编译阶段 来自“CMU Common Lisp 的 Python 编译器”。
关于compiler-construction - 阶段 SBCL 编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17251129/