guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Native code generation and gcc


From: Lluís Vilanova
Subject: Re: Native code generation and gcc
Date: Mon, 05 Dec 2016 17:18:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Mikael Djurfeldt writes:

> [I apologize beforehand for being completely out of context.]
> Are there fundamental reasons for not re-using the gcc backends for native 
> code generation? I'm thinking of the (im?)possibility to convert the cps to 
> some of the intermediate languages of gcc.

> If it wouldn't cause bad constraints the obvious gain is the many targets 
> (for free), the gcc optimizations, not having to maintain backends and free 
> future development.

> Of course, there's the practical problem that gcc needs to be adapted for 
> this kind of use---but shouldn't it be adapted that way anyway? :)

> Just an (old) idea...

> Mikael

Guile 2.1 has a register-base bytecode VM that makes using a code generation
library like GNU lightning [1] a convenient alternative. In fact, that's the
library used by nash [2] (an experimental Guile VM that generates native code
for hot routines). You also have the experimental GCC JIT interface [3] to
achieve similar goals (available upstream since GCC 5, I think).

IMO, if guile wants to go the tracing JIT way (like nash), it should store the
CPS representation of routines to be able to iteratively apply more heavy-weight
optimizations as the routine becomes hotter (called more frequently).

For example, you could start with the current state. If the routine is called
many times with the same argument types, you can create a version specialized
for these types, opening more unboxing possibilities (the routine entry point
would then have to be a version dispatcher). If a routine version later becomes
hotter, re-compile that version into native code.

One open question is whether the VM needs to be changed to count routine
"hotness" efficiently (as in nash), or if a simple routine prelude inserted by
guile's compiler tower could do that almost as efficiently (the bytecode ISA
might need new atomic integer operations to cope with routine tracing in a
multi-threaded app).

Also, these all are no small tasks.

[1] https://www.gnu.org/software/lightning/
[2] https://github.com/8c6794b6/guile-tjit
[3] https://gcc.gnu.org/wiki/JIT

Cheers,
  Lluis



reply via email to

[Prev in Thread] Current Thread [Next in Thread]