Hotspot loves PHP.reboot
Rémi Forax
forax at univ-mlv.fr
Tue Sep 6 13:36:12 PDT 2011
On 09/06/2011 10:19 PM, John Rose wrote:
> On Sep 6, 2011, at 12:58 PM, John Rose wrote:
>
>> What's needed here is a way to get 33 bits out of a 32-bit add
>> intrinsic. There's no fully natural way to do this, and about 4
>> kludgey ways. Because there are so many poor ways to shape the API,
>> it's hard to pick the best one to invest in.
>
> But, assuming the user wants to force a JO, here's one fairly clean
> way to do it:
>
> /**
> * Detect 32-bit overflow if the parameters are summed.
> * @return true if the inputs have the same sign, but their 32-bit
> sum would have a different sign
> */
> public static boolean addWouldOverflow(int x, int y) {
> //int res = x + y;
> //boolean overflowDetected = (SGN(x) == SGN(y) && SGN(x) !=
> SGN(res));
> //boolean overflowDetected = ((x ^ y) >= 0 & (x ^ res) < 0);
> //boolean overflowDetected = ((x ^ y ^ -1) & (x ^ res)) < 0;
> return (((x ^ y ^ -1) & (x ^ (x+y))) < 0);
> }
>
> That would provide a fairly stable and clear target for the JIT to aim
> at. No points for ease-of-use.
An exception is perhaps more easier to use,
because if it overflow you may have to deoptimize, for that you need the
stack and local values,
it's easier to jump to a exception handler that will push all these
values and call the interpreter.
>
> -- John
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20110906/abb14493/attachment.html
More information about the mlvm-dev
mailing list