caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ygrek <ygrekheretix@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Non-toplevel C functions using OCaml values
Date: Mon, 9 Jan 2012 11:23:24 +0200	[thread overview]
Message-ID: <20120109112324.d553ddd2.ygrekheretix@gmail.com> (raw)
In-Reply-To: <1326094398.2242.26.camel@samsung>

On Mon, 09 Jan 2012 08:33:18 +0100
Gerd Stolpmann <info@gerd-stolpmann.de> wrote:

> If you are looking for more optimizations, you can also replace the
> first Store_field with Field(newblock,0) = Val_int(h). Store_field is
> slightly more expensive, because there is a test whether you create a
> pointer from the old generation to the young generation, which is only
> allowed if this pointer is added to a special list. You only assign an
> int here, so it cannot be a pointer.
> 
> For the second assignment you need Store_field because there is no
> (official) guarantee that newblock is created in the young generation
> (although I don't see a reason why newblock could ever reside in the old
> generation, but it's really dependent on implementation details in the
> GC).

AFAIK the better (and described in manual) way is to use caml_alloc_small and
direct assignment into fields in this case.

To answer OP's question: CAML* macros are used to live in harmony with GC, and GC
manages ocaml heap. So one should always use these macros when (and by the
same rules) the code touches values in ocaml heap - no matter whether the function
is called directly from ocaml side or not.

-- 
 ygrek
 http://ygrek.org.ua

      reply	other threads:[~2012-01-09  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09  2:35 Harrison, John R
2012-01-09  7:33 ` Gerd Stolpmann
2012-01-09  9:23   ` ygrek [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

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

  git send-email \
    --in-reply-to=20120109112324.d553ddd2.ygrekheretix@gmail.com \
    --to=ygrekheretix@gmail.com \
    --cc=caml-list@inria.fr \
    /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).