caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] calling native code from bytecode?
Date: Wed, 08 Aug 2001 11:34:25 -0700	[thread overview]
Message-ID: <4.3.2.7.2.20010808105617.03b61390@shell16.ba.best.com> (raw)
In-Reply-To: <20010808104615.A3590@pauillac.inria.fr>


>To handle these differences, the runtime system comes in two variants
>(libcamlrun.a and libasmrun.a), with suitable #ifdefs, different
>definitions of some runtime functions, etc.

Oh.  Bummer.

> My advice is: don't do it.  If all you need is to have the
>efficiency of native code and the debugging comfort of bytecode, just
>compile all your sources twice, to native-code and to bytecode.

It's not quite that simple.  I'm working on a video game, which is by nature a realtime simulation, and its behavior changes depending on how long frames take to compute.  So, if I can't optimize enough stuff in the bytecode version to keep it playable, I'm just going to have to switch to native code and give up on bytecode completely (giving up "debugging comfort" and the toplevel, which I've grown fond of).

The shame is that a few specific pieces of leaf code are taking the time, and since linking native code into bytecode is turning out not to be possible, they're going to force my entire project into native code.

If I get a complex bug that won't reproduce in the bytecode version because of the time-dependence and feedback, then I'm screwed.  Well, I'd be stuck debugging with printfs, which is actually what I'm doing now (plus #trace in the toplevel, which is very useful), but I was planning on getting the bytecode debugger to work under Windows as soon as I ran into something truly heinous.  That won't be an option if I have to switch to native code.

It seems like the right thing to do from an engineering standpoint is to rewrite these leaf functions in C because that will allow me to continue with bytecode and native code (plus I can debug the C trivially).  However, my entire "experiment" was to see if I could develop a commercial quality game in ocaml without dropping to C very often.  I find it slightly ironic that ocaml's environment is in some ways more friendly towards C than other ocaml code.

It does sound like I'm the only person who's ever requested this, so maybe others don't run into this problem.  

If I am actually insane enough to try to make this work correctly (fixing the closure problem and the runtime problem), would this be something that could make it into the distribution?

Chris


-------------------
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-08-08 18:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-01 23:45 Chris Hecker
2001-08-03 12:03 ` Xavier Leroy
2001-08-03 14:31   ` Chris Hecker
2001-08-08  8:46     ` Xavier Leroy
2001-08-08 18:34       ` Chris Hecker [this message]
2001-08-09  6:57       ` Florian Hars
2001-08-14 13:34       ` Fabrice Le Fessant

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=4.3.2.7.2.20010808105617.03b61390@shell16.ba.best.com \
    --to=checker@d6.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).