< prev index next >

src/share/vm/opto/library_call.cpp

Print this page
rev 11803 : 8159611: C2: ArrayCopy elimination skips required parameter checks

@@ -5031,10 +5031,16 @@
     generate_negative_guard(src_offset, slow_region);
 
     // (5) dest_offset must not be negative.
     generate_negative_guard(dest_offset, slow_region);
 
+    // (6) length must not be negative.
+    // This is also checked in generate_arraycopy() during macro expansion, but
+    // we also have to check it here for the case where the ArrayCopyNode will
+    // be eliminated by Escape Analysis.
+    if (EliminateAllocations) generate_negative_guard(length, slow_region);
+
     // (7) src_offset + length must not exceed length of src.
     generate_limit_guard(src_offset, length,
                          load_array_length(src),
                          slow_region);
 
< prev index next >