From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Chris Hecker <checker@d6.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] calling native code from bytecode?
Date: Fri, 3 Aug 2001 14:03:51 +0200 [thread overview]
Message-ID: <20010803140351.A3307@pauillac.inria.fr> (raw)
In-Reply-To: <200108012345.QAA29668@smtp3-cm.mail.eni.net>; from checker@d6.com on Wed, Aug 01, 2001 at 04:45:40PM -0700
> Is there any way to compile part of a project in bytecode and another
> part with the native compiler and link them? It seems odd that you
> can call C from bytecode but not other caml code. The gc and
> everything is the same between the asm and bytecode runtimes, no? Are
> datastructures in memory (except code, of course) compatible?
Yes, they are compatible, except function closures, which contain
native code pointers for ocamlopt and byte-code pointers for ocamlc.
But that's where the problem is for mixed-mode execution: treating
pointers to bytecode and pointers to native-code differently.
One solution would be to have two code pointers per closure, one
bytecode and one native-code. For a bytecode closure, the native-code
pointer would point to the bytecode interpreter. For a native-code
closure, the bytecode pointer would point to a special "switch mode"
instruction of the virtual machine. But that's far from easy to
implement.
Another approach is Fabrice Le Fessant's asmdynlink library, which
basically is a bytecode interpreter written in Caml and compiled with
ocamlopt. This gives native-code programs the ability to execute
bytecode, albeit at a fairly large cost in execution speed.
> Basically, I've got some numerical code that I'd like to compile to
> native code for performance, but I'd like to keep most of the
> non-performance stuff in bytecode so I can use the toplevel and
> whatnot. I suppose I could do some sort of heinous bytecode -> C ->
> native code shim
Besides problems with potential callbacks from native-code to
bytecode, there are also (non-essential, but intricate) GC issues that
would come in the way.
> Obviously, the holy grail would be complete intermingling of bytecode
> and native code, and the linker just figures it out and does the right
> thing. That would rock. But, I'd settle for bytecode -> native calls
> only at this point.
> Thoughts?
Nothing is impossible, but I shudder at the idea of implementing all
this.
- Xavier Leroy
-------------------
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
next prev parent reply other threads:[~2001-08-03 12:03 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 [this message]
2001-08-03 14:31 ` Chris Hecker
2001-08-08 8:46 ` Xavier Leroy
2001-08-08 18:34 ` Chris Hecker
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=20010803140351.A3307@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=checker@d6.com \
/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