3 ms·
IMO, LLVM is more successful than JVM in this metric. JVM has definitely had some powerhouses, but it's inherent limitations has meant that it is only able to p
by adgjlsfhk1 3y ago
IMO, LLVM is more successful than JVM in this metric. JVM has definitely had some powerhouses, but it's inherent limitations has meant that it is only able to produce languages that have many of the same limitations as Java. Since LLVM generates machine code, the limitations of LLVM compiled languages end up being a lot closer to the limitations of modern processors.
- pjmlp 3y agoAs Rust folks keep re-discovering in compiler regressions, likewise LLVM has many of the limitations of the C and C++ abstract machine model.
- trealira 3y agoIt seems like the main problem, for implementers of languages significantly different to C and C-like languages, is that LLVM doesn't offer direct access to hardware registers or the stack, and it has built-in calling conventions. (Although, that's kind of the point of LLVM IR. GHC implementers wanted certain values to be always kept in registers, from what I understood of it.) This was a problem in writing an LLVM backend for both the Glasgow Haskell Compiler and the Standard ML of New Jersey Compiler. It seems like it was easier for the GHC implementers, because they were already able to compile their semantic IR (the spineless tagless G-machine) into C--/Cmm, which conceptually isn't that different from LLVM IR. The SML implementers compiled to the continuation passing style, which is harder to map to LLVM IR. However, the GHC implementers still had to extend LLVM with a custom calling convention, so it was still challenging. Paper on the LLVM backend for GHC Haskell: https://llvm.org/pubs/2010-09-HASKELLSYM-LLVM-GHC.pdf https://llvm.org/pubs/2010-09-HASKELLSYM-LLVM-GHC.pdf Paper on the LLVM backend for SML/NJ: https://people.cs.uchicago.edu/~jhr/papers/2020/ifl-smlnj-llvm.pdf https://people.cs.uchicago.edu/~jhr/papers/2020/ifl-smlnj-ll...
- pjmlp 3y agoThanks for the links.
- adgjlsfhk1 3y agoAt this point, between Rust, Julia, and Swift, it is in pretty good shape. The biggest one that used to be a problem was handling of undefined behavior, but at this point, LLVM's poison system works quite well.
- mike_hearn 3y agoJVMs also produce machine code ;) In practice LLVM is designed for C/C++ like languages. You can use it for other things but not easily. GraalVM is the closest thing to a universal VM so far, but even then, it's more optimized for high level languages than stuff like Rust (even though it can run those).