From: Noah Lavine <noah549@gmail.com>
To: ludo@gnu.org
Cc: guile-devel@gnu.org
Subject: Re: Lightning Bindings
Date: Mon, 31 May 2010 18:49:42 -0400 [thread overview]
Message-ID: <DED46412-5EEA-4A5C-A392-7D05091B2AEF@gmail.com> (raw)
Hi Ludo,
I didn't realize guile-lightning existed! It looks like that project already has most of the code for Lightning bindings, so it might be better to try to update it to work with Guile 2.0. I also saw your idea for JIT, which I could work on as well. However, all three projects use different ideas of how Lightning should connect to Guile, so before I code more I would like to talk about which would be better.
Here is my understanding of the three approaches:
The approach in my project was to make machine code a Guile datatype, which you could allocate with a special init function and write to with writing functions which are just Guile versions of the Lightning macros. It could be called as a function through the dynamic FFI.
The approach in the other guile-lightning project is to represent the Lightning code as a Guile list which mirrors the Lightning virtual instruction set. When a list is completely built, it would then be passed to a special function (written in C) to assemble it. It also has some infrastructure for labels and a special method of calling these functions, neither of which I understand yet.
The approach in your plan for JIT, as I understand it, is to implement this completely in the C layer. The machine code would be stored as part of the representation of a procedure, and would be invisible from the Scheme side.
(I should also point out that my plan for compilation was to first start generating machine code with as few inlined instructions as possible, which would just call VM functions to do its work. This was also your plan, and I believe also the plan of the earlier guile-lightning project.)
It is not clear to me which one of these is the best way, or even if there is a best way.
The reason I did not use the approach of the other guile-lightning, to make a list and then assemble it, was that it seemed inelegant and possibly slow to have to iterate through instructions twice whenever I compiled something, first to generate the list and then to compile it. However, I doubt it would be very slow, and thinking about it now it might even be faster if the iteration programs became smaller and fit in cache.
As for doing it all in C, I am concerned about this because if there were bindings available in Scheme, then it might be possible to write a nice compiler in Scheme someday, which would do clever things like inlining and interprocedural optimization. (Or, more easily, persuade the MIT Scheme or Bigloo people to donate their compilers.) Writing it in C could make that more difficult - but if it also made Guile programs faster right now, then it might be worth doing anyway.
What do you think of this? What way should I try to implement this?
Noah
next reply other threads:[~2010-05-31 22:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-31 22:49 Noah Lavine [this message]
2010-06-01 9:15 ` Lightning Bindings Andy Wingo
2010-06-01 18:02 ` Ludovic Courtès
-- strict thread matches above, loose matches on Subject: below --
2010-06-01 20:42 Noah Lavine
2010-05-27 21:03 Noah Lavine
2010-05-28 20:49 ` No Itisnt
2010-05-28 21:38 ` Noah Lavine
2010-05-29 20:09 ` Thien-Thi Nguyen
2010-06-01 14:57 ` Noah Lavine
2010-06-01 17:55 ` Ludovic Courtès
2010-06-02 20:47 ` Thien-Thi Nguyen
2010-05-29 21:39 ` Ludovic Courtès
2010-06-01 9:06 ` Andy Wingo
2010-06-01 14:55 ` Noah Lavine
2010-06-01 19:24 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DED46412-5EEA-4A5C-A392-7D05091B2AEF@gmail.com \
--to=noah549@gmail.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).