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.0 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 67ED4BC6C for ; Mon, 4 Feb 2008 14:41:01 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq4HAPakpkfUnw7VdWdsb2JhbACCNo1mDQEKAggPEweaKg X-IronPort-AV: E=Sophos;i="4.25,302,1199660400"; d="scan'208";a="6854509" Received: from ptb-relay02.plus.net ([212.159.14.213]) by mail2-smtp-roc.national.inria.fr with ESMTP; 04 Feb 2008 14:41:01 +0100 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay02.plus.net with esmtp (Exim) id 1JM1ZE-0003PU-8S; Mon, 04 Feb 2008 13:41:00 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: Alain Frisch Subject: Re: [Caml-list] Using OCaml's run-time from LLVM-generated native code Date: Mon, 4 Feb 2008 13:36:22 +0000 User-Agent: KMail/1.9.7 Cc: caml-list References: <200802012124.56835.jon@ffconsultancy.com> <200802041032.05929.jon@ffconsultancy.com> <47A6F2E5.2000604@frisch.fr> In-Reply-To: <47A6F2E5.2000604@frisch.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802041336.22550.jon@ffconsultancy.com> X-Plusnet-Relay: 6d8ac4054df7ed5ca74e1fbaa730fdc4 X-Spam: no; 0.00; ocaml's:01 run-time:01 frisch:01 afaict:01 val:01 camlparam:01 camlreturn:01 val:01 frog:98 wrote:01 wrote:01 stack:01 caml-list:01 int:01 int:01 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. > > int apply(int n) { > > CAMLlocal2(nv, fibn); > > nv = copy_int64(n); > > fibn = fib(nv); > > caml_gc_full_major(0); > > return Int64_val(fib(nv)); > > } > > > > Is that correct code? > > No, this function does not follow the rules of Section 18.5.1. 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))); } Is that correct? Next, this C code is 4x slower than the ocamlopt-generated equivalent. What can be done to improve its performance without leaving C? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e