When used at the end of a function, when all locals go out of scope, it is actually doing nothing.
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.
The book is freely available here: http://people.inf.ethz.ch/wirth/CompilerConstruction/index.h...
For a more comprehensive example, you can have a look at my compiler for the full Oberon language targeting the JVM. It is based on the principles of that book: https://github.com/lboasso/oberonc
I'd keep an eye on http://www.craftinginterpreters.com/contents.html, although it hasn't gotten to compilation yet (I think).
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.
I enjoyed this read because it was a very user-friendly overview. After reading, I knew exactly what major pieces did what and therefore what to search for next on my own terms.
Crenshaw's tutorial fits this perfectly: https://compilers.iecc.com/crenshaw/
x86 version here: http://www.pp4s.co.uk/main/tu-trans-comp-jc-intro.html
Aren't these the same thing?
This particular project luckily turned out to be quick to get working. Also, I kept the scope very small, calling it a day right before getting big ideas.
Isn't JIT compilation the process of compiling some sort of intermediate code into machine code at runtime? For example, compiling JVM bytecode into machine code during execution, and using the cached machine code transparently on subsequent calls to that segment of code.
Not to detract from the article, or the interesting techniques and explanation, but I didn't see any compilation other than by gcc, which IMHO makes this AOT rather than JIT compilation.
What am I missing?
Perhaps I should have included a small example of compiling a linear list of abstract instructions into machine code. But that again would consist of compiling small templates in a coherent way, just like many actual compilers do.
Anyway, point taken, and maybe I'll expand the article or follow up on it.
The article author seems to be using GCC not at runtime, but more as a generator for templates (at the machine code level) for the rest of the software to use. You don't really want to be assembling a template at runtime in this context.
.Net doesn't work that way, for instance. Unlike Java's HotSpot, .Net never interprets CIL instructions. They're always compiled down to native code for execution.
At least, that was true in 2009, according to Jon Skeet - https://stackoverflow.com/a/1255832/2307853
Congratulations on the article.
Does anybody know the easiest way to compile to JVM bytecode? I have a Scheme interpreter written in Kotlin, what is the best way to compile it, instead of interpreting? Where do I start?
Shen to JVM bytecode compiler in Java 6 https://github.com/otabat/shen-jvm
Shen to JVM bytecode compiler in Java 8 with indy https://github.com/hraberg/Shen.java
http://www.cs.ncl.ac.uk/publications/trs/papers/129.pdf
*by "poking around" I mean I typed the code into a text editor for further study:
http://jasmin.sourceforge.net/
Or have a lookt at Kawa.