[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Native Code Again
From: |
Andy Wingo |
Subject: |
Re: Native Code Again |
Date: |
Fri, 28 Jan 2011 12:01:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Heya Noah,
Replying out-of-order here.
On Sat 08 Jan 2011 18:27, Noah Lavine <address@hidden> writes:
> 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.
Hah, it seems we concluded on the same thing after all...
> Specifically, you could construct the VM using the JITcode generator,
> either on Guile startup or whenever the user decided to enable native
> code generation.
This is a very interesting possibility. It scares me, in its
complexity, but it does seem to handle all of the objections that I had.
> 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).
I actually don't think that either of these are bad ideas.
And also... why not rely on gcc's tail-call optimization, in the case
where it works? You can check for it at configure-time. I just ran
some small tests for tail-calls between functions in separate
compilation units and it shows that indeed, gcc does the right thing.
I guess that given this circumstance, things are a lot easier. The JIT
library still needs to know how to tail-call a C function, but that is
more tractable. If you don't have tail-calls, perhaps the JIT compiler
uses trampolines as you and Ludovic proposed; and that becomes a case
that only gets exercised with -O0, and possibly not even then if we add
-foptimize-sibling-calls when available.
My apologies again for going back and forth on this issue! It's
important, and there are a few options, so I guess more discussion is
better here.
Let us know your thoughts :)
Regards,
Andy
--
http://wingolog.org/