From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 78655BC6C for ; Mon, 4 Feb 2008 16:20:37 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAIW7pkdQDPIagWdsb2JhbACQKQEBCQQGBwgTBZpy X-IronPort-AV: E=Sophos;i="4.25,303,1199660400"; d="scan'208";a="22161000" Received: from smtp20.orange.fr ([80.12.242.26]) by mail4-smtp-sop.national.inria.fr with ESMTP; 04 Feb 2008 16:20:37 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2027.orange.fr (SMTP Server) with ESMTP id 146A71C04FFC for ; Mon, 4 Feb 2008 16:20:36 +0100 (CET) Received: from [192.168.1.59] (APuteaux-154-1-58-91.w81-249.abo.wanadoo.fr [81.249.65.91]) by mwinf2027.orange.fr (SMTP Server) with ESMTP id AF08C1C056F9; Mon, 4 Feb 2008 16:20:34 +0100 (CET) X-ME-UUID: 20080204152034717.AF08C1C056F9@mwinf2027.orange.fr Message-ID: <47A72D43.30204@frisch.fr> Date: Mon, 04 Feb 2008 16:20:35 +0100 From: Alain Frisch User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Jon Harrop Cc: caml-list Subject: Re: [Caml-list] Using OCaml's run-time from LLVM-generated native code References: <200802012124.56835.jon@ffconsultancy.com> <200802041032.05929.jon@ffconsultancy.com> <47A6F2E5.2000604@frisch.fr> <200802041336.22550.jon@ffconsultancy.com> In-Reply-To: <200802041336.22550.jon@ffconsultancy.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 ocaml's:01 run-time:01 afaict:01 ocamlopt:01 camlparam:01 camlreturn:01 val:01 wrote:01 wrote:01 stack:01 stack:01 caml-list:01 int:01 Jon Harrop wrote: > On Monday 04 February 2008 11:11:33 Alain Frisch wrote: >> Jon Harrop wrote: >>> Despite the availability of that code it seems that few people can use it >>> correctly and I am one of them. >> What part of memory.h do you fail to understand? > > That file doesn't even mention the stack walker AFAICT. Nevertheless, the file contains all the info you need to produce GC-safe C code. If you want efficient GC-safe code, you need to understand how ocamlopt records information about stack frames. It is probably impossible to do it with pure portable C code. For LLVM-generated code, you should be able to use the GC infrastructure improved by Gordon. > Perhaps this does: > > int apply(int n) { > CAMLparam0(); > CAMLlocal2(nv, fibn); > nv = copy_int64(n); > fibn = fib(nv); > caml_gc_full_major(0); > CAMLreturn(Int64_val(fib(nv))); > } CAMLreturnT would be better. -- Alain