8159129: TestStringIntrinsicRangeChecks fails w/ No exception thrown for compressByte/inflateByte

Need to convert char offsets to byte offsets before range check.

Reviewed-by: vlivanov
This commit is contained in:
Tobias Hartmann 2016-07-05 07:57:09 +02:00
parent 9ab5f632b5
commit b64a4110b3
2 changed files with 13 additions and 11 deletions

View file

@ -1403,18 +1403,20 @@ bool LibraryCallKit::inline_string_copy(bool compress) {
(!compress && src_elem == T_BYTE && (dst_elem == T_BYTE || dst_elem == T_CHAR)), (!compress && src_elem == T_BYTE && (dst_elem == T_BYTE || dst_elem == T_CHAR)),
"Unsupported array types for inline_string_copy"); "Unsupported array types for inline_string_copy");
// Range checks // Convert char[] offsets to byte[] offsets
generate_string_range_check(src, src_offset, length, compress && src_elem == T_BYTE); bool convert_src = (compress && src_elem == T_BYTE);
generate_string_range_check(dst, dst_offset, length, !compress && dst_elem == T_BYTE); bool convert_dst = (!compress && dst_elem == T_BYTE);
if (stopped()) { if (convert_src) {
return true; src_offset = _gvn.transform(new LShiftINode(src_offset, intcon(1)));
} else if (convert_dst) {
dst_offset = _gvn.transform(new LShiftINode(dst_offset, intcon(1)));
} }
// Convert char[] offsets to byte[] offsets // Range checks
if (compress && src_elem == T_BYTE) { generate_string_range_check(src, src_offset, length, convert_src);
src_offset = _gvn.transform(new LShiftINode(src_offset, intcon(1))); generate_string_range_check(dst, dst_offset, length, convert_dst);
} else if (!compress && dst_elem == T_BYTE) { if (stopped()) {
dst_offset = _gvn.transform(new LShiftINode(dst_offset, intcon(1))); return true;
} }
Node* src_start = array_element_address(src, src_offset, src_elem); Node* src_start = array_element_address(src, src_offset, src_elem);

View file

@ -30,7 +30,7 @@
* @library /compiler/patches /testlibrary /test/lib / * @library /compiler/patches /testlibrary /test/lib /
* @build java.base/java.lang.Helper * @build java.base/java.lang.Helper
* @build compiler.intrinsics.string.TestStringIntrinsicRangeChecks * @build compiler.intrinsics.string.TestStringIntrinsicRangeChecks
* @run main compiler.intrinsics.string.TestStringIntrinsicRangeChecks * @run main/othervm -Xbatch -XX:CompileThreshold=100 -XX:-TieredCompilation compiler.intrinsics.string.TestStringIntrinsicRangeChecks
*/ */
package compiler.intrinsics.string; package compiler.intrinsics.string;