caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] When to (not) use -no-naked-pointers?
@ 2015-05-25  6:25 Jez
  2015-05-25 21:49 ` Fabrice Le Fessant
  0 siblings, 1 reply; 5+ messages in thread
From: Jez @ 2015-05-25  6:25 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 424 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] When to (not) use -no-naked-pointers?
  2015-05-25  6:25 [Caml-list] When to (not) use -no-naked-pointers? Jez
@ 2015-05-25 21:49 ` Fabrice Le Fessant
  2015-05-26 15:42   ` Mark Shinwell
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Le Fessant @ 2015-05-25 21:49 UTC (permalink / raw)
  To: Jez; +Cc: Ocaml Mailing List

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] When to (not) use -no-naked-pointers?
  2015-05-25 21:49 ` Fabrice Le Fessant
@ 2015-05-26 15:42   ` Mark Shinwell
  2015-05-26 17:21     ` ygrek
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Shinwell @ 2015-05-26 15:42 UTC (permalink / raw)
  To: Fabrice Le Fessant; +Cc: Jez, Ocaml Mailing List

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] When to (not) use -no-naked-pointers?
  2015-05-26 15:42   ` Mark Shinwell
@ 2015-05-26 17:21     ` ygrek
  2015-07-05  2:40       ` ygrek
  0 siblings, 1 reply; 5+ messages in thread
From: ygrek @ 2015-05-26 17:21 UTC (permalink / raw)
  Cc: caml-list

On Tue, 26 May 2015 16:42:23 +0100
Mark Shinwell <mshinwell@janestreet.com> wrote:

> 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.

Hi,

 I wonder if there is a C define in caml runtime headers to test for this configuration feature?
 Because naturally the bindings author knows whether his code is compatible with this mode or not
 and could assert that during the build.. 

-- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] When to (not) use -no-naked-pointers?
  2015-05-26 17:21     ` ygrek
@ 2015-07-05  2:40       ` ygrek
  0 siblings, 0 replies; 5+ messages in thread
From: ygrek @ 2015-07-05  2:40 UTC (permalink / raw)
  Cc: caml-list

On Tue, 26 May 2015 10:21:46 -0700
ygrek <ygrek@autistici.org> wrote:

>  I wonder if there is a C define in caml runtime headers to test for this configuration feature?
>  Because naturally the bindings author knows whether his code is compatible with this mode or not
>  and could assert that during the build.. 

Answering my own question, NO_NAKED_POINTERS will be defined in config.h if this feature is enabled.

-- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-05  2:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-25  6:25 [Caml-list] When to (not) use -no-naked-pointers? Jez
2015-05-25 21:49 ` Fabrice Le Fessant
2015-05-26 15:42   ` Mark Shinwell
2015-05-26 17:21     ` ygrek
2015-07-05  2:40       ` ygrek

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).