Hardware support for overflow detection in BEAM?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Hardware support for overflow detection in BEAM?

James Hague-3
As best I can tell from the BEAM sources (there *is* a lot of code :)
overflow for fixnums and the like is detected manually before, in the case
of addition, adding the numbers together.  Has anyone tried modifying this
to just do the math, then check the overflow bit after the fact?  Seems like
this would be a win on the x86, though I can't say for sure about
processors.

James


Reply | Threaded
Open this post in threaded view
|

Hardware support for overflow detection in BEAM?

Kent Boortz-2

> As best I can tell from the BEAM sources (there *is* a lot of code :)
> overflow for fixnums and the like is detected manually before, in the case
> of addition, adding the numbers together.  Has anyone tried modifying this
> to just do the math, then check the overflow bit after the fact?  Seems like
> this would be a win on the x86, though I can't say for sure about
> processors.

We are looking into this at the moment, i.e. we investigate if we can
put back the use of hardware support for arithmetic overflows.

I removed it a couple of years ago simply because the hardware support
for arithmetic overflows in Erlang didn't work correctly. At the time
I blamed the operating system implementations to be incomplete/broken.
On some machines the overflow test cases hang the whole machine, on
others some overflows where caught and others not. I felt that the
extra speed was not worth the danger of crashing an Erlang node.

kent