emacs-devel
[Top][All Lists]
Advanced

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

Re: Emacs Lisp JIT Compiler


From: Tom Tromey
Subject: Re: Emacs Lisp JIT Compiler
Date: Wed, 22 Aug 2018 18:47:23 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux)

>>>>> "Tom" == Tom Tromey <address@hidden> writes:

Tom> Now, one thing that is portable is compiling Emacs Lisp code to C.  For
Tom> example, it would be easy to compile all the bytecode that is dumped
Tom> into Emacs.  The drawback is that this is just a fraction of what users
Tom> use; and would probably not show major benefits.  But, maybe it would
Tom> help some.  And, it would certainly allow some existing C code (looking
Tom> at you, widget-put) to be moved to Lisp, which seems worthwhile to me.

I wrote a bytecode->C compiler to see what this would look like.  It is
set up to walk the obarray and compile every lexically-bound bytecode
function that it finds there.

The resulting .o files are roughly the same size as the rest of the
Emacs .o files.  So, maybe that's a bit too big.  One idea would be to
segregate the code that is to be compiled.  This would allow rewriting
some of the C code into Lisp at least.

Another issue is that runtime linking -- that is, associating the
compiled code with the bytecode -- is hard.  My current approach (which
isn't fully hooked up yet) is to use the doc string index as a key.
However, this is not fantastic because it means that undocumented
functions can't be compiled.

Runtime linking is needed because of two issues; otherwise the compiler
could just emit DEFUNs.  One, I didn't want to deal with compiling
complex lisp constants to C.  Doing this properly would mean introducing
initialization code.  Two, I think the DEFUN approach wouldn't work for
closures.

Perhaps if the segregation approach were taken, there could just be some
rules against closures and complex constants, and the compiler could
error if they were introduced.

Tom



reply via email to

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