caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@oefai.at>
To: "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] A few questions regarding the compiler
Date: Wed, 14 Nov 2001 10:52:57 +0100	[thread overview]
Message-ID: <20011114105257.B17604@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <slrn9v3not.28d.qrczak@qrnik.zagroda>; from qrczak@knm.org.pl on Wed, Nov 14, 2001 at 03:03:57 +0000

On Wed, 14 Nov 2001, Marcin 'Qrczak' Kowalczyk wrote:
> I guess that it's fine to initialize an array of non-floats with
> 'Obj.magic 0' even if the type doesn't have nullary constructors,
> provided that I overwrite elements with valid objects before use?

Yes, this is safe for non-float arrays. The GC will only interpret some
array element as a pointer to follow if it is not tagged as integer
(or nullary constructor, which is the same representation). I abuse this
"feature" in my "Res"-module to implement automatically resizing arrays.

> I don't always have a proper element at hand. Is it true that the
> Array module cares to always find a valid element for initialization
> only because of float arrays?

There is no function that allows you to create an array without passing
an initial element in the Array-module. It would be nice if there
were a function that allows one to create uninitialized, unboxed float
arrays. This is easy to implement and could be useful for efficiency
purposes in some occasions. It's, of course, not possible for other
kinds of arrays, because the memory region might contain things that
look like a pointer to the GC.

Btw., wouldn't it be possible (or is this actually implemented - haven't
looked) that the GC allocates arrays of integers always within the same
region of memory? Then it could reuse this region as a pool for creating
uninitialized integer arrays. Only if there is not enough memory, more
would have to be allocated and initialized.

> Why are small arrays and large arrays treated differently?

I think this is part of the GC-strategy to gain efficiency. The heuristics
is that large arrays (or other large chunks of memory) are not likely
to be short-lived.

I hope my explanations were not too far from the truth... ;)

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-11-14 13:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-29 15:43 Marcin 'Qrczak' Kowalczyk
2001-11-11 17:38 ` Xavier Leroy
     [not found] ` <9smdf7$511$1@qrnik.zagroda>
2001-11-11 21:54   ` Marcin 'Qrczak' Kowalczyk
2001-11-11 22:09     ` Patrick M Doane
2001-11-13 20:36     ` Xavier Leroy
     [not found]     ` <9ssfsl$fa4$1@qrnik.zagroda>
2001-11-14  3:03       ` Marcin 'Qrczak' Kowalczyk
2001-11-14  9:52         ` Markus Mottl [this message]
2001-11-14 13:20         ` David Mentre
     [not found]         ` <9sttmn$kei$1@qrnik.zagroda>
2001-11-14 14:47           ` Marcin 'Qrczak' Kowalczyk
2001-11-14 16:45             ` Marcin 'Qrczak' Kowalczyk

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=20011114105257.B17604@fichte.ai.univie.ac.at \
    --to=markus@oefai.at \
    --cc=caml-list@inria.fr \
    --cc=qrczak@knm.org.pl \
    /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).