News for hackers. Stuff that matters.
Re:The Performance Cost of Integer Overflow Checking by the_why_of_y on Saturday December 27, 2014 @07:50AM (#8802406)
> an ISA that doesn't have an integer type with wrapping semantics (e.g. the JVM.)

This is incorrect: the JVM has fully well-defined modulo arithmetic:

http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.htm...

"The result is the 32 low-order bits of the true mathematical result in a sufficiently wide two's-complement format, represented as a value of type int. If overflow occurs, then the sign of the result may not be the same as the sign of the mathematical sum of the two values. Despite the fact that overflow may occur, execution of an iadd instruction never throws a run-time exception."

With this definition the JVM doesn't need distinct instructions for unsigned arithmetic since they're identical to signed arithmetic in two's complement (with some exceptions like shifting for which there are both ishr / iushr instructions).

There are no comments on this comment yet.