TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Implementing a fast interpreter without resorting to assembly

93 pointsby madalmost 14 years ago

6 comments

fexlalmost 14 years ago
Brilliant. Fascinating how he slides from switch-dispatching to function pointers, deals with the problems there, then does that thing where the function pointer returns the next function pointer. But that's just skimming the surface of the brilliance there. The intricacies of his observations have a sparkling beauty.
评论 #2593558 未加载
habermanalmost 14 years ago
&#62; and thus debunk one of the greatest virtual machine myths of all - the blind faith in the use of jitting as a performance accelerator.<p>It's not blind faith, it's demonstrated in pretty much every situation where an interpreter and a JIT are both available for the same language. All of the fastest VMs out there today (V8, LuaJIT, JVM, etc.) are based on a JIT.<p>&#62; The performance level made possible by the Nostradamus Distributor also means that [interpreter-based] Bochs could purely interpreted pretty much match the performance of [JIT-based] QEMU, although I admit that is still left to actually implement and try out.<p>This sounds like blind faith to me.
评论 #2594018 未加载
sbalmost 14 years ago
I have just read the post and have to say that I would appreciate the post containing a more accurate description of the testing methodology. Some of the techniques described are known in interpreter optimization and his description of "threaded code" intepreter is actually not consistent with what it usually means (viz. threaded code interpreters have nothing to do with "threading" the decode for the successor instruction into the operation implementation of the current instruction, but just moving instruction decode and dispatch into the operation implementation.)<p>Aside of that, there have been papers detailing the software pipelining approach (cf. Hoogerbrugge et al.: "A code compression system based on pipelined interpreters", 1999), but I cannot for the love of god imagine that the loop shown in there is faster than a JIT compiler for a very simple reason: each of the interpreter operations is invoked via a function pointer, which means that the compiler emits an indirect branch instruction for implementing this. Now, these indirect branch instructions are <i>very</i> costly, and a simple JIT compiler could just take the actual values (callee target addresses) of the input program and generate direct call instructions instead. (And I am not even talking about inlining the function bodies of the operation implementation.)
评论 #2594297 未加载
radarsat1almost 14 years ago
I'm not sure I understand the attraction of writing a fast interpreter, as opposed to writing a JIT or ahead-of-time compiler. If you're going to the trouble of optimizing the hell out of your interpreter, yet compiling will always result in faster execution time, why not go directly from an easy, one-off slow implementation to writing a compiler, instead of spending your time optimizing the execution loop?
评论 #2593543 未加载
评论 #2593897 未加载
评论 #2593608 未加载
评论 #2593994 未加载
评论 #2593848 未加载
dexenalmost 14 years ago
The content of the website is beyond awesome.<p><a href="http://www.emulators.com/docs/nx33_qemu_0125.htm" rel="nofollow">http://www.emulators.com/docs/nx33_qemu_0125.htm</a> first caugth my eye.<p>then <a href="http://www.emulators.com/docs/nx30_bochs245.htm" rel="nofollow">http://www.emulators.com/docs/nx30_bochs245.htm</a>
wolfgangKalmost 14 years ago
Too bad I'm coming late to the party, but those interested by this post might be interested by the test implementations that I made a few months ago to bench various design parameters of interpreters (bytecode size, gCC computed goto extension...) in high level (I.e boost::variant&#60;&#62;) C++. I don't have the numbers at hand but I remember it was very CPU dependant. You can try for yourself, it is only a few self contained small programs : <a href="https://github.com/scientific-coder/Computer-Languages/tree/master/interpreting" rel="nofollow">https://github.com/scientific-coder/Computer-Languages/tree/...</a>