Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phases SBCL compiler

I can not find any source that would describe the individual phases SBCL compiler. What resources, e.g., papers, describe these phases of the SBCL compiler?

like image 978
Edmont Avatar asked Jun 22 '13 13:06

Edmont


1 Answers

Phil Khoung's article Starting to Hack on SBCL includes a good description of how to start working on SBCL internals. In a section about the compiler, he writes,

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 for compile-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.

The Python paper that is mentioned there is linked earlier in the article:

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).

You'll probably be particularly interested in Section 8, Compilation Phases from “The Python Compiler for CMU Common Lisp.”

like image 139
Joshua Taylor Avatar answered Nov 15 '22 10:11

Joshua Taylor