[Top][All Lists]

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

Re: [Lightning] Position independence of GNU lightning generated code

From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Position independence of GNU lightning generated code
Date: Wed, 20 Apr 2016 20:54:16 -0300

2016-04-19 4:33 GMT-03:00 Marc Nieper-Wißkirchen <address@hidden>:
> Hi,


> is the code emitted by `jit_emit` guaranteed to be position independent? In
> other words, if I use an alternate code buffer as in 7.2 of the manual and
> later move that code buffer to a different address (say, by a copying
> garbage collector to reduce heap fragmentation), will my code still be
> working?

  It is very unlikely to work as most non conditional jumps are implemented
as a jump to an absolute address. On all ports conditional jumps are
implemented as relative jumps, but they may vary in maximum jump
distance, and generate an assertion if the target is too far.

  Note that code buffers are allocated with mmap, should be at least one
page, and are mprotect'ed readonly and executable. So, if you allocate
your own code buffer, it should be used only by a very small trampoline,
and there may be issues with cache coherence in some architectures.

  Sure there are plans to extend this, but currently the only way to create
relocatable code is to create your own relocation code, most likely by
using a global vector of pointers.

> Marc


reply via email to

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