unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
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: Tue, 26 Nov 2019 11:25:41 +0100	[thread overview]
Message-ID: <87v9r7rl22.fsf@igalia.com> (raw)
In-Reply-To: <87o8wzvcj4.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 25 Nov 2019 23:03:59 +0100")

Hi :)

On Mon 25 Nov 2019 23:03, Ludovic Courtès <ludo@gnu.org> writes:

> Andy Wingo <wingo@igalia.com> skribis:
>
>> 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.
>
> I agree!  I have a patch from the 2.0 era (attached), but it doesn’t
> work because all the tc3s are already taken.  I don’t think this has
> changed but I could well be missing something about the tag space.
> WDYT?

I was actually thinking about raw pointer values -- i.e. not
immediate-tagged values.  If you think about it these values are
generally live only between the bytevector->pointer and the FFI call --
the compiler is capable of safely unboxing values in spaces like that.
But this would work better with a more compiler-focussed FFI than with
the current "interpreted" FFI.

But, immediate pointers would be nice too; nicer, in some ways.  See
also Mark's fixrat work.

>> 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.
>
> So in practice, every time there’s '* in the FFI, it’d accept a
> bytevector, right?

That was the idea :)

> I would prefer immediate pointers if that’s possible, and then one of
> the two other solutions.

In that case I am not sure what a good solution is.  Having to add an
additional 2-word internal displacement is a bit unfortunate, if that's
the case!

Andy



      reply	other threads:[~2019-11-26 10:25 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
2019-11-25 22:03   ` Ludovic Courtès
2019-11-26 10:25     ` Andy Wingo [this message]

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=87v9r7rl22.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).