public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: "Madhavan T. Venkataraman" <madvenka@linux.microsoft.com>
Cc: libffi-discuss@sourceware.org
Subject: Re: [RFC PATCH v3 1/5] Libffi Static Trampolines
Date: Wed, 27 Jan 2021 17:15:50 -0500	[thread overview]
Message-ID: <xnpn1qgh61.fsf@greed.delorie.com> (raw)
In-Reply-To: <8b4d70a2-42a1-43a0-6a60-25576591f4e2@linux.microsoft.com> (madvenka@linux.microsoft.com)

"Madhavan T. Venkataraman" <madvenka@linux.microsoft.com> writes:
>>> +case "$target" in
>>> +     *-linux*)
>>> +       AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
>>> +                 [Define this if you want statically defined trampolines])
>>> +     ;;
>>> +esac
>> 
>> Ok.  Might want to conditional for the arches that are supported too.
>> 
>
> ok. I will add the arches although the code currently handles that by testing
> ffi_tramp_arch == NULL.

/me ponders...

Is the intent here that a Linux client has to check for static
trampolines in configure (i.e. it's on linux) but *also* check if it's
supported at runtime?  If we could minimize the number of checks, that
would help the developer.  If the API is always present (or always
hidden, so that the client need do nothing), that's best.

Ideally, the client would need do nothing regardless, but that only
works if the static trampoline functionality is 100% hidden.

> My intention is to allow applications and libraries that currently use dynamic code
> to use the libffi API to eliminate their dynamic code. The maintainers of these
> apps/libs would rewrite their dynamic code into static code. All they need is a
> way to pass data to their static code (that uses PC-relative access). The libffi
> API will let them do that.

Ok, as long as there's a use case.

Note that adding public APIs is MUCH easier than removing them later...

> My intention is to always have the API functions defined in the library. If
> FFI_EXEC_STATIC_TRAMP is defined, then, the API will supply static trampolines.
> Else, the stub API functions will return an error and the caller can fall back
> on his existing method if any.

Ok.  I guess that answers one of my earlier questions (above) ;-)

>>> @@ -943,12 +966,17 @@ void *
>>>  ffi_data_to_code_pointer (void *data)
>>>  {
>>>    msegmentptr seg = segment_holding (gm, data);
>>> +
>> 
>> Extraneous but ok.
>
> This is needed.

I meant the extra blank line ;-)

>>> +  if (table->nfree == gtramp.ntramp && gtramp.ntables > 1)
>> 
>> You can't compare these.  The first is a count of *trampolines* and the
>> second is a count of *tables*.
>> 
>
> There are two conditions here:
>
> If (table->nfree == gtramp.ntramp) is true, then all of the table's slots are free.

This reads as "If the number of trampolines equals the number of tables"
which are not comparable.  If you're doing some math magic hack here to
get the right answer, it *really* needs a big comment explaining how it
works.

>> tramp_table_del unlinks the table, but doesn't deallocate its
>> resources.  Are these resources lost/leaked?
>> 
>
> The table list contains tables that have free slots. If all slots of a table
> are allocated, the table is removed from the list. Its trampoline resources
> are held inside closures. When those closures are freed, the table will be back
> on the list. When the table gets back all of its trampolines, it will be freed
> along with all of its trampolines.

Ah, ok.


  reply	other threads:[~2021-01-27 22:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1ef5c7e1c9a6ebb140a476ba555ec955681f4fba>
2021-01-15 18:46 ` [RFC PATCH v3 0/5] " madvenka
2021-01-15 18:46   ` [RFC PATCH v3 1/5] " madvenka
2021-01-27  3:31     ` DJ Delorie
2021-01-27 21:51       ` Madhavan T. Venkataraman
2021-01-27 22:15         ` DJ Delorie [this message]
2021-01-27 22:43           ` Madhavan T. Venkataraman
2021-01-15 18:46   ` [RFC PATCH v3 2/5] x86: Support for " madvenka
2021-01-27  3:31     ` DJ Delorie
2021-01-28 21:59       ` Madhavan T. Venkataraman
2021-01-28 22:17         ` DJ Delorie
2021-01-28 23:25           ` Madhavan T. Venkataraman
2021-01-29  2:09             ` DJ Delorie
2021-01-29  2:38               ` Madhavan T. Venkataraman
2021-01-29  2:48                 ` DJ Delorie
2021-01-29  3:24                   ` Madhavan T. Venkataraman
2021-01-29  6:07                     ` DJ Delorie
2021-02-01 19:46                 ` DJ Delorie
2021-01-15 18:46   ` [RFC PATCH v3 3/5] i386: " madvenka
2021-01-15 18:46   ` [RFC PATCH v3 4/5] arm64: " madvenka
2021-01-15 18:46   ` [RFC PATCH v3 5/5] arm: " madvenka
2021-01-26 23:41   ` [RFC PATCH v3 0/5] Libffi " Anthony Green
2021-01-27 17:20     ` Madhavan T. Venkataraman
2021-01-27 18:00       ` Anthony Green
2021-01-27 19:45         ` Madhavan T. Venkataraman
2021-01-28 14:21           ` Anthony Green
2021-01-28 17:01             ` Madhavan T. Venkataraman
2021-02-05 18:20               ` Madhavan T. Venkataraman
2021-02-05 18:46                 ` Anthony Green
2021-02-05 19:38                   ` Madhavan T. Venkataraman
2021-02-07 16:09                     ` Madhavan T. Venkataraman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xnpn1qgh61.fsf@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=libffi-discuss@sourceware.org \
    --cc=madvenka@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).