Hi Noah,

Noah Lavine <noah.b.lav...@gmail.com> writes:

> After watching the discussion of native code generation on this list a
> few weeks ago, I decided I'd like to help. I looked at several
> possibilities, but it seemed like the easiest and most sure way of
> making *something* work was writing bindings to GNU Lightning.

Excellent!

Have you looked at, ahem, guile-lightning?  :-)

  http://cvs.savannah.gnu.org/viewvc/guile/guile-lightning/?root=guile

As you can see it’s an old attempt to do this.  I haven’t looked in
detail, but there may be ideas or code to borrow.

> My thought was to do enough of the Lightning API that it could call C
> functions, and then implement a compiler from Guile VM code to native
> Lightning-generated code that just called a series of VM functions.
> There wouldn't be any inlining or cool things like that, but it would
> be a start. You could then add inlining support for individual VM
> functions as it seemed important.

I had a vague plan to implement JIT in the VM using lightning in C:

  http://www.fdn.fr/~lcourtes/software/guile/jit.html

The (presumed) advantage is that opcodes from vm-*.c could be largely
reused.  The obvious disadvantage is that it would be C.  Writing
lightning assembly can be tedious, but probably less so if done in
Scheme.

>    - First, would you like Lightning bindings?

Yes!  :-)

>    - Second, what would a good interface to a native code generation
> system be? (I'm assuming we'll want Lightning available as a regular
> module in addition to using it to speed up the language.) My current
> prototype just mimics the Lightning API, but it's not necessarily the
> best way to do this. Is there a better way?

Something close to lightning at the lowest level probably makes sense.
Then there could be a higher-level interface like
<http://cvs.savannah.gnu.org/viewvc/guile/guile-lightning/compiler.scm?revision=1.3&root=guile&view=markup>
or close to the VM’s own assembly.

Looking at
<http://github.com/noahl/guile-lightning/blob/master/binds.scm> it seems
that you plan to have one subr for each lightning instruction.  That
would make the cost of assembling a single instruction quite high,
compared to that of the raw lightning C macros.

Thanks,
Ludo’.


Reply via email to