libjit
[Top][All Lists]
Advanced

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

Re: [Libjit] Function recompilation and deletion


From: Tom Tromey
Subject: Re: [Libjit] Function recompilation and deletion
Date: Wed, 14 Feb 2018 22:57:54 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

>>>>> "Aleksey" == Aleksey Demakov <address@hidden> writes:

Aleksey> Yes, the memory management mechanism in libjit is, in principe,
Aleksey> intended exactly for this, however nobody tried it yet in practice.

So maybe I could rename and expose _jit_function_destroy and that would
work ok?

Aleksey> It is hard to do it in generic way as it would be required to protect
Aleksey> against concurrent execution of the code that is being freed. But if
Aleksey> your particular runtime have just one thread or have some sort of
Aleksey> control over threads (can stop them and prevent entering a given
Aleksey> function) then it should be doable.

Yeah, I think this should not be a problem in Emacs.  When the object
wrapping a function is GC'd, we know that the function isn't running
anywhere.

Aleksey> Another thing is that after recompiling a function it is required to
Aleksey> redirect all old call sites to it. It could be done trivially if you
Aleksey> used indirect calls in the first place. Then it would be required to
Aleksey> change just one memory location that contains the function address.

I'd considered this but was hoping for something better.  But maybe this
is good enough... certainly it would be better than what is currently
done.

Aleksey> So indirect calls seem to be the way to go for recompilation
Aleksey> anyway.

How do I actually recompile though?  After reading some code I wonder if
it would work to call jit_function_abandon, and then just start adding
new IR to the function again.  Is that how it is supposed to work?  This
is not really mentioned in the documentation, so I guess if it is, I
could write a patch to the docs.

Tom



reply via email to

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