src/share/vm/opto/library_call.cpp

changeset 5991
b2ee5dc63353
parent 5981
3213ba4d3dff
child 5997
59e8ad757e19
     1.1 --- a/src/share/vm/opto/library_call.cpp	Wed Oct 23 10:00:39 2013 +0200
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Wed Oct 23 12:40:23 2013 +0200
     1.3 @@ -3353,6 +3353,7 @@
     1.4    // If kls is null, we have a primitive mirror.
     1.5    phi->init_req(_prim_path, prim_return_value);
     1.6    if (stopped()) { set_result(region, phi); return true; }
     1.7 +  bool safe_for_replace = (region->in(_prim_path) == top());
     1.8  
     1.9    Node* p;  // handy temp
    1.10    Node* null_ctl;
    1.11 @@ -3363,7 +3364,7 @@
    1.12    switch (id) {
    1.13    case vmIntrinsics::_isInstance:
    1.14      // nothing is an instance of a primitive type
    1.15 -    query_value = gen_instanceof(obj, kls);
    1.16 +    query_value = gen_instanceof(obj, kls, safe_for_replace);
    1.17      break;
    1.18  
    1.19    case vmIntrinsics::_getModifiers:
    1.20 @@ -4553,8 +4554,62 @@
    1.21    const Type* dest_type = dest->Value(&_gvn);
    1.22    const TypeAryPtr* top_src  = src_type->isa_aryptr();
    1.23    const TypeAryPtr* top_dest = dest_type->isa_aryptr();
    1.24 -  if (top_src  == NULL || top_src->klass()  == NULL ||
    1.25 -      top_dest == NULL || top_dest->klass() == NULL) {
    1.26 +
    1.27 +  // Do we have the type of src?
    1.28 +  bool has_src = (top_src != NULL && top_src->klass() != NULL);
    1.29 +  // Do we have the type of dest?
    1.30 +  bool has_dest = (top_dest != NULL && top_dest->klass() != NULL);
    1.31 +  // Is the type for src from speculation?
    1.32 +  bool src_spec = false;
    1.33 +  // Is the type for dest from speculation?
    1.34 +  bool dest_spec = false;
    1.35 +
    1.36 +  if (!has_src || !has_dest) {
    1.37 +    // We don't have sufficient type information, let's see if
    1.38 +    // speculative types can help. We need to have types for both src
    1.39 +    // and dest so that it pays off.
    1.40 +
    1.41 +    // Do we already have or could we have type information for src
    1.42 +    bool could_have_src = has_src;
    1.43 +    // Do we already have or could we have type information for dest
    1.44 +    bool could_have_dest = has_dest;
    1.45 +
    1.46 +    ciKlass* src_k = NULL;
    1.47 +    if (!has_src) {
    1.48 +      src_k = src_type->speculative_type();
    1.49 +      if (src_k != NULL && src_k->is_array_klass()) {
    1.50 +        could_have_src = true;
    1.51 +      }
    1.52 +    }
    1.53 +
    1.54 +    ciKlass* dest_k = NULL;
    1.55 +    if (!has_dest) {
    1.56 +      dest_k = dest_type->speculative_type();
    1.57 +      if (dest_k != NULL && dest_k->is_array_klass()) {
    1.58 +        could_have_dest = true;
    1.59 +      }
    1.60 +    }
    1.61 +
    1.62 +    if (could_have_src && could_have_dest) {
    1.63 +      // This is going to pay off so emit the required guards
    1.64 +      if (!has_src) {
    1.65 +        src = maybe_cast_profiled_obj(src, src_k);
    1.66 +        src_type  = _gvn.type(src);
    1.67 +        top_src  = src_type->isa_aryptr();
    1.68 +        has_src = (top_src != NULL && top_src->klass() != NULL);
    1.69 +        src_spec = true;
    1.70 +      }
    1.71 +      if (!has_dest) {
    1.72 +        dest = maybe_cast_profiled_obj(dest, dest_k);
    1.73 +        dest_type  = _gvn.type(dest);
    1.74 +        top_dest  = dest_type->isa_aryptr();
    1.75 +        has_dest = (top_dest != NULL && top_dest->klass() != NULL);
    1.76 +        dest_spec = true;
    1.77 +      }
    1.78 +    }
    1.79 +  }
    1.80 +
    1.81 +  if (!has_src || !has_dest) {
    1.82      // Conservatively insert a memory barrier on all memory slices.
    1.83      // Do not let writes into the source float below the arraycopy.
    1.84      insert_mem_bar(Op_MemBarCPUOrder);
    1.85 @@ -4589,6 +4644,40 @@
    1.86      return true;
    1.87    }
    1.88  
    1.89 +  if (src_elem == T_OBJECT) {
    1.90 +    // If both arrays are object arrays then having the exact types
    1.91 +    // for both will remove the need for a subtype check at runtime
    1.92 +    // before the call and may make it possible to pick a faster copy
    1.93 +    // routine (without a subtype check on every element)
    1.94 +    // Do we have the exact type of src?
    1.95 +    bool could_have_src = src_spec;
    1.96 +    // Do we have the exact type of dest?
    1.97 +    bool could_have_dest = dest_spec;
    1.98 +    ciKlass* src_k = top_src->klass();
    1.99 +    ciKlass* dest_k = top_dest->klass();
   1.100 +    if (!src_spec) {
   1.101 +      src_k = src_type->speculative_type();
   1.102 +      if (src_k != NULL && src_k->is_array_klass()) {
   1.103 +          could_have_src = true;
   1.104 +      }
   1.105 +    }
   1.106 +    if (!dest_spec) {
   1.107 +      dest_k = dest_type->speculative_type();
   1.108 +      if (dest_k != NULL && dest_k->is_array_klass()) {
   1.109 +        could_have_dest = true;
   1.110 +      }
   1.111 +    }
   1.112 +    if (could_have_src && could_have_dest) {
   1.113 +      // If we can have both exact types, emit the missing guards
   1.114 +      if (could_have_src && !src_spec) {
   1.115 +        src = maybe_cast_profiled_obj(src, src_k);
   1.116 +      }
   1.117 +      if (could_have_dest && !dest_spec) {
   1.118 +        dest = maybe_cast_profiled_obj(dest, dest_k);
   1.119 +      }
   1.120 +    }
   1.121 +  }
   1.122 +
   1.123    //---------------------------------------------------------------------------
   1.124    // We will make a fast path for this call to arraycopy.
   1.125  

mercurial