[erlang-questions] Bug in HiPE on x86-64?

Mikael Pettersson mikpe@REDACTED
Mon Oct 23 17:12:56 CEST 2006


On Tue, 20 Jun 2006 17:52:31 +0200, Mikael Pettersson wrote:
> Stefan Axelsson L \(LN/EAB\) writes:
>  > Hi, I'm seeing different behaviour depending on whether a module is
>  > compiled with HiPE and without, when I make a call with a function
>  > argument. It works when I wrap the function in an anonymous function
>  > though. Is this a feature or a bug? I've read the documentation and
>  > while there are a few differences noted, nothing really jumps out at me
>  > that would explain this (I'm a relative newbie to Erlang, so that's not
>  > to say isn't in there of course).
>  > 
>  > Below are a few test cases that provoke the deviation. In the first case
>  > the evaluation succeeds and in the second I get an error message.
>  > Removing the -smp switch makes no difference. As mentioned, invoking the
>  > test as: "merge_sort:test_sort(1000000, 1, fun(N,Xs)->
>  > merge_sort:merge_sort(N,Xs) end)/1000000." works, i.e. Produces the
>  > expected results.
>  > 
>  > This is on an AMD Opteron x86-64. The code and details are included
>  > below.
> ...
>  > sax@REDACTED:~/Erlang> erl -smp
>  > Erlang (BEAM) emulator version 5.5 [source] [64-bit] [smp:2]
>  > [async-threads:0] [hipe]
>  > 
>  > Eshell V5.5  (abort with ^G)
>  > 1> c(merge_sort,native).
>  > {ok,merge_sort}
>  > 2> merge_sort:test_sort(1000000, 1, fun
>  > merge_sort:merge_sort/2)/1000000.
>  > ** exited: {{badfun,#Fun<merge_sort.merge_sort.2>},[]} **
>  > 3>
>  > =ERROR REPORT==== 20-Jun-2006::11:10:20 ===
>  > Error in process <0.32.0> with exit value:
>  > {{badfun,#Fun<merge_sort.merge_sort.2>},[]}
> 
> I've reproduced this problem on 32-bit PowerPC. It's not dependent on
> architecture or word size; instead, the issue appears to be that these
> pseudo-closures (values of fun M:F/A expressions) aren't recognized by
> HiPE-generated code as function values.
> 
> Thanks for reporting this. We'll look into it.

This bug has now been fixed, and HiPE should handle non-closure fun values
correctly starting with R11B-2. As a bonus HiPE will also handle the old
{M,F}-tuples-as-funs abomination correctly starting with R11B-2.

/Mikael



More information about the erlang-questions mailing list