Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Using OCaml's run-time from LLVM-generated native code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-05 (23:09)
From: Florent Monnier <fmonnier@l...>
Subject: Re: [Caml-list] Using OCaml's run-time from LLVM-generated native code

Jon Harrop wrote:
> 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?

I don't know if it is a typo from you, or if it is me that don't understand 
the code, but it seems that fib(nv) is computed twice.
Shouldn't the second one be replaced by fibn, the result of the first one?