TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Writing a basic x86-64 JIT compiler from scratch in stock Python

325 点作者 csl超过 7 年前

10 条评论

Jasper_超过 7 年前
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&#x27;s morally equivalent to &quot;block = None&quot;, except future references to block will raise a NameError instead of giving you None.<p>When used at the end of a function, when all locals go out of scope, it is actually doing nothing.
评论 #15667116 未加载
dsco超过 7 年前
Just what I love, a scientific and pedagogic CS article, in well formulated English.<p>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.
评论 #15666376 未加载
one_thawt超过 7 年前
In my opinion, the most tedious part of writing this sort of thing from scratch is the x86&#x2F;x86-64 instruction encoding. Grab the Intel&#x2F;AMD manuals or an opcode database and have fun. Other projects to study: LLVM, dynasm, asmjit, peachpy, luajit jit, Intel XED, etc.
评论 #15667821 未加载
评论 #15666753 未加载
评论 #15669889 未加载
tamer_c超过 7 年前
off topic question: When do you find time do such interesting things as these? I&#x27;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&#x27;m even happy to get to sleep 8 hours.
评论 #15666519 未加载
评论 #15666778 未加载
mnembrini超过 7 年前
A nice trick for debugging code generated at runtime is temporarily adding a CC instruction at the beginning of your assembly function, so you don&#x27;t have to care where in memory your snippet is going to end up
defined超过 7 年前
This is a very interesting and well-written article, but I am puzzled by the technique being described as &quot;JIT compilation&quot;.<p>Isn&#x27;t JIT compilation the process of compiling some sort of intermediate code into machine code <i>at runtime</i>? 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.<p>Not to detract from the article, or the interesting techniques and explanation, but I didn&#x27;t see any compilation other than by gcc, which IMHO makes this AOT rather than JIT compilation.<p>What am I missing?
评论 #15669174 未加载
评论 #15668274 未加载
pjmlp超过 7 年前
Love the idea of only using stock Python.<p>Congratulations on the article.
peteforde超过 7 年前
I am reminded of a most excellent piece of science fiction, &quot;Coding Machines&quot;.<p><a href="https:&#x2F;&#x2F;www.teamten.com&#x2F;lawrence&#x2F;writings&#x2F;coding-machines&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.teamten.com&#x2F;lawrence&#x2F;writings&#x2F;coding-machines&#x2F;</a>
Bojjagani超过 7 年前
good performance
kovrik超过 7 年前
That is awesome! Thanks!<p>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?
评论 #15666234 未加载
评论 #15666170 未加载
评论 #15668020 未加载
评论 #15666226 未加载
评论 #15666203 未加载
评论 #15666245 未加载