unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Native Code Again
@ 2011-01-08 17:27 Noah Lavine
  2011-01-28 11:01 ` Andy Wingo
  0 siblings, 1 reply; 5+ messages in thread
From: Noah Lavine @ 2011-01-08 17:27 UTC (permalink / raw)
  To: guile-devel

Hello all,

Sorry for all of the discussion about native code generation. I have
another idea for how we could implement a good interface to JITed
code. I've actually been thinking it for a while and initially
dismissed it as too crazy, but now I'd like to see what you all think.

The issue this solves that there is really no portable way for C code
to do tail-calls. The ideal method of calling natively-generated code
would be for the VM to tail call the JITed code, which would then tail
call the VM when it was done. The only two ways of doing this are
asking GCC to add a tail call intrinsic (unportable) or building a
library of tail-call ASM for different platforms (more generally
useful, but also basically unportable).

However, there is a third possibility: don't have the VM be C code.
Specifically, you could construct the VM using the JITcode generator,
either on Guile startup or whenever the user decided to enable native
code generation. The benefit of this is that the VM could communicate
with native code using any method our JIT library supports, rather
than any method you can do in portable C. Also, it introduces no new
dependencies than what you need anyway for native code generation,
since you would only need to do this in cases where you would be
generating native code, and in that case you would have to have JIT
capability anyway. The downside is that it's a big new batch of code
to add to Guile.

Just so you know, I have a thought on how to implement this. I posed
here a while back about generating the VM from s-expressions, but I
now have a different idea. I think that Guile should have a C code
parser, if for no other reason than that we could parser C header
declarations and make foreign function interfaces automatically. Given
that, it wouldn't be too much more work to compile C to libjit.
Therefore, I think the path to a native-code VM is to leave the VM as
it is (except maybe reserve an opcode for native-code calls). Then I
write first a C parser for Guile and then a converter program that
would take Guile's current VM and output a JIT VM like I've described.

One downside of this is that libjit probably doesn't have as good
optimization abilities as GCC, so the VM produced might be slower.
Another issue is that this is quite a bit of complexity, but actually
most of the complexity would happen at the time we compile Guile, not
Guile runtime. By the time Guile is running, the only remaining task
should be to run libjit once and go.

So, what do you all think?

Noah



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-01-28 16:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-08 17:27 Native Code Again Noah Lavine
2011-01-28 11:01 ` Andy Wingo
2011-01-28 14:33   ` Noah Lavine
2011-01-28 14:55     ` Andy Wingo
2011-01-28 16:19     ` Ken Raeburn

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).