United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6850613 : Add support for saturated casts

Details
Type:
Enhancement
Submit Date:
2009-06-12
Status:
Open
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
Component:
core-libs
OS:
linux
Sub-Component:
java.lang
CPU:
x86
Priority:
P5
Resolution:
Unresolved
Affected Versions:
7
Targeted Versions:

Related Reports
Relates:

Sub Tasks

Description
A DESCRIPTION OF THE REQUEST :
I post this as a follow up to a discussion that took place on core-libs-dev, titled "Interest in support for saturated casts?"

It would be great if when fixing "4504839 "Java libraries should provide support for unsigned integer arithmetic", saturated casts could also be provided.

JUSTIFICATION :
Modern processors seem to have support for this kind of operation, in
x86 there's packssdw in MMX/SSE2.

If the processor doesn't support saturated casts, its just a few lines simple code.

For now this behaviour has to emulated with, which is quite inefficient:

return (short) (x > Short.MAX_VALUE ? Short.MAX_VALUE : (x <
Short.MIN_VALUE ? Short.MIN_VALUE : x));

                                    

Comments



Hardware and Software, Engineered to Work Together