Re: FFI callback is broken in last git version

Kostirya <[email protected]> Thu, 29 Sep 2016 10:53:09 +0300
Newsgroups gmane.comp.lang.ml.mlton.user
Message-ID <CAG+QnTcY7DUq8oC+ikS_P11DGWktbFvBK5W3dRU2V1sphEi1Yw@mail.gmail.com>
By the way, what does "reentrant" do?
I guess it turns GC, among other things. At least this seemed to me when I
was exploring rare segmentation faults with MLton 20130715.

2016-09-28 19:06 GMT+03:00 Matthew Fluet <[email protected]>:

> On Wed, Sep 28, 2016 at 10:56 AM, Kostirya <[email protected]> wrote:
> > Wow. Speed callback increased 6 times (compared with MLton 20130715)!
>
> Interesting; I don't believe that anything special changed with
> respect to callbacks themselves, but if you have an FFI heavy
> application, you may benefit from the fact that non-"reentrant"
> _import-ed functions have a little lower overhead (compared to the
> default behavior in MLton 20130715).
>
>
> > 2016-09-28 11:36 GMT+03:00 Florian Weimer <[email protected]>:
> >>
> >> > I updated MLton from git repository and detect what FFI callback is
> >> > broken.
> >>
> >> I think it was merely changed in a backwards-incompatible way.
> >>
> >> >> mlton
> >> > MLton gd201ca9-dirty (built Tue Sep 27 15:21:50 EEST 2016 on thinkpad)
> >> >
> >> >
> >> >> cat callback.c
> >> > void foo ( int n, void (*fn) (int) ) {
> >> >         int i = 1;
> >> >         while (n--) {
> >> >                 (*fn)(i++);
> >> >         }
> >> >         return;
> >> > }
> >> >
> >> >
> >> >> cat cb-mlton.sml
> >> > val foo = _import "foo" public: int * MLton.Pointer.t -> unit;
> >> > val () = (_export "cb" : (int -> unit) -> unit;) (fn v => print
> >> > ((Int.toString v) ^ "\n"))
> >> > val cb = _address "cb" public: MLton.Pointer.t;
> >> > val _ = foo(3, cb)
> >>
> >> You need to import foo with the “reentrant“ attribute, like this
> >> (untested):
> >>
> >> val foo = _import "foo" public reentrant: int * MLton.Pointer.t -> unit;
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "MLton-user" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to [email protected].
> >>
> >>
> >>
> >> ------------------------------------------------------------
> ------------------
> >> _______________________________________________
> >> MLton-user mailing list
> >> [email protected]; [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/mlton-user
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "MLton-user" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> >
> > ------------------------------------------------------------
> ------------------
> >
> > _______________________________________________
> > MLton-user mailing list
> > [email protected]; [email protected]
> > https://lists.sourceforge.net/lists/listinfo/mlton-user
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "MLton-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>
>
> ------------------------------------------------------------
> ------------------
> _______________________________________________
> MLton-user mailing list
> [email protected]; [email protected]
> https://lists.sourceforge.net/lists/listinfo/mlton-user
>

-- 
You received this message because you are subscribed to the Google Groups "MLton-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

------------------------------------------------------------------------------

_______________________________________________
MLton-user mailing list
[email protected]; [email protected]
https://lists.sourceforge.net/lists/listinfo/mlton-user