Re: [Projects] [PATCH] Arithmetic overflow should wrap around

On 06/04/2014 02:44, Pablo Oliveira wrote:
Dear HAVM maintainers,
Dear Pablo, Sorry for this late answer! :/
Tiger specifications do not precisely define the expected behavior of an integer overflow. Currently, HAVM does not coerce its arithmetic computations to an Int32 type. To be consistent with nolimips, spim, and most current architectures, it would be nice that arithmetic operations in HAVM wrap around.
Agreed. We had a discussion in the Tiger Patches mailing list about overflows in the code generated by the TC's MIPS backend a couple of years ago and I was also in favor of wrapping arithmetic operators (although I forgot to implement them!).
The tentative attached patch fixes this. (I went for the less intrusive fix, a more radical solution would be to redefine all Int types in HAVM to Int32.)
Thank you for your patch! As long as the semantics of the virtual machine remain unclear regarding overflows, your solution is admittedly better than migrating all Int values to Int32. I'll apply it ASAP. Kind regards, Roland -- Roland Levillain EPITA Research and Development Laboratory (LRDE) 14-16, rue Voltaire - FR-94276 Le Kremlin-BicĂȘtre Cedex - France Phone: +33 1 53 14 59 45 - Fax: +33 1 53 14 59 22 - www.lrde.epita.fr
participants (1)
-
Roland Levillain