changeset 11724:b82f3570b774

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
author thartmann
date Tue, 05 Jul 2016 07:57:09 +0200
parents cfb594b3cdbe
children 20d1eb098cd0
files src/share/vm/opto/library_call.cpp test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java
diffstat 2 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/library_call.cpp	Mon Jul 04 09:14:02 2016 +0200
+++ b/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/test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java	Mon Jul 04 09:14:02 2016 +0200
+++ b/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;