8159129: TestStringIntrinsicRangeChecks fails w/ No exception thrown for compressByte/inflateByte
authorthartmann
Tue, 05 Jul 2016 07:57:09 +0200
changeset 40045 4273f3ba95f7
parent 40044 4e8299073922
child 40046 01e973266ee4
8159129: TestStringIntrinsicRangeChecks fails w/ No exception thrown for compressByte/inflateByte Summary: Need to convert char offsets to byte offsets before range check. Reviewed-by: vlivanov
hotspot/src/share/vm/opto/library_call.cpp
hotspot/test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java
--- a/hotspot/src/share/vm/opto/library_call.cpp	Mon Jul 04 09:14:02 2016 +0200
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Tue Jul 05 07:57:09 2016 +0200
@@ -1403,20 +1403,22 @@
          (!compress && src_elem == T_BYTE && (dst_elem == T_BYTE || dst_elem == T_CHAR)),
          "Unsupported array types for inline_string_copy");
 
+  // Convert char[] offsets to byte[] offsets
+  bool convert_src = (compress && src_elem == T_BYTE);
+  bool convert_dst = (!compress && dst_elem == T_BYTE);
+  if (convert_src) {
+    src_offset = _gvn.transform(new LShiftINode(src_offset, intcon(1)));
+  } else if (convert_dst) {
+    dst_offset = _gvn.transform(new LShiftINode(dst_offset, intcon(1)));
+  }
+
   // Range checks
-  generate_string_range_check(src, src_offset, length, compress && src_elem == T_BYTE);
-  generate_string_range_check(dst, dst_offset, length, !compress && dst_elem == T_BYTE);
+  generate_string_range_check(src, src_offset, length, convert_src);
+  generate_string_range_check(dst, dst_offset, length, convert_dst);
   if (stopped()) {
     return true;
   }
 
-  // Convert char[] offsets to byte[] offsets
-  if (compress && src_elem == T_BYTE) {
-    src_offset = _gvn.transform(new LShiftINode(src_offset, intcon(1)));
-  } else if (!compress && dst_elem == T_BYTE) {
-    dst_offset = _gvn.transform(new LShiftINode(dst_offset, intcon(1)));
-  }
-
   Node* src_start = array_element_address(src, src_offset, src_elem);
   Node* dst_start = array_element_address(dst, dst_offset, dst_elem);
   // 'src_start' points to src array + scaled offset
--- a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java	Mon Jul 04 09:14:02 2016 +0200
+++ b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java	Tue Jul 05 07:57:09 2016 +0200
@@ -30,7 +30,7 @@
  * @library /compiler/patches /testlibrary /test/lib /
  * @build java.base/java.lang.Helper
  * @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;