3351 // Side-effects region with the control path if the klass is null. |
3351 // Side-effects region with the control path if the klass is null. |
3352 Node* kls = load_klass_from_mirror(mirror, never_see_null, region, _prim_path); |
3352 Node* kls = load_klass_from_mirror(mirror, never_see_null, region, _prim_path); |
3353 // If kls is null, we have a primitive mirror. |
3353 // If kls is null, we have a primitive mirror. |
3354 phi->init_req(_prim_path, prim_return_value); |
3354 phi->init_req(_prim_path, prim_return_value); |
3355 if (stopped()) { set_result(region, phi); return true; } |
3355 if (stopped()) { set_result(region, phi); return true; } |
|
3356 bool safe_for_replace = (region->in(_prim_path) == top()); |
3356 |
3357 |
3357 Node* p; // handy temp |
3358 Node* p; // handy temp |
3358 Node* null_ctl; |
3359 Node* null_ctl; |
3359 |
3360 |
3360 // Now that we have the non-null klass, we can perform the real query. |
3361 // Now that we have the non-null klass, we can perform the real query. |
3361 // For constant classes, the query will constant-fold in LoadNode::Value. |
3362 // For constant classes, the query will constant-fold in LoadNode::Value. |
3362 Node* query_value = top(); |
3363 Node* query_value = top(); |
3363 switch (id) { |
3364 switch (id) { |
3364 case vmIntrinsics::_isInstance: |
3365 case vmIntrinsics::_isInstance: |
3365 // nothing is an instance of a primitive type |
3366 // nothing is an instance of a primitive type |
3366 query_value = gen_instanceof(obj, kls); |
3367 query_value = gen_instanceof(obj, kls, safe_for_replace); |
3367 break; |
3368 break; |
3368 |
3369 |
3369 case vmIntrinsics::_getModifiers: |
3370 case vmIntrinsics::_getModifiers: |
3370 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); |
3371 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); |
3371 query_value = make_load(NULL, p, TypeInt::INT, T_INT); |
3372 query_value = make_load(NULL, p, TypeInt::INT, T_INT); |
4551 // (1) src and dest are arrays. |
4552 // (1) src and dest are arrays. |
4552 const Type* src_type = src->Value(&_gvn); |
4553 const Type* src_type = src->Value(&_gvn); |
4553 const Type* dest_type = dest->Value(&_gvn); |
4554 const Type* dest_type = dest->Value(&_gvn); |
4554 const TypeAryPtr* top_src = src_type->isa_aryptr(); |
4555 const TypeAryPtr* top_src = src_type->isa_aryptr(); |
4555 const TypeAryPtr* top_dest = dest_type->isa_aryptr(); |
4556 const TypeAryPtr* top_dest = dest_type->isa_aryptr(); |
4556 if (top_src == NULL || top_src->klass() == NULL || |
4557 |
4557 top_dest == NULL || top_dest->klass() == NULL) { |
4558 // Do we have the type of src? |
|
4559 bool has_src = (top_src != NULL && top_src->klass() != NULL); |
|
4560 // Do we have the type of dest? |
|
4561 bool has_dest = (top_dest != NULL && top_dest->klass() != NULL); |
|
4562 // Is the type for src from speculation? |
|
4563 bool src_spec = false; |
|
4564 // Is the type for dest from speculation? |
|
4565 bool dest_spec = false; |
|
4566 |
|
4567 if (!has_src || !has_dest) { |
|
4568 // We don't have sufficient type information, let's see if |
|
4569 // speculative types can help. We need to have types for both src |
|
4570 // and dest so that it pays off. |
|
4571 |
|
4572 // Do we already have or could we have type information for src |
|
4573 bool could_have_src = has_src; |
|
4574 // Do we already have or could we have type information for dest |
|
4575 bool could_have_dest = has_dest; |
|
4576 |
|
4577 ciKlass* src_k = NULL; |
|
4578 if (!has_src) { |
|
4579 src_k = src_type->speculative_type(); |
|
4580 if (src_k != NULL && src_k->is_array_klass()) { |
|
4581 could_have_src = true; |
|
4582 } |
|
4583 } |
|
4584 |
|
4585 ciKlass* dest_k = NULL; |
|
4586 if (!has_dest) { |
|
4587 dest_k = dest_type->speculative_type(); |
|
4588 if (dest_k != NULL && dest_k->is_array_klass()) { |
|
4589 could_have_dest = true; |
|
4590 } |
|
4591 } |
|
4592 |
|
4593 if (could_have_src && could_have_dest) { |
|
4594 // This is going to pay off so emit the required guards |
|
4595 if (!has_src) { |
|
4596 src = maybe_cast_profiled_obj(src, src_k); |
|
4597 src_type = _gvn.type(src); |
|
4598 top_src = src_type->isa_aryptr(); |
|
4599 has_src = (top_src != NULL && top_src->klass() != NULL); |
|
4600 src_spec = true; |
|
4601 } |
|
4602 if (!has_dest) { |
|
4603 dest = maybe_cast_profiled_obj(dest, dest_k); |
|
4604 dest_type = _gvn.type(dest); |
|
4605 top_dest = dest_type->isa_aryptr(); |
|
4606 has_dest = (top_dest != NULL && top_dest->klass() != NULL); |
|
4607 dest_spec = true; |
|
4608 } |
|
4609 } |
|
4610 } |
|
4611 |
|
4612 if (!has_src || !has_dest) { |
4558 // Conservatively insert a memory barrier on all memory slices. |
4613 // Conservatively insert a memory barrier on all memory slices. |
4559 // Do not let writes into the source float below the arraycopy. |
4614 // Do not let writes into the source float below the arraycopy. |
4560 insert_mem_bar(Op_MemBarCPUOrder); |
4615 insert_mem_bar(Op_MemBarCPUOrder); |
4561 |
4616 |
4562 // Call StubRoutines::generic_arraycopy stub. |
4617 // Call StubRoutines::generic_arraycopy stub. |
4585 // (But, avoid the native method wrapper to JVM_ArrayCopy.) |
4640 // (But, avoid the native method wrapper to JVM_ArrayCopy.) |
4586 generate_slow_arraycopy(TypePtr::BOTTOM, |
4641 generate_slow_arraycopy(TypePtr::BOTTOM, |
4587 src, src_offset, dest, dest_offset, length, |
4642 src, src_offset, dest, dest_offset, length, |
4588 /*dest_uninitialized*/false); |
4643 /*dest_uninitialized*/false); |
4589 return true; |
4644 return true; |
|
4645 } |
|
4646 |
|
4647 if (src_elem == T_OBJECT) { |
|
4648 // If both arrays are object arrays then having the exact types |
|
4649 // for both will remove the need for a subtype check at runtime |
|
4650 // before the call and may make it possible to pick a faster copy |
|
4651 // routine (without a subtype check on every element) |
|
4652 // Do we have the exact type of src? |
|
4653 bool could_have_src = src_spec; |
|
4654 // Do we have the exact type of dest? |
|
4655 bool could_have_dest = dest_spec; |
|
4656 ciKlass* src_k = top_src->klass(); |
|
4657 ciKlass* dest_k = top_dest->klass(); |
|
4658 if (!src_spec) { |
|
4659 src_k = src_type->speculative_type(); |
|
4660 if (src_k != NULL && src_k->is_array_klass()) { |
|
4661 could_have_src = true; |
|
4662 } |
|
4663 } |
|
4664 if (!dest_spec) { |
|
4665 dest_k = dest_type->speculative_type(); |
|
4666 if (dest_k != NULL && dest_k->is_array_klass()) { |
|
4667 could_have_dest = true; |
|
4668 } |
|
4669 } |
|
4670 if (could_have_src && could_have_dest) { |
|
4671 // If we can have both exact types, emit the missing guards |
|
4672 if (could_have_src && !src_spec) { |
|
4673 src = maybe_cast_profiled_obj(src, src_k); |
|
4674 } |
|
4675 if (could_have_dest && !dest_spec) { |
|
4676 dest = maybe_cast_profiled_obj(dest, dest_k); |
|
4677 } |
|
4678 } |
4590 } |
4679 } |
4591 |
4680 |
4592 //--------------------------------------------------------------------------- |
4681 //--------------------------------------------------------------------------- |
4593 // We will make a fast path for this call to arraycopy. |
4682 // We will make a fast path for this call to arraycopy. |
4594 |
4683 |