From: Noah Lavine <noah.b.lavine@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: A Working (but Minimal) JIT
Date: Sun, 28 Nov 2010 15:58:18 -0500 [thread overview]
Message-ID: <AANLkTikXJPHzb7ugVXY7PsMEw4oyR6F9oUH3Ccv=KyrD@mail.gmail.com> (raw)
In-Reply-To: <m3oc9k15hb.fsf@unquote.localdomain>
Hi,
> I am concerned about complexity.
I agree that complexity is a problem. I just sent an email about
Jitgen, which is something I cooked up to reduce code duplication.
However, I can't tell if it's going to end up reducing code complexity
or increasing it. What do you think?
> So what I would really like to see would be:
>
> * Ideally, a 4-word objcode representation that includes native
> code.
> * A well-defined convention for that native code. That's to say that
> the native code could come from JIT compilation, or from AOT
> compilation.
Let me answer these together, because I think they affect each other.
I've been poking around in the code, and noticed that procs.c has a
reference to "applicable structs". As I understand it, these are
structures that can also act as procedures. Procedures with setters
are implemented this way. Is it possible to use these as containers
for JITed code, and leave the objcode format alone? (And on a related
note, is there any documentation for them?)
I've been thinking about this because even if I could put JIT code in
the objcode struct now, that wouldn't make much sense for AOT compiled
code that wouldn't necessarily have or want objcode. It might be
better to pick an interface to compiled code now that would work with
AOT compiled code in the future, as you say.
> * A uniform way to invoke native code from the VM, and VM code from
> native code -- *preserving tail calls*. This seems to require either
> trampolines within the VM or platform-specific tail-call assembly.
This one could be hard. I can make JITed code call the VM as a tail
call, because libjit will generate tail calls if you ask it to, but I
don't see how to get from C code to JIT code without pushing onto the
stack without either some assembly code or a trampoline. I think a
trampoline would be easier, but I will ask on the libjit mailing list
how people have solved this before.
> * A uniform interface to create JIT code as needed, in the call
> instructions. i.e.
> if (SCM_UNLIKELY (SCM_NEEDS_JIT (proc)))
> scm_jit_x (proc);
> or something.
That seems easy enough.
Noah
On Sat, Nov 20, 2010 at 8:37 AM, Andy Wingo <wingo@pobox.com> wrote:
> Hi,
>
> On Fri 22 Oct 2010 06:29, Noah Lavine <noah.b.lavine@gmail.com> writes:
>
>> After not emailing for a while, I have some good news: a JIT engine is working!
>
> Great news!
>
> I have been behind on things a bit, so apologies for taking a month to
> get back to you, and then only partially. In any case Ludovic probably
> knows more both about assembly and JIT work, so I'm happy to not be a
> "gatekeeper" of sorts here...
>
> That said, I am concerned about complexity. The current VM, though
> obviously slow, does have the advantage of being relatively
> simple. Adding a JIT complicates things. Well, adding another form of
> compilation complicates things, JIT or AOT or whatever -- so my primary
> concern is that, as we add native compilation, we need to keep things
> mentally tractable.
>
> I have worked with many people who seem to be able to keep an inhuman
> number of names and relationships in their head at one time. I fear I am
> not such a person, so we will have to keep things extra-simple :)
>
> So what I would really like to see would be:
>
> * Ideally, a 4-word objcode representation that includes native
> code.
>
> * A well-defined convention for that native code. That's to say that
> the native code could come from JIT compilation, or from AOT
> compilation.
>
> * A uniform way to invoke native code from the VM, and VM code from
> native code -- *preserving tail calls*. This seems to require either
> trampolines within the VM or platform-specific tail-call assembly.
>
> * A uniform interface to create JIT code as needed, in the call
> instructions. i.e.
> if (SCM_UNLIKELY (SCM_NEEDS_JIT (proc)))
> scm_jit_x (proc);
> or something.
>
> We should be able to merge all of that into Guile before any JIT code
> goes in, and maybe even before 2.0 if the patches were small enough and
> came fast enough ;-) Then we could take our time experimenting on how
> best to do native compilation.
>
> So, to reiterate: *simple*, with a good *tail call* story. If we can
> find a solution that has those characteristics, fantastic :)
>
> Andy
> --
> http://wingolog.org/
>
next prev parent reply other threads:[~2010-11-28 20:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 4:29 A Working (but Minimal) JIT Noah Lavine
2010-10-22 21:46 ` Phil
2010-10-27 21:17 ` Ludovic Courtès
2010-10-27 21:10 ` Ludovic Courtès
2010-10-27 22:53 ` Noah Lavine
2010-11-02 22:51 ` Ludovic Courtès
2010-11-20 13:37 ` Andy Wingo
2010-11-28 20:56 ` Noah Lavine
2010-11-29 21:25 ` Andy Wingo
2010-12-02 3:58 ` Noah Lavine
2010-12-06 22:06 ` Andy Wingo
2010-12-06 22:53 ` Noah Lavine
2010-11-28 20:58 ` Noah Lavine [this message]
2010-11-28 22:36 ` Ludovic Courtès
2010-11-29 7:18 ` Ken Raeburn
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='AANLkTikXJPHzb7ugVXY7PsMEw4oyR6F9oUH3Ccv=KyrD@mail.gmail.com' \
--to=noah.b.lavine@gmail.com \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/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).