11 ms·
ZetaVM, my new compiler project
- zerr 10y agoWhy do you need Tag member in the Word union?
- tachyonbeam 10y agoAuthor here: sometimes you want to get the tag of a value, and operate on that tag as a value, but I guess this may not be necessary in this system, given that the get_tag instruction will produce an immutable string. EDIT: removed it. It was probably left over from old code, previous VM's I've written: https://github.com/maximecb/zetavm/commit/7ef746f061135304684c5029820631a688c399fa https://github.com/maximecb/zetavm/commit/7ef746f06113530468...
- marktangotango 10y agoHow does this project compare to nekovm? Sounds very similar.
- tachyonbeam 10y agoNot familiar with Neko, but superficially, it seems that VM is designed for a specific programming language. It uses a bytecode IR whereas Zeta uses a textual one. Neko is also farther along, more mature and feature complete than Zeta. I intend to take a more experimental direction with Zeta. It won't have an FFI, for instance. It will only provide a small set of minimalist APIs. The VM will be intentionally designed to avoid code rot and breaking changes. Another thing I would like to experiment with is transparent compilation of pixel shaders to run on GPUs, the ability to run code in any language running on Zeta (given some restrictions) on both the CPU and GPU. I believe I have found a way to make this work, based on my type-specialization research.
- ternaryoperator 10y ago>"The VM will be intentionally designed to avoid code rot" How do you plan to do that?
- tachyonbeam 10y agoThe IR, once past an initial prototyping state, will not change. Things will be added to it later, but not removed. The IR and semantics will be designed, as much as possible, to eliminate corner cases and undefined behaviors. Zeta will favor robustness over tiny performance gains. I realize that completely eliminating undefined behaviors isn't necessarily possible, but we will do our best. The outside world will be accessible through a set of APIs that are small, have limited surface area. For instance, sound output will be done by writing raw samples. Graphics will be done with pixel shaders (functions which given coordinates return a pixel color). New APIs will be added over time, new versions of APIs will be added, but the older APIs will remain functional. There will eventually be a package manager, and it will have immutable package versioning. That is, you can publish v5 of libtern, and I can depend on it. You can later publish v6 of libtern, but you can't change v5, so you can't break my code which depends on v5 when you publish new versions of your lib. Obvious caveat: Zeta will have no FFI. You won't be able to immediately use all the libraries you could use in another system. I still think that building a huge amount of code that doesn't break could turn out to be a huge advantage. We won't try to satisfy every use case out there... But I think there are a lot of interesting and useful programs which don't need much more than basic keyboard and mouse input, audio and video output, network and file access (think photoshop, audio editing software, IDEs, etc). We will probably end up adding APIs for other things like MIDI, etc later on.
- __s 10y agoWhat about WebAssembly? It's hit 1.0 now, & it's designed so that 1.0 wasm will never become deprecated My own thoughts have been considering a wasm vm in kernel space. No need to ever exit kernel space; the wasm vm provides sufficient sandboxing. Wasm binaries could run on any architecture. Hopefully come up with a method that browsers can efficiently run wasm in directly in the kernel's sandboxing rather than having wasm-in-wasm. Syscalls could be exposed through wasm's import/export system. Kind of like that Metal idea in "The Birth & Death of JavaScript"
- grashalm01 10y agoYour mission seems to be matching with what we are trying with Graal and Truffle. The Truffle API aims to be stable as well. We also provide basic building blocks like an object model. I am curious how you plan to support speculative optimizations that need to deoptimize and reconstruct interpreter stack frames? In my experience that's essential for building high performance dynamic language implementations.
- tachyonbeam 10y agoThe interpreter I'm building right now will essentially be a JIT, but it will JIT to an internal IR instead of machine code. My plan is to eventually have it operate on compact and optimized stack frames as native code would.
- DonbunEf7 10y agoI wonder whether a "bridge-across-the-void" approach would work. The idea is that a speculative optimization would not discard its original form, so that deoptimization is as cheap as a rollback. Then, when speculative optimizations are performed, they form a kind of bridging branching structure which reaches across the void of invalid low-level IRs, trying to find a safe point at which the optimization can complete. I know that Truffle is based on partial evaluation; how close are you to Futamura #2? That'd relieve you of the burden of having to care about what an "interpreter stack frame" even looks like. OTOH I can confirm that the same kind of speculation in optimization has to occur during self-application. It really is a thorny problem, isn't it?
- mpweiher 10y ago> essential for high performance dynamic language implementations Is it? Objective-C is a dynamic language (AOT-compiled) that doesn't have these features, and it is possible to write very high performance code with it.
- chrisseaton 10y agoI don't have any numbers, but I think it's generally possible to write very high performance code in Objective C... by not using the dynamic language features of it such as message sends. Objective C I believe does a globally cached method lookup for every message send (!) and so can't inline through message sends (!), and since inlining is the mother of all optimisations I would imagine this would severely limit performance if you tried to use a lot of message sends in your inner loops. We should actually think about doing that experiment to see what the cost would be. In a language like Ruby almost all operators, even basic arithmetic, are dynamic method calls, so you can't avoid using message sends anywhere. I think if you tried to do that in Objective C things might grind to a halt. Objective C also lacks many dynamic language features which are the ones solved through speculative optimisation, such as integer overflow, access to frames as objects, and so on. I'm not an expert on Object C though so happy to be corrected.
- msangi 10y agoI'm wondering how different languages implemented on top of this VM could be, especially at the semantic level. Having different syntaxes on top of the same VM is nice and all the JVM languages show that there is room for a good variety and for different paradigms. On the other hand, the choice of a VM sets some constraints while providing important features. Think for instance at the differences between the languages running on the JVM and the languages running on the BEAM (Erlang's VM). I think there is a lot of untapped potential for innovative ideas at the VM-level but for some reason most of the effort goes into proposing new syntaxes that reuse the same concepts all the other languages are using.
- Johnny_Brahms 10y agoI have been playing with toy languages for the guile VM, and you can do quite a lot of things before the VM limits you much. With some exceptions though: Java VM does not support tail call optimization, which limits how you implement loop constructs.
- salmonlogs 10y ago+1 for the amazing domain name