caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mark Shinwell <mshinwell@janestreet.com>
To: Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
Cc: Jez <jezreel@gmail.com>, Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] When to (not) use -no-naked-pointers?
Date: Tue, 26 May 2015 16:42:23 +0100	[thread overview]
Message-ID: <CAM3Ki774wFiGHY2k2JBmhbXeVOC41jo23BXWq86em2uKnfJw8Q@mail.gmail.com> (raw)
In-Reply-To: <CAHvkLrPehoTDNn6qS-iM-6gQupr3GheOiNgqErZTW_XLF8707A@mail.gmail.com>

A bit more detail following on from Fabrice's mail.  A "naked pointer"
is traditionally used to describe a non-immediate value that is
scanned by the GC and points outside the OCaml heap.  However, in the
context of the "-no-naked-pointers" configuration option, there is a
more specific meaning.  When the system is configured in this mode any
naked pointer (an undesirable thing in any case) must be
dereferenceable without a fault and point at a block that has the
basic structure of an OCaml value.  In particular, there must be a
valid header one word prior.  Such headers should be coloured black;
if they are in read-only memory, they must be coloured black.

These restrictions enable the page table test to be suppressed when
scanning all values except closures, which may improve performance
under high GC pressure.

As an aside, there is a bug in the debug runtime in the released
compiler system that causes an assertion to fail when
"-no-naked-pointers" was specified in conjunction with
"-runtime-variant d".  This will be fixed in 4.02.2.

Mark

On 25 May 2015 at 22:49, Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr> wrote:
> Hi,
>
>   Naked pointers only appear in C bindings when pointers to C
> structures are passed directly as OCaml values. Non-naked pointers are
> the ones which are hidden within either a custom block or a block with
> the "abstract" tag (Tag_abstract). It is normally easy to modify a
> binding to switch from naked-pointers to non-naked pointers (it could
> even be a configure script option of the binding). The only case where
> there is a (big) problem is when the binding is allocating OCaml
> values outside of the heap: it is the case for the "ancient" library,
> for example, that copies OCaml values outside of the heap to avoid
> garbage collections; it is also the case for some bindings that create
> OCaml string headers in front of C buffers, to be able to manipulate
> them directly in OCaml (I did that once to share OCaml strings between
> processes, using shared memory).
>
> --Fabrice
> INRIA &OCamlPro
>
>
> On Mon, May 25, 2015 at 8:25 AM, Jez <jezreel@gmail.com> wrote:
>> Hi,
>>
>> I noticed that 4.02 now has the no-naked-pointers option. I'd like to better
>> understand when I shouldn't use it -- i.e. what kinds of operations create
>> naked pointers? I suppose that these pointers can only be generated by C
>> code; an example of when their use may arise would be nice :)
>>
>> Jez
>
>
>
> --
> Fabrice LE FESSANT
> Chercheur en Informatique
> INRIA Paris Rocquencourt -- OCamlPro
> Programming Languages and Distributed Systems
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

  reply	other threads:[~2015-05-26 15:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25  6:25 Jez
2015-05-25 21:49 ` Fabrice Le Fessant
2015-05-26 15:42   ` Mark Shinwell [this message]
2015-05-26 17:21     ` ygrek
2015-07-05  2:40       ` ygrek

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=CAM3Ki774wFiGHY2k2JBmhbXeVOC41jo23BXWq86em2uKnfJw8Q@mail.gmail.com \
    --to=mshinwell@janestreet.com \
    --cc=Fabrice.Le_fessant@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jezreel@gmail.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 NNTP newsgroup(s).