[9] RFR (S): 8152179: C2: Folding of unsigned loads is broken w/ @Stable

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed Mar 23 16:56:04 UTC 2016


http://cr.openjdk.java.net/~vlivanov/8152179/webrev.00/
https://bugs.openjdk.java.net/browse/JDK-8152179

Byte and short loads with small masks are converted to unsigned loads.
Constant folding logic for array elements doesn't respect unsigned loads 
and replace them with signed values.

It usually happens when a small mask is applied to the value produced by 
a signed load (see AndINode::Ideal [1]):

   byteArr [i] & 0x000F;  // AndI (LoadB 0x000F) => AndI (LoadUB 0xF)
   shortArr[i] & 0x000F;  // AndI (LoadS 0x000F) => AndI (LoadUS 0xF)

   byteArr [i] & 0x00FF;  // AndI (LoadB 0x00FF) => LoadUB
   shortArr[i] & 0xFFFF;  // AndI (LoadS 0xFFFF) => LoadUS

Field loads aren't affected since they are constant folded during parsing.

Testing: regression tests, hotspot/compiler/stable, JPRT

Thanks!

Best regards,
Vladimir Ivanov

PS: while experimenting with the fix, I found that constant folding of 
@Stable loads doesn't always happen. Filed 8152590 [2].

[1] 
http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/d9d0a63499ce/src/share/vm/opto/mulnode.cpp#l483

[2] https://bugs.openjdk.java.net/browse/JDK-8152590


More information about the hotspot-compiler-dev mailing list