To 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…
Unbinding a name does do one thing which might call `__del__`: It decreases the reference count by 1.
Writing a basic x86-64 JIT compiler from scratch in stock Python
31–40 of 52 posts
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#32Just 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.
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
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#33Earlier quoted context omitted.
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.
that wont stuff lots of fancy compiler buzzwords in my face and become white noise to me. 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
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#34In 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
#35Earlier 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?
I also recommended the same Wirth book as lboasso, and a couple other books, down at the bottom of the page.
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#36Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#37That is awesome! Thanks! 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?
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:
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#38Isn'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?
Re: Writing a basic x86-64 JIT compiler from scratch in stock Python
#39This is a very interesting and well-written article, but I am puzzled by the technique being described as "JIT compilation". 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 t…
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.