
Integrating with LLVM - ColinWright
http://dylanfoundry.org/2014/11/05/integrating-with-llvm/
======
bjourne
One big downside with llvm as a compiler backend is that it does not support
accurate relocating garbage collection, see:
[http://www.philipreames.com/Blog/2014/02/21/why-not-use-
gcro...](http://www.philipreames.com/Blog/2014/02/21/why-not-use-gcroot/). I
believe both Dylan and Julia uses conservative gc which is not at all as
efficient as relocating gc.

~~~
BruceM
Well, if you're aware of that blog post from February, then you should also be
aware of all of the work that he and his team have done since then. They're
working on solving the problems with LLVM and more advanced GC.

As for Dylan, Dylan can use Boehm (and does for now in the C and LLVM
backends), which is conservative.

However, Dylan can also use MPS
([http://ravenbrook.com/project/mps](http://ravenbrook.com/project/mps)) which
is a much more advanced GC that does copying/compacting and all that. Dylan
uses MPS with the compiler backend that generates native code.

The plan is that once the LLVM backend is up and running using Boehm, efforts
will be made to get it working with MPS.

Julia uses a home-grown GC, but I'm not familiar with it or its
characteristics at all.

~~~
bjourne
Yes I know they are working on solving the issues I've mentioned, but I don't
think they are there yet? I wasn't aware of MPS, it looks like a very
interesting garbage collector. Do you know if it supports inline bump
allocation (no function calls)? I skimmed the docs but couldn't find the
answer. The language I'm contributing to (Factor) does that by keeping the
nursery pointer in a register so you just ADD to it to allocate memory.

To bad about the restrictive license. Is that why there is the Open Dylan
exception in it?

~~~
BruceM
MPS is designed so that allocation can be very fast in the common case as long
as the interface to the collector in the compiler and run-time is done well.

They are willing to talk to people about the licensing. They're nice folks,
although often pretty busy. CLASP supports using both MPS and Boehm as well.

As for the Open Dylan exception ... yes. But the other thing to understand
there is that both MPS and what is now Open Dylan were developed at Harlequin
in the 1990s and MPS's original "client" was Open Dylan.

~~~
bjourne
So if another compiler wanted to use MPS in their runtime, they couldn't,
unless binary distribution of programs compiled with that compiler was
forbidden? I'm not a license wonk by any means, but it seems to me that
programs compiled with CLASP themselves need to be gpl:ed since CLASP itself
is.

~~~
klipt
> it seems to me that programs compiled with CLASP themselves need to be
> gpl:ed since CLASP itself is.

Why? GCC is GPL'd but plenty of people use GCC to write non-GPL code...

~~~
bjourne
[https://www.gnu.org/licenses/gcc-
exception-3.1.html](https://www.gnu.org/licenses/gcc-exception-3.1.html)

------
hajile
Was there ever any consideration of the rubinius JIT? It seems that for a
somewhat small community like Dylan has, pairing up with other small groups to
make and improve a shared JIT would be a better use of resources.

~~~
BruceM
Interesting question. I would say that the answer is "no, the rubinius JIT was
never considered" ... One thing is that we don't just JIT compile code. In
fact, we only do on Windows when under the debugger / REPL. We do AOT
compilation, for better or worse. LLVM is a pretty nice match and gives us a
lot of good things, including DWARF debug info.

------
qznc
What approach do others use? API or Bitcode? The pro and contra discussion is
quite short in the article.

~~~
BruceM
Well, I'd mainly written it for people who were (already) asking me about how
we differed from other integrations or why we did what we did ...

LDC (D with LLVM) is written in C++, so they invoke LLVM APIs, but I don't
know what they generate (bitcode or machine code).

Julia is written in C++, they invoke LLVM APIs, they call the JIT.

CLASP is written in C++ and Common Lisp, they invoke LLVM APIs, but I'm not
sure if they only JIT or if he stores anything to disk yet.

And so on ...

------
thope
"You are tied to a particular version of the LLVM API at compile time."

In what pretty terms these thoughts are put!

