RFR(XXS): 8166767: C2: OptimizeStringConcat produces wrong results when copying UTF16 Strings

Doerr, Martin martin.doerr at sap.com
Tue Sep 27 09:40:59 UTC 2016


Hi Tobias,

thank you very much for reviewing. You're right.
I just noticed that the code didn't fit to another change which I have locally. I got to fix that.
Sorry for the mistake. I'll close the bug.

Best regards,
Martin


-----Original Message-----
From: Tobias Hartmann [mailto:tobias.hartmann at oracle.com] 
Sent: Dienstag, 27. September 2016 11:31
To: Doerr, Martin <martin.doerr at sap.com>; hotspot-compiler-dev at openjdk.java.net
Subject: Re: RFR(XXS): 8166767: C2: OptimizeStringConcat produces wrong results when copying UTF16 Strings

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