[erlang-questions] NIF + HiPE - can it works together?

Mikael Pettersson mikpe@REDACTED
Wed Jun 8 17:08:58 CEST 2011


On Wed, 8 Jun 2011 15:55:35 +0200, Sverker Eriksson <sverker@REDACTED> wrote:
> I don't know if it has been stated, but HiPE and NIFs do not play nice=20
> together *within the same module*.
> Using HiPE and NIFs on different modules within the same VM will=20
> hopefully work fine.
> 
> 
> There seem to be a number of problems here.
> 
> 1. erlang:load_nif fails as reported by Rados=C5=82aw Bu=C5=82at. This se=
> ems to be=20
> a "simple" bug that can be fixed, but even if so...
> 
> 2. The NIF overriding mechanism is not implemented for hipe and would=20
> probably yield unpredictable results.
> 
> 3. Hipe compiler fails on on_load as reported.
> 
> I will look into the first two.  Not sure if #3 was expected not to=20
> work? (Mikael? Kostis?)

Last time I checked on_load was unsupportable by HiPE.  The BEAM loader
did some hacks behind the scenes that it could get away with, but which
were unexpected by and incompatible with the HiPE loader.

Keeping HiPE and NIFs separate seems to be the only viable solution currently.

Alas there are effectively no compiler/vm developers left in the HiPE team;
we've all left to pursue other career paths.

/Mikael

> 
> 
> /Sverker, Erlang/OTP
> 
> Paul Davis wrote:
> > I'm fairly certain that I saw somewhere that HiPE is incompatible with
> > NIF's but I'm unable to actually Google a reference so I could be
> > making that up based on that on_init error that I've seen before.
> >
> > If so, I'd probably just shove the code you want HiPE compiled into a
> > lib module and have the nif stubs call out to that as necessary.
> >
> > HTH,
> > Paul Davis
> >
> > 2011/6/6 Rados=C5=82aw Bu=C5=82at <radek.bulat@REDACTED>:
> >  =20
> >> 2011/6/7 Rados=C5=82aw Bu=C5=82at <radek.bulat@REDACTED>:
> >>    =20
> >>> 2011/6/6 Mikael Pettersson <mikpe@REDACTED>:
> >>>      =20
> >>>> Please post a standalone and minimal test case.
> >>>>
> >>>>        =20
> >>> Yeah, sure.
> >>>
> >>>      =20
> >> One more thing. When module is compiled with HiPE and try to use
> >> on_load attribute it ends with error:
> >>
> >> <HiPE (v 3.8)> EXITED with reason {'trans_fun/2',on_load}
> >> @hipe_beam_to_icode:1148
> >>
> >> =3DERROR REPORT=3D=3D=3D=3D 7-Jun-2011::01:18:36 =3D=3D=3D
> >> Error in process <0.50.0> with exit value:
> >> {{badmatch,{'EXIT',{{hipe_beam_to_icode,1148,{'trans_fun/2',on_load}},=
> [{hipe_beam_to_icode,trans_fun,2},{hipe_beam_to_icode,trans_fun,2},{hipe_=
> beam_to_icode,trans_mfa_code,5},{hipe_beam_to_icode,trans_beam_function_c=
> hunk...
> >>
> >> src/nif_with_hipe.erl:none: internal error in native_compile;
> >> crash reason: {{badmatch,
> >>                   {'EXIT',
> >>                       {{hipe_beam_to_icode,1148,{'trans_fun/2',on_load=
> }},
> >>                        [{hipe_beam_to_icode,trans_fun,2},
> >>                         {hipe_beam_to_icode,trans_fun,2},
> >>                         {hipe_beam_to_icode,trans_mfa_code,5},
> >>                         {hipe_beam_to_icode,trans_beam_function_chunk,=
> 2},
> >>                         {hipe_beam_to_icode,'-module/2-lc$^1/1-1-',2},=
> 
> >>                         {hipe,get_beam_icode,4},
> >>                         {hipe,'-run_compiler_1/3-fun-0-',4}]}}},
> >>               [{hipe,get_beam_icode,4},{hipe,'-run_compiler_1/3-fun-0-=
> ',4}]}
> >>
> >> --
> >> Pozdrawiam
> >>
> >> Rados=C5=82aw Bu=C5=82at
> >> http://radarek.jogger.pl - m=C3=B3j blog
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://erlang.org/mailman/listinfo/erlang-questions
> >>
> >>    =20
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> >  =20
> 
> 
> 
> 



More information about the erlang-questions mailing list