caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christian Lindig <lindig@cs.uni-sb.de>
To: Mark Shinwell <Mark.Shinwell@cl.cam.ac.uk>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] how to enlarge header of blocks?
Date: Thu, 1 Sep 2005 10:07:37 +0200	[thread overview]
Message-ID: <28b5733129446c3d12d090f5f66c1e3e@cs.uni-sb.de> (raw)
In-Reply-To: <20050830111624.GC5470@three-tuns.net>


On Aug 30, 2005, at 1:16 PM, Mark Shinwell wrote:

> If the extra field obeys the GC structure constraints (see the Caml
> documentation on interfacing to C) then you shouldn't have any
> problem...

Maybe we have different things in mind, so I'll elaborate my idea 
briefly and why it was too simple: I changed the allocation routine in 
the bytecode runtime to allocate one extra word where I intended to 
store some information as an Ocaml value. However, I overlooked that 
Array.length and String.length use the block size denoted by the header 
to determine the length. Hence, code looping over an array or string 
would run into my value - and crash. For example, here is the code for 
Array.get:

CAMLprim value caml_array_get_addr(value array, value index)
{
   long idx = Long_val(index);
   if (idx < 0 || idx >= Wosize_val(array)) caml_array_bound_error();
   return Field(array, idx);
}


To make this work I either must refrain from tucking an extra word to 
strings and arrays or change the implementations for the length 
functions and code that checks array and string bounds.

-- Christian


  reply	other threads:[~2005-09-01  8:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-26  8:10 Christian Lindig
2005-08-26 11:34 ` [Caml-list] " Mark Shinwell
2005-08-27 11:17   ` Christian Lindig
2005-08-30 11:16     ` Mark Shinwell
2005-09-01  8:07       ` Christian Lindig [this message]
2005-09-01 11:53         ` Mark Shinwell

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=28b5733129446c3d12d090f5f66c1e3e@cs.uni-sb.de \
    --to=lindig@cs.uni-sb.de \
    --cc=Mark.Shinwell@cl.cam.ac.uk \
    --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).