changeset 52209:2d7bff7367c6

8209684: Intrinsics that assume some input non null should use GraphKit::must_be_not_null() Reviewed-by: kvn, thartmann
author roland
date Wed, 22 Aug 2018 10:09:06 +0200
parents d7029542d67a
children 2730e629e32d
files src/hotspot/share/opto/library_call.cpp
diffstat 1 files changed, 63 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/opto/library_call.cpp	Tue Aug 14 16:54:47 2018 +0200
+++ b/src/hotspot/share/opto/library_call.cpp	Wed Aug 22 10:09:06 2018 +0200
@@ -1100,6 +1100,9 @@
   Node* arg1 = argument(0);
   Node* arg2 = argument(1);
 
+  arg1 = must_be_not_null(arg1, true);
+  arg2 = must_be_not_null(arg2, true);
+
   // Get start addr and length of first argument
   Node* arg1_start  = array_element_address(arg1, intcon(0), T_BYTE);
   Node* arg1_cnt    = load_array_length(arg1);
@@ -1123,6 +1126,10 @@
   Node* phi = new PhiNode(region, TypeInt::BOOL);
 
   if (!stopped()) {
+
+    arg1 = must_be_not_null(arg1, true);
+    arg2 = must_be_not_null(arg2, true);
+
     // Get start addr and length of first argument
     Node* arg1_start  = array_element_address(arg1, intcon(0), T_BYTE);
     Node* arg1_cnt    = load_array_length(arg1);
@@ -1182,6 +1189,8 @@
   Node* offset     = argument(1);
   Node* len        = argument(2);
 
+  ba = must_be_not_null(ba, true);
+
   // Range checks
   generate_string_range_check(ba, offset, len, false);
   if (stopped()) {
@@ -1254,6 +1263,9 @@
   RegionNode* result_rgn = new RegionNode(4);
   Node*       result_phi = new PhiNode(result_rgn, TypeInt::INT);
 
+  src = must_be_not_null(src, true);
+  tgt = must_be_not_null(tgt, true);
+
   // Get start addr and length of source string
   Node* src_start = array_element_address(src, intcon(0), T_BYTE);
   Node* src_count = load_array_length(src);
@@ -1298,6 +1310,9 @@
   Node* tgt_count   = argument(3); // char count
   Node* from_index  = argument(4); // char index
 
+  src = must_be_not_null(src, true);
+  tgt = must_be_not_null(tgt, true);
+
   // Multiply byte array index by 2 if String is UTF16 encoded
   Node* src_offset = (ae == StrIntrinsicNode::LL) ? from_index : _gvn.transform(new LShiftINode(from_index, intcon(1)));
   src_count = _gvn.transform(new SubINode(src_count, from_index));
@@ -1383,6 +1398,8 @@
   Node* from_index  = argument(2);
   Node* max         = argument(3);
 
+  src = must_be_not_null(src, true);
+
   Node* src_offset = _gvn.transform(new LShiftINode(from_index, intcon(1)));
   Node* src_start = array_element_address(src, src_offset, T_BYTE);
   Node* src_count = _gvn.transform(new SubINode(max, from_index));
@@ -1453,6 +1470,9 @@
          (!compress && src_elem == T_BYTE && (dst_elem == T_BYTE || dst_elem == T_CHAR)),
          "Unsupported array types for inline_string_copy");
 
+  src = must_be_not_null(src, true);
+  dst = must_be_not_null(dst, true);
+
   // Convert char[] offsets to byte[] offsets
   bool convert_src = (compress && src_elem == T_BYTE);
   bool convert_dst = (!compress && dst_elem == T_BYTE);
@@ -1709,6 +1729,8 @@
     return false;
   }
 
+  value = must_be_not_null(value, true);
+
   Node* adr = array_element_address(value, index, T_CHAR);
   if (adr->is_top()) {
     return false;
@@ -4866,6 +4888,9 @@
   Node *dst_offset  = argument(3);
   Node *length      = argument(4);
 
+  src = must_be_not_null(src, true);
+  dst = must_be_not_null(dst, true);
+
   const Type* src_type = src->Value(&_gvn);
   const Type* dst_type = dst->Value(&_gvn);
   const TypeAryPtr* top_src = src_type->isa_aryptr();
@@ -4918,6 +4943,9 @@
   Node* ylen = argument(3);
   Node* z    = argument(4);
 
+  x = must_be_not_null(x, true);
+  y = must_be_not_null(y, true);
+
   const Type* x_type = x->Value(&_gvn);
   const Type* y_type = y->Value(&_gvn);
   const TypeAryPtr* top_x = x_type->isa_aryptr();
@@ -4963,7 +4991,12 @@
      } __ else_(); {
        // Update graphKit memory and control from IdealKit.
        sync_kit(ideal);
-       Node* zlen_arg = load_array_length(z);
+       Node *cast = new CastPPNode(z, TypePtr::NOTNULL);
+       cast->init_req(0, control());
+       _gvn.set_type(cast, cast->bottom_type());
+       C->record_for_igvn(cast);
+
+       Node* zlen_arg = load_array_length(cast);
        // Update IdealKit memory and control from graphKit.
        __ sync_kit(this);
        __ if_then(zlen_arg, BoolTest::lt, zlen); {
@@ -5018,6 +5051,9 @@
   Node* z    = argument(2);
   Node* zlen = argument(3);
 
+  x = must_be_not_null(x, true);
+  z = must_be_not_null(z, true);
+
   const Type* x_type = x->Value(&_gvn);
   const Type* z_type = z->Value(&_gvn);
   const TypeAryPtr* top_x = x_type->isa_aryptr();
@@ -5065,6 +5101,8 @@
   Node* len      = argument(3);
   Node* k        = argument(4);
 
+  out = must_be_not_null(out, true);
+
   const Type* out_type = out->Value(&_gvn);
   const Type* in_type = in->Value(&_gvn);
   const TypeAryPtr* top_out = out_type->isa_aryptr();
@@ -5317,6 +5355,7 @@
   }
 
   // 'src_start' points to src array + scaled offset
+  src = must_be_not_null(src, true);
   Node* src_start = array_element_address(src, offset, src_elem);
 
   // We assume that range check is done by caller.
@@ -5405,10 +5444,12 @@
   }
 
   // 'src_start' points to src array + scaled offset
+  src = must_be_not_null(src, true);
   Node* src_start = array_element_address(src, offset, src_elem);
 
   // static final int[] byteTable in class CRC32C
   Node* table = get_table_from_crc32c_class(callee()->holder());
+  table = must_be_not_null(table, true);
   Node* table_start = array_element_address(table, intcon(0), T_INT);
 
   // We assume that range check is done by caller.
@@ -5452,6 +5493,7 @@
 
   // static final int[] byteTable in class CRC32C
   Node* table = get_table_from_crc32c_class(callee()->holder());
+  table = must_be_not_null(table, true);
   Node* table_start = array_element_address(table, intcon(0), T_INT);
 
   // Call the stub.
@@ -5695,6 +5737,9 @@
   Node* dest            = argument(3);
   Node* dest_offset     = argument(4);
 
+  src = must_be_not_null(src, true);
+  dest = must_be_not_null(dest, true);
+
   // (1) src and dest are arrays.
   const Type* src_type = src->Value(&_gvn);
   const Type* dest_type = dest->Value(&_gvn);
@@ -5765,6 +5810,9 @@
   Node* dest                       = argument(4);
   Node* dest_offset                = argument(5);
 
+  src = must_be_not_null(src, false);
+  dest = must_be_not_null(dest, false);
+
   // (1) src and dest are arrays.
   const Type* src_type = src->Value(&_gvn);
   const Type* dest_type = dest->Value(&_gvn);
@@ -5970,6 +6018,9 @@
   // The receiver was checked for NULL already.
   Node* objCBC = argument(0);
 
+  Node* src = argument(1);
+  Node* dest = argument(4);
+
   // Load embeddedCipher field of CipherBlockChaining object.
   Node* embeddedCipherObj = load_field_from_object(objCBC, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false);
 
@@ -5988,6 +6039,10 @@
     set_control(top()); // no regular fast path
     return ctrl;
   }
+
+  src = must_be_not_null(src, true);
+  dest = must_be_not_null(dest, true);
+
   ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass();
 
   Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt)));
@@ -6005,8 +6060,7 @@
   // see the original java code for why.
   RegionNode* region = new RegionNode(3);
   region->init_req(1, instof_false);
-  Node* src = argument(1);
-  Node* dest = argument(4);
+
   Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest));
   Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq));
   Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN);
@@ -6073,6 +6127,10 @@
   Node* state          = argument(3);
   Node* subkeyH        = argument(4);
 
+  state = must_be_not_null(state, true);
+  subkeyH = must_be_not_null(subkeyH, true);
+  data = must_be_not_null(data, true);
+
   Node* state_start  = array_element_address(state, intcon(0), T_LONG);
   assert(state_start, "state is NULL");
   Node* subkeyH_start  = array_element_address(subkeyH, intcon(0), T_LONG);
@@ -6146,6 +6204,7 @@
     return false;
   }
   // 'src_start' points to src array + offset
+  src = must_be_not_null(src, true);
   Node* src_start = array_element_address(src, ofs, src_elem);
   Node* state = NULL;
   address stubAddr;
@@ -6212,6 +6271,7 @@
     return false;
   }
   // 'src_start' points to src array + offset
+  src = must_be_not_null(src, false);
   Node* src_start = array_element_address(src, ofs, src_elem);
 
   const char* klass_SHA_name = NULL;