From: John Prevost <prevost@maya.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: Internals details for cmmgen.ml
Date: 17 Dec 1999 19:51:02 -0500 [thread overview]
Message-ID: <87d7s5rs09.fsf@isil.maya.com> (raw)
In-Reply-To: Xavier Leroy's message of "Sat, 11 Dec 1999 19:09:08 +0100"
Xavier Leroy <Xavier.Leroy@inria.fr> writes:
> Using a "checkbound" is perhaps the simplest solution. Otherwise,
> some system-wide exceptions such as Invalid_argument are assigned
> global symbols and you don't need to guess their integer index inside
> their defining module: just emit the C-- code corresponding to
>
> (raise (symbol "Invalid_argument") (string "my message"))
I'll try this.
> If you're really into high-performance stuff, you could fold the
> permission check and the bounds check in one "checkbound" instruction.
> Just arrange the "write enable" flag to be (the Caml integer) 0 if
> write is allowed, and -1 if it is not. Then, generate something like
>
> (checkbound (or index (write_enable_flag region) (size region)))
I don't think this is necessary--especially since both reading and
writing are things that could fail (so I need more than one bit).
When you're going for extreme speed, you'll probably use the unsafe
versions.
(How does -unsafe work, by the way? Does it make the C-- "checkbound"
stuff work differently?)
> Although hacking cmmgen.ml is fun, you could get a more portable
> implementation by writing it in ML using unsafe string accesses.
> Those will happily work on any char *, not necessarily on well-formed
> Caml strings. Something like:
>
> external mmap : ... -> string
> type t = { data: string; length: int }
>
> let read_char reg idx =
> if idx < 0 || idx >= reg.length
> then raise (Invalid_argument "Region.read_char")
> else String.unsafe_get reg.data idx
>
> It will be a bit slower, but maybe not too much.
Hmm. What do you mean by "a more portable implementation"? One which
doesn't require compiler modifications, or one which works with
bytecode? I believe that with bytecode, the C functions are
sufficient.
As for unsafe string access: but doesn't the pointer point to an
O'Caml block, which includes a tag and length information?
John.
next prev parent reply other threads:[~1999-12-18 17:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-12-10 8:12 John Prevost
1999-12-11 18:09 ` Xavier Leroy
1999-12-18 0:51 ` John Prevost [this message]
1999-12-18 18:56 ` Jerome Vouillon
1999-12-23 5:26 ` John Prevost
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=87d7s5rs09.fsf@isil.maya.com \
--to=prevost@maya.com \
--cc=Xavier.Leroy@inria.fr \
--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).