Phases SBCL compiler [closed]
Asked Answered
B

1

7

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?

Boss answered 22/6, 2013 at 13:11 Comment(1)
Welcome to Stack Overflow! Did the references help you in getting into the SBCL compiler? The answer has a few upvotes now, and if it's answered your question (which it might not have), you can accept it to let others know that it was helpful for you (and to give the poster and yourself a bit of reputation). Happy Lisping (and Lisp compiler hacking)!Trollop
T
10

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

Trollop answered 23/6, 2013 at 12:29 Comment(2)

© 2022 - 2024 — McMap. All rights reserved.