Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Using OCaml's run-time from LLVM-generated native code
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