3 ms·
Unfortunately, many of these VMs don't offer a peak under the hood at runtime. For instance, V8 doesn't have any bytecode or IR you can compile to and run. Java
by TheHydroImpulse 13y ago
Unfortunately, many of these VMs don't offer a peak under the hood at runtime. For instance, V8 doesn't have any bytecode or IR you can compile to and run. JavaScript, and asm.js is the lowest you can go.
If you want to target an IR language, you can try LLVM. Although it's not a VM, you can definitely implement your own language on-top of it. It'd be pretty low-level.
Other alternatives are Ruby VMs, such as Rubinius, which actually uses the LLVM JIT compiler. Rubinius is pretty fast (I have never used it myself) and it has it's own bytecode format, so you can easily compile your own language to it.
Fancy (https://github.com/bakkdoor/fancy https://github.com/bakkdoor/fancy) is a great example of this. It compiles to Rubinius bytecode and executes it within the virtual machine.
- girvo 13y agoYeah, that's the issue I've run into (with PHP at least). Isn't that what this tool here is supposed to allow you to do, though? Give you a peek under the hood to V8? That's why I thought it was really interesting :) Of course, I'm likely reading it wrong, and just because it gives you access to the IR doesn't mean it lets you interface with said IR directly, which is the issue! Yeah I've been fiddling with LLVM lately, it's really quite nice. Fancy looks awesome, cheers for that!
- TheHydroImpulse 13y agoYeah, V8 has a lot of stuff under the hood that you can access for profiling and what not, but nothing more than that. V8 has two JIT compilers. One that's quick at starting up, but doesn't produce very good cpu instructions, and an optimizing JIT-compiler that takes a lot longer to spin up, but the code is heavily optimized. You can ask V8 to give you IR dumps and other meta information about the runtime of your program. But, unfortunately, that's all you can get. You can't use V8 to implement a new language, or compile your language down, unless you transpile it to JavaScript, which isn't as fun. Yeah, LLVM is pretty awesome of compilers. I know it used to be somewhat bad for JIT compilers, but I haven't tried or benchmarked it since then. There's also LibJit that's written in C, and it's only goal is to JIT compile (http://eli.thegreenplace.net/2013/10/17/getting-started-with-libjit-part-1/ http://eli.thegreenplace.net/2013/10/17/getting-started-with...). A downside to LibJit is the lack of IR. It just emits x86(-64?) instructions. LLVM offers it's super awesome IR which makes debugging a ton easier. Julia is another smaller VM that makes use of LLVM as a JIT compiler. I don't know if it has a bytecode you can compile to, or not. Then you can always go towards an interpreted virtual machine, written in C or even Rust; if the current VMs don't work out.