[Top][All Lists]

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

[Libjit] Function recompilation and deletion

From: Tom Tromey
Subject: [Libjit] Function recompilation and deletion
Date: Tue, 13 Feb 2018 16:51:55 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)


Thanks to libjit, I was able to write a JIT compiler for Emacs Lisp.
However, while working on this I ran into a few libjit issues that are
somewhat related (I have at least one unrelated one, too, but I'll send
that in a new thread).

One of the problems is that I didn't see a way to free a single
function.  In Emacs, this may be needed when a function is redefined: if
the old definition is garbage collected, then the JIT-compiled function
should be freed as well.

One way to accomplish this would be to allocate each function in its own
jit_context_t.  However, that seemed expensive to me.  I didn't look
into the memory management code yet -- would it be difficult to
implement per-function freeing?

The next problem is that I'd like to be able to selectively recompile
functions.  I noticed jit_function_set_recompilable and friends -- but I
think these just direct libjit to recompile a function at some new
optimization level.  Instead I'd like to be able to fully replace the IR
for a function.

This seemed maybe related to the deletion issue, to me, because one
aspect of it is freeing the old function body...

There are two motivations for wanting to be able to recompile.  One is
to possibly supporting inlining at hot spots.  Another is that in Emacs
Lisp, the user can redefine any function at any time -- and one possible
approach to supporting a performant calling convention would be to
recompile callers when a callee changes.

Any thoughts on this?  Or any pre-existing work?

Also, is there a bug tracker somewhere?


reply via email to

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