Computer Language Shootout - concurrency
Ulf Wiger (AL/EAB)
Wed Dec 7 14:42:50 CET 2005
Oh, I should hasten to add that it was conjecture
based on my reading of the code. I did not trace
the benchmark code to see that erts_mixed_plus()
in fact got called.
What I did was compile with the -S flag with and
without is_integer/1 guards, and then run diff on
the output. The only difference was the call to
the guard, but it didn't affect any of the other
In both cases, the following instruction was:
where the constant value is obviously tagged as
In erl_bif.tab, the '+' operation seems to map
to splus_2(), which turns around and calls
erts_mixed_plus(). I have failed to spot the
optimization that you speak of. That obviously
isn't meant to imply that it isn't there - only
that I was unable to find it.
> -----Original Message-----
> [mailto:] On Behalf Of Bjorn
> Sent: den 7 december 2005 09:17
> Subject: Re: Computer Language Shootout - concurrency
> "Ulf Wiger (AL/EAB)" <> writes:
> > I thought that, worst case, it wouldn't make a difference. As it is
> > now, the compiler inserts the is_integer/1 checks, but
> doesn't act on
> > the result. Eventually, the function splus_2 in erl_arith.c ends up
> > being called, and it turns around and calls
> erts_mixed_plus(), which
> > is so complex, I didn't even bother to understand it.
> > It does handle all combinations of smallints, bignums and floats.
> This is strange.
> Both Beam and hipe-native code have special cases for
> addition of "small integers" (signed integers that fit into
> 28 bits), so that erts_mixed_plus() does not get called.
> Are you sure that the benchmark code itself causes the call
> erts_mixed_plus() (and not, for instance, the benchmarking
> framework)? Or could it be that the ackermann benchmark uses
> big numbers or floats?
> Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-questions