RFR(S): 8158228: C1 incorrectly folds mismatched loads from stable arrays
tobias.hartmann at oracle.com
Wed Jun 1 12:12:47 UTC 2016
please review the following patch:
Multiple tests fail since JDK 9 b110 because String.charAt() returns a wrong value for a constant string. In b110, JDK-8143407  enabled C1 to constant fold stable array elements and since JDK-8150180  String.value is constant. The problem is that C1 does not correctly fold mismatched loads from stable arrays. In this case, String.value is a stable byte and StringUTF16.charAt() is intrinsified as char load. Instead of a char load, C1 emits a byte load because it does not check for mismatched loads.
I fixed this by passing the BasicType of the mismatched load to ciArray::element_value() to ensure the correct constant is emitted. I verified that both 'Lex06403.java' and 'NewTestCase.java' pass with the fix. Also tested with JPRT and RBT (running).
More information about the hotspot-compiler-dev