4 ms·
About GC: it would be nice if there would be some kind of standard-ish implementation framework for a GC in an LLVM language. LLVM has been enabling fantastic
by exDM69 10y ago
About GC: it would be nice if there would be some kind of standard-ish implementation framework for a GC in an LLVM language.
LLVM has been enabling fantastic new programming languages, and while it has support for a GC, I have not found a GC library that would be easy to embed in a new compiler/runtime environment.
Now there are dozens of LLVM-based languages (or language prototypes) that have different, incompatible implementations of GC with varying degrees of quality. If there was a relatively simple but efficient GC available, it would be much easier to implement a new language on LLVM.
At one point there was a project called HLVM, but it was targetted at implementing JVM and .NET -style virtual machines. This is not what I'm looking for and I think the project is dead now.
If anyone knows about a GC implementation for LLVM, I'd really like to take a look. If it's a part of a programming language project but would be relatively easy to rip out of the rest of the compiler/runtime, it's not a problem.
That said, I prefer languages without GC.
- pjmlp 10y agoIt is very hard to have a general purpose GC library, because the best GC algorithms require a tight cooperation between compiler, GC and language semantics. For me, the only viable alternative to GC are substructural type systems like in Rust's case.
- exDM69 10y agoYou're definitely right and it's not an easy task. However, I think there's a sweet spot where you could implement a fairly nice boilerplate/framework that would be an 80% solution to the problem which would be a vast improvement over the current state. The missing 20% would be language specifics and that would be either solved by forking the boilerplate code or writing some kind of callbacks for discovering references given a root object. edit: Additionally, there's no simple example of using a GC with LLVM. It would be very helpful if there was, for example, a GC'd version of the Kaleidoscope language used in the LLVM tutorials. Even a trivial Lisp-style cons/car/cdr object system coupled with the simplest possible mark'n'sweep GC would be good.
- pjmlp 10y agoYou should check projects like the The Mu Micro Virtual Machine and Eclipse OMR http://microvm.github.io/ http://microvm.github.io/ http://projects.eclipse.org/projects/technology.omr http://projects.eclipse.org/projects/technology.omr The guys behind The Mu Micro Virtual Machine were the ones that did the L4 OS formal verification. Eclipse OMR is based on IBM's J9, they are making it language agnostic to support PHP, Python, Ruby and whatever else one can think of. However they aren't LLVM based and the caveats of a generic GC do still apply. I also agree with you, the problem is how much those 20% actually are in terms of effort. EDIT: typo where => were, on => one
- filereaper 10y ago"About GC: it would be nice if there would be some kind of standard-ish implementation framework for a GC in an LLVM language." Not quite LLVM, but take a look at the Eclipse OMR project. OMR intends to provide a set of reuseable components like a GC, port-library and given more effort a jit to be reused into existing language runtimes or build a whole new language out of them. https://github.com/eclipse/omr https://github.com/eclipse/omr
- dikaiosune 10y agoThe Boehm collector (http://www.hboehm.info/gc/ http://www.hboehm.info/gc/) appears to offer what you're describing. In fact, it looks like it's what Crystal added in 2013 to implement its original garbage collection: https://crystal-lang.org/2013/12/05/garbage-collector.html https://crystal-lang.org/2013/12/05/garbage-collector.html
- exDM69 10y agoI'm familiar with it but it's not at all what I'm looking for. It's a library to "retrofit" GC into a C or other native program. I'm looking for something to plug into LLVM's GC mechanisms to be used for new languages.
- mike_hearn 10y agoI guess the question is, by the time you added high quality GC to LLVM, how different would it be to the JVM or .NET? Bear in mind that .NET can do AOT compilation and the JVM is getting it (and some other non-OpenJDK JVMs already have it).