RFR(XXS): 8166767: C2: OptimizeStringConcat produces wrong results when copying UTF16 Strings
Tobias Hartmann
tobias.hartmann at oracle.com
Tue Sep 27 09:30:41 UTC 2016
Hi Martin,
On 27.09.2016 11:03, Doerr, Martin wrote:
> PhaseStringOpts::copy_constant_string increments index twice in the copy loop when source and destination are UTF16 encoded.
> http://cr.openjdk.java.net/~mdoerr/8166767_StringOpts_copy_bug/webrev.00/ <http://cr.openjdk.java.net/%7Emdoerr/8166767_StringOpts_copy_bug/webrev.00/>
The index passed to readChar refers to an index in the source byte array (and length is the size in bytes):
// Read two bytes from index and index+1 and convert them to a char
For example, if we want to read the second char value, we need to use index = 4. Therefore, if we read chars, we need to increment i twice in each loop iteration to get the correct char index in the byte array.
Or am I missing something?
Best regards,
Tobias
More information about the hotspot-compiler-dev
mailing list