Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6797305
Votes 0
Synopsis Add LoadUB and LoadUI opcode class
Category hotspot:compiler2
Reported Against b01
Release Fixed hs15(b03), 7(b51) (Bug ID:2174467) , 6u18(b01) (Bug ID:2180534)
State 10-Fix Delivered, request for enhancement
Priority: 5-Very Low
Related Bugs 6345033 , 6402977 , 6738521 , 6799997 , 6216739
Submit Date 23-JAN-2009
Description
Add a LoadUB (unsigned byte) and LoadUI (unsigned int) opcode class so we have these load optimizations in the first place and do not need to handle them in the matcher.

These classes will handle code like, e.g.:

bytearray[i] & 0xFF
intarray[i] & 0xFFFFFFFF
Posted Date : 2009-01-23 18:19:27.0
Work Around
N/A
Evaluation
Some micro benchmarks show a big performance win.
Posted Date : 2009-02-24 15:45:02.0

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/337400e7a5dd
Posted Date : 2009-03-09 12:43:57.0

@brackeen: Well the only thing I can think of (for x86) is to use partial register moves (using MOVZX instructions instead of SHR-AND sequences), e.g.:

  int g = (anInt >> 8) & 0xff;

  MOV    EBX,ECX
  SHR    EBX,#8
  AND    EBX,#255

vs.

  MOVZX8 EBX,CH

or:

  int b = anInt & 0xff;

  MOV    EBX,ECX
  AND    EBX,#255

vs.

  MOVZX8 EBX,CL

While the latter one is likely to have the same performance, as the resulting micro instructions should be the same.  I will run some tests.  Do you have a use-case you can send me?
Posted Date : 2009-09-21 11:53:23.0
Comments
  
  Include a link with my name & email   

Submitted On 04-FEB-2009
UlfZibis
Sorry about my duplicate:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6799997

... but maybe note my testcase code!



Submitted On 06-MAR-2009
UlfZibis
What's about:
    char c = (char)(b & 0xFF)
    char c = (char)(i & 0xFF)
After optimization, it should be fast as or faster as
    char c = (char)b
Goal: determination, if b is positive, becomes superfluous, so we could use { char c = (char)(i & 0xFF) } in any case without speed loss.

Also consider:
    char c = (char)(i & 0xFFFF)
    char c = (char)(intarray[i] & 0xFFFF)


Submitted On 20-SEP-2009
brackeen
Could a similar optimization be applied to extracting unsigned bytes from an integer? For example, getting the color components out of a packed ARGB:
int a = (anInt >>> 24);
int r = (anInt >> 16) & 0xff;
int g = (anInt >> 8) & 0xff;
int b = anInt & 0xff;



PLEASE NOTE: JDK6 is formerly known as Project Mustang