From: Andy Wingo <wingo@igalia.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: Guile Devel <guile-devel@gnu.org>
Subject: Re: For a cheaper ‘bytevector->pointer’
Date: Mon, 25 Nov 2019 10:05:12 +0100 [thread overview]
Message-ID: <875zj81g3b.fsf@igalia.com> (raw)
In-Reply-To: <87zhglzgue.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 24 Nov 2019 11:52:41 +0100")
On Sun 24 Nov 2019 11:52, Ludovic Courtès <ludo@gnu.org> writes:
> A few days ago David was explaining on #guile how ‘bytevector->pointer’
> was generating too much garbage for his use case. An idea we came up
> with was to embed the pointer object in the bytevector.
>
> The patch below does that but it leads to segfaults because I’m guessing
> there’s generated bytecode somewhere that still uses the wrong offset; I
> adjusted code that emits ‘pointer-ref/immediate’, what else did I
> miss?
The compiler :) Bytevector literals are stored statically in the .go
files, so the assembler would need to change to emit the new layout.
Also, compiled access to bytevectors; see prepare-bytevector-access in
(language tree-il compile-cps).
> Also, since we disable internal pointers, we’d need to register an
> additional displacement, and I’m not sure if this is a good idea.
>
> Thoughts?
Honestly I would prefer not to do this. If I understand correctly, the
problem is in FFI calls -- you have a bytevector and you want to pass it
as a pointer. In that case the "right" optimization is to avoid the
scm_tc7_pointer altogether and instead having an unboxed raw pointer.
The idioms used in FFI are local enough that a compiler can do this.
More broadly -- the current FFI is an interpreter but it should be a
compiler. When a call happens, the code interprets the description of
the ABI. Instead, pointer->function should ideally *compile* a
trampoline. In an ideal world this compilation can happen
ahead-of-time, when the .go file is compiled.
In the short term, what about allowing bytevectors as arguments
whereever a pointer is allowed? Perhaps it's bad to expand the domain
of these functions but it may be the right trade-off.
Andy
next prev parent reply other threads:[~2019-11-25 9:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-24 10:52 For a cheaper ‘bytevector->pointer’ Ludovic Courtès
2019-11-25 6:26 ` Amirouche Boubekki
2019-11-25 9:05 ` Andy Wingo [this message]
2019-11-25 22:03 ` Ludovic Courtès
2019-11-26 10:25 ` Andy Wingo
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875zj81g3b.fsf@igalia.com \
--to=wingo@igalia.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/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).