Earlier quoted context omitted.
I'm writing my first compiler now, and it's been quite a learning curve. I've also realized how much nicer my language is for writing compilers than the language in which I'm implementing the compiler. That made me realize I could write the compiler in my language and then write an interpreter for my language which would only need to run once--to generate the compiler--after which point my compiler would be self-host…
Do you mind sharing some of the resources you're using to learn? Book titles or URLs?
Writing a basic x86-64 JIT compiler from scratch in stock Python
21–30 of 52 posts
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#22Just what I love, a scientific and pedagogic CS article, in well formulated English. I would appreciate some introductory notes or links to prerequisites though. That would perhaps entice an audience who has no previous experience in writing compilers.
I really want to be able to wrap my head around compilers but I'm not sure what a good "user friendly" resource is that wont stuff lots of fancy compiler buzzwords in my face and become white noise to me.
I'd keep an eye on http://www.craftinginterpreters.com/contents.html, although it hasn't gotten to compilation yet (I think).
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#23In my opinion, the most tedious part of writing this sort of thing from scratch is the x86/x86-64 instruction encoding. Grab the Intel/AMD manuals or an opcode database and have fun. Other projects to study: LLVM, dynasm, asmjit, peachpy, luajit jit, Intel XED, etc.
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#24off topic question: When do you find time do such interesting things as these? I'd really like to dive deeper in this topic. As a CS student, who also got to work as a dev at the same time for a living, I'm even happy to get to sleep 8 hours.
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#25Earlier quoted context omitted.
Lisp In Small Pieces would be my reccomendation. A relatively small book that takes you through writing 11 interpreters and 2 compilers.
Is it really that friendly when starting out, though? I found it brilliant, but quite the challenging read. I'd rather just read chapters four and five of SICP [1] and move on to Queinnec as a follow-up on more advanced topics. [1]: The book is free as well: https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html...
SICP being freely available in both book form, and the lectures [0] makes it one of the best resources out there.
(I just never found it's section on compilers that helpful. Again, probably learning styles.)
[0] https://www.youtube.com/playlist?list=PLB63C06FAF154F047
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#26When used at the end of a function, when all locals go out of scope, it is actually doing nothing.
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#27Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#28To be clear about the `del block` thing, the only thing that the `del` keyword does in Python is unbind a name from the local scope. It does not cause an object to be destructed, call `__del__`, or anything else. It's morally equivalent to "block = None", except future references to block will raise a NameError instead of giving you None. When used at the end of a function, when all locals go out of scope, it is actu…
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#29Just what I love, a scientific and pedagogic CS article, in well formulated English. I would appreciate some introductory notes or links to prerequisites though. That would perhaps entice an audience who has no previous experience in writing compilers.
I really want to be able to wrap my head around compilers but I'm not sure what a good "user friendly" resource is that wont stuff lots of fancy compiler buzzwords in my face and become white noise to me.
At this point it's not well-documented, but the layers are numbered in order: l00, l01, l02... Each builds on top of the previous one.
EDIT: I just added a mini evaluator for debugging purposes and so people can see what the language is like.
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#30off topic question: When do you find time do such interesting things as these? I'd really like to dive deeper in this topic. As a CS student, who also got to work as a dev at the same time for a living, I'm even happy to get to sleep 8 hours.
Why not take a class about compilers and implement something like that as a class project?