4657 // and skip a call to MH.linkTo*/invokeBasic adapter, additional information
4658 // about the method being invoked should be attached to the call site to
4659 // make resolution logic work (see SharedRuntime::resolve_{virtual,opt_virtual}_call_C).
4660 slow_call->set_override_symbolic_info(true);
4661 }
4662 set_arguments_for_java_call(slow_call);
4663 set_edges_for_java_call(slow_call);
4664 return slow_call;
4665 }
4666
4667
4668 /**
4669 * Build special case code for calls to hashCode on an object. This call may
4670 * be virtual (invokevirtual) or bound (invokespecial). For each case we generate
4671 * slightly different code.
4672 */
4673 bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) {
4674 assert(is_static == callee()->is_static(), "correct intrinsic selection");
4675 assert(!(is_virtual && is_static), "either virtual, special, or static");
4676
4677 enum { _slow_path = 1, _fast_path, _null_path, PATH_LIMIT };
4678
4679 RegionNode* result_reg = new RegionNode(PATH_LIMIT);
4680 PhiNode* result_val = new PhiNode(result_reg, TypeInt::INT);
4681 PhiNode* result_io = new PhiNode(result_reg, Type::ABIO);
4682 PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM);
4683 Node* obj = nullptr;
4684 if (!is_static) {
4685 // Check for hashing null object
4686 obj = null_check_receiver();
4687 if (stopped()) return true; // unconditionally null
4688 result_reg->init_req(_null_path, top());
4689 result_val->init_req(_null_path, top());
4690 } else {
4691 // Do a null check, and return zero if null.
4692 // System.identityHashCode(null) == 0
4693 obj = argument(0);
4694 Node* null_ctl = top();
4695 obj = null_check_oop(obj, &null_ctl);
4696 result_reg->init_req(_null_path, null_ctl);
4697 result_val->init_req(_null_path, _gvn.intcon(0));
4705 return true;
4706 }
4707
4708 // We only go to the fast case code if we pass a number of guards. The
4709 // paths which do not pass are accumulated in the slow_region.
4710 RegionNode* slow_region = new RegionNode(1);
4711 record_for_igvn(slow_region);
4712
4713 // If this is a virtual call, we generate a funny guard. We pull out
4714 // the vtable entry corresponding to hashCode() from the target object.
4715 // If the target method which we are calling happens to be the native
4716 // Object hashCode() method, we pass the guard. We do not need this
4717 // guard for non-virtual calls -- the caller is known to be the native
4718 // Object hashCode().
4719 if (is_virtual) {
4720 // After null check, get the object's klass.
4721 Node* obj_klass = load_object_klass(obj);
4722 generate_virtual_guard(obj_klass, slow_region);
4723 }
4724
4725 // Get the header out of the object, use LoadMarkNode when available
4726 Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
4727 // The control of the load must be null. Otherwise, the load can move before
4728 // the null check after castPP removal.
4729 Node* no_ctrl = nullptr;
4730 Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
4731
4732 if (!UseObjectMonitorTable) {
4733 // Test the header to see if it is safe to read w.r.t. locking.
4734 Node *lock_mask = _gvn.MakeConX(markWord::lock_mask_in_place);
4735 Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask));
4736 Node *monitor_val = _gvn.MakeConX(markWord::monitor_value);
4737 Node *chk_monitor = _gvn.transform(new CmpXNode(lmasked_header, monitor_val));
4738 Node *test_monitor = _gvn.transform(new BoolNode(chk_monitor, BoolTest::eq));
4739
4740 generate_slow_guard(test_monitor, slow_region);
4741 }
4742
4743 // Get the hash value and check to see that it has been properly assigned.
4744 // We depend on hash_mask being at most 32 bits and avoid the use of
4745 // hash_mask_in_place because it could be larger than 32 bits in a 64-bit
4746 // vm: see markWord.hpp.
4747 Node *hash_mask = _gvn.intcon(markWord::hash_mask);
4748 Node *hash_shift = _gvn.intcon(markWord::hash_shift);
4749 Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift));
4750 // This hack lets the hash bits live anywhere in the mark object now, as long
4751 // as the shift drops the relevant bits into the low 32 bits. Note that
4752 // Java spec says that HashCode is an int so there's no point in capturing
4753 // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build).
4754 hshifted_header = ConvX2I(hshifted_header);
4755 Node *hash_val = _gvn.transform(new AndINode(hshifted_header, hash_mask));
4756
4757 Node *no_hash_val = _gvn.intcon(markWord::no_hash);
4758 Node *chk_assigned = _gvn.transform(new CmpINode( hash_val, no_hash_val));
4759 Node *test_assigned = _gvn.transform(new BoolNode( chk_assigned, BoolTest::eq));
4760
4761 generate_slow_guard(test_assigned, slow_region);
4762
4763 Node* init_mem = reset_memory();
4764 // fill in the rest of the null path:
4765 result_io ->init_req(_null_path, i_o());
4766 result_mem->init_req(_null_path, init_mem);
4767
4768 result_val->init_req(_fast_path, hash_val);
4769 result_reg->init_req(_fast_path, control());
4770 result_io ->init_req(_fast_path, i_o());
4771 result_mem->init_req(_fast_path, init_mem);
4772
4773 // Generate code for the slow case. We make a call to hashCode().
4774 set_control(_gvn.transform(slow_region));
4775 if (!stopped()) {
4776 // No need for PreserveJVMState, because we're using up the present state.
4777 set_all_memory(init_mem);
4778 vmIntrinsics::ID hashCode_id = is_static ? vmIntrinsics::_identityHashCode : vmIntrinsics::_hashCode;
4779 CallJavaNode* slow_call = generate_method_call(hashCode_id, is_virtual, is_static, false);
4780 Node* slow_result = set_results_for_java_call(slow_call);
4781 // this->control() comes from set_results_for_java_call
4782 result_reg->init_req(_slow_path, control());
4783 result_val->init_req(_slow_path, slow_result);
4784 result_io ->set_req(_slow_path, i_o());
4785 result_mem ->set_req(_slow_path, reset_memory());
4786 }
4787
4788 // Return the combined state.
4789 set_i_o( _gvn.transform(result_io) );
4790 set_all_memory( _gvn.transform(result_mem));
4791
4792 set_result(result_reg, result_val);
4793 return true;
5526 _gvn.hash_delete(alloc);
5527 alloc->set_req(TypeFunc::Control, control());
5528 alloc->set_req(TypeFunc::I_O, i_o());
5529 Node *mem = reset_memory();
5530 set_all_memory(mem);
5531 alloc->set_req(TypeFunc::Memory, mem);
5532 set_control(init->proj_out_or_null(TypeFunc::Control));
5533 set_i_o(callprojs.fallthrough_ioproj);
5534
5535 // Update memory as done in GraphKit::set_output_for_allocation()
5536 const TypeInt* length_type = _gvn.find_int_type(alloc->in(AllocateNode::ALength));
5537 const TypeOopPtr* ary_type = _gvn.type(alloc->in(AllocateNode::KlassNode))->is_klassptr()->as_instance_type();
5538 if (ary_type->isa_aryptr() && length_type != nullptr) {
5539 ary_type = ary_type->is_aryptr()->cast_to_size(length_type);
5540 }
5541 const TypePtr* telemref = ary_type->add_offset(Type::OffsetBot);
5542 int elemidx = C->get_alias_index(telemref);
5543 // Need to properly move every memory projection for the Initialize
5544 #ifdef ASSERT
5545 int mark_idx = C->get_alias_index(ary_type->add_offset(oopDesc::mark_offset_in_bytes()));
5546 int klass_idx = C->get_alias_index(ary_type->add_offset(oopDesc::klass_offset_in_bytes()));
5547 #endif
5548 auto move_proj = [&](ProjNode* proj) {
5549 int alias_idx = C->get_alias_index(proj->adr_type());
5550 assert(alias_idx == Compile::AliasIdxRaw ||
5551 alias_idx == elemidx ||
5552 alias_idx == mark_idx ||
5553 alias_idx == klass_idx, "should be raw memory or array element type");
5554 set_memory(proj, alias_idx);
5555 };
5556 init->for_each_proj(move_proj, TypeFunc::Memory);
5557
5558 Node* allocx = _gvn.transform(alloc);
5559 assert(allocx == alloc, "where has the allocation gone?");
5560 assert(dest->is_CheckCastPP(), "not an allocation result?");
5561
5562 _gvn.hash_delete(dest);
5563 dest->set_req(0, control());
5564 Node* destx = _gvn.transform(dest);
5565 assert(destx == dest, "where has the allocation result gone?");
5566
|
4657 // and skip a call to MH.linkTo*/invokeBasic adapter, additional information
4658 // about the method being invoked should be attached to the call site to
4659 // make resolution logic work (see SharedRuntime::resolve_{virtual,opt_virtual}_call_C).
4660 slow_call->set_override_symbolic_info(true);
4661 }
4662 set_arguments_for_java_call(slow_call);
4663 set_edges_for_java_call(slow_call);
4664 return slow_call;
4665 }
4666
4667
4668 /**
4669 * Build special case code for calls to hashCode on an object. This call may
4670 * be virtual (invokevirtual) or bound (invokespecial). For each case we generate
4671 * slightly different code.
4672 */
4673 bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) {
4674 assert(is_static == callee()->is_static(), "correct intrinsic selection");
4675 assert(!(is_virtual && is_static), "either virtual, special, or static");
4676
4677 enum { _slow_path = 1, _null_path, _fast_path, _fast_path2, PATH_LIMIT };
4678
4679 RegionNode* result_reg = new RegionNode(PATH_LIMIT);
4680 PhiNode* result_val = new PhiNode(result_reg, TypeInt::INT);
4681 PhiNode* result_io = new PhiNode(result_reg, Type::ABIO);
4682 PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM);
4683 Node* obj = nullptr;
4684 if (!is_static) {
4685 // Check for hashing null object
4686 obj = null_check_receiver();
4687 if (stopped()) return true; // unconditionally null
4688 result_reg->init_req(_null_path, top());
4689 result_val->init_req(_null_path, top());
4690 } else {
4691 // Do a null check, and return zero if null.
4692 // System.identityHashCode(null) == 0
4693 obj = argument(0);
4694 Node* null_ctl = top();
4695 obj = null_check_oop(obj, &null_ctl);
4696 result_reg->init_req(_null_path, null_ctl);
4697 result_val->init_req(_null_path, _gvn.intcon(0));
4705 return true;
4706 }
4707
4708 // We only go to the fast case code if we pass a number of guards. The
4709 // paths which do not pass are accumulated in the slow_region.
4710 RegionNode* slow_region = new RegionNode(1);
4711 record_for_igvn(slow_region);
4712
4713 // If this is a virtual call, we generate a funny guard. We pull out
4714 // the vtable entry corresponding to hashCode() from the target object.
4715 // If the target method which we are calling happens to be the native
4716 // Object hashCode() method, we pass the guard. We do not need this
4717 // guard for non-virtual calls -- the caller is known to be the native
4718 // Object hashCode().
4719 if (is_virtual) {
4720 // After null check, get the object's klass.
4721 Node* obj_klass = load_object_klass(obj);
4722 generate_virtual_guard(obj_klass, slow_region);
4723 }
4724
4725 if (UseCompactObjectHeaders) {
4726 // Get the header out of the object.
4727 Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
4728 // The control of the load must be null. Otherwise, the load can move before
4729 // the null check after castPP removal.
4730 Node* no_ctrl = nullptr;
4731 Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
4732
4733 // Test the header to see if the object is in hashed or copied state.
4734 Node* hashctrl_mask = _gvn.MakeConX(markWord::hashctrl_mask_in_place);
4735 Node* masked_header = _gvn.transform(new AndXNode(header, hashctrl_mask));
4736
4737 // Take slow-path when the object has not been hashed.
4738 Node* not_hashed_val = _gvn.MakeConX(0);
4739 Node* chk_hashed = _gvn.transform(new CmpXNode(masked_header, not_hashed_val));
4740 Node* test_hashed = _gvn.transform(new BoolNode(chk_hashed, BoolTest::eq));
4741
4742 generate_slow_guard(test_hashed, slow_region);
4743
4744 // Test whether the object is hashed or hashed&copied.
4745 Node* hashed_copied = _gvn.MakeConX(markWord::hashctrl_expanded_mask_in_place | markWord::hashctrl_hashed_mask_in_place);
4746 Node* chk_copied = _gvn.transform(new CmpXNode(masked_header, hashed_copied));
4747 // If true, then object has been hashed&copied, otherwise it's only hashed.
4748 Node* test_copied = _gvn.transform(new BoolNode(chk_copied, BoolTest::eq));
4749 IfNode* if_copied = create_and_map_if(control(), test_copied, PROB_FAIR, COUNT_UNKNOWN);
4750 Node* if_true = _gvn.transform(new IfTrueNode(if_copied));
4751 Node* if_false = _gvn.transform(new IfFalseNode(if_copied));
4752
4753 // Hashed&Copied path: read hash-code out of the object.
4754 set_control(if_true);
4755 // result_val->del_req(_fast_path2);
4756 // result_reg->del_req(_fast_path2);
4757 // result_io->del_req(_fast_path2);
4758 // result_mem->del_req(_fast_path2);
4759
4760 Node* obj_klass = load_object_klass(obj);
4761 Node* hash_addr;
4762 const TypeKlassPtr* klass_t = _gvn.type(obj_klass)->isa_klassptr();
4763 bool load_offset_runtime = true;
4764
4765 if (klass_t != nullptr) {
4766 if (klass_t->klass_is_exact() && klass_t->isa_instklassptr()) {
4767 ciInstanceKlass* ciKlass = reinterpret_cast<ciInstanceKlass*>(klass_t->is_instklassptr()->exact_klass());
4768 if (!ciKlass->is_mirror_instance_klass() && !ciKlass->is_reference_instance_klass()) {
4769 // We know the InstanceKlass, load hash_offset from there at compile-time.
4770 int hash_offset = ciKlass->hash_offset_in_bytes();
4771 hash_addr = basic_plus_adr(obj, hash_offset);
4772 Node* loaded_hash = make_load(control(), hash_addr, TypeInt::INT, T_INT, MemNode::unordered);
4773 result_val->init_req(_fast_path2, loaded_hash);
4774 result_reg->init_req(_fast_path2, control());
4775 load_offset_runtime = false;
4776 }
4777 }
4778 }
4779
4780 //tty->print_cr("Load hash-offset at runtime: %s", BOOL_TO_STR(load_offset_runtime));
4781
4782 if (load_offset_runtime) {
4783 // We don't know if it is an array or an exact type, figure it out at run-time.
4784 // If not an ordinary instance, then we need to take slow-path.
4785 Node* kind_addr = basic_plus_adr(top(), obj_klass, Klass::kind_offset_in_bytes());
4786 Node* kind = make_load(control(), kind_addr, TypeInt::INT, T_INT, MemNode::unordered);
4787 Node* instance_val = _gvn.intcon(Klass::InstanceKlassKind);
4788 Node* chk_inst = _gvn.transform(new CmpINode(kind, instance_val));
4789 Node* test_inst = _gvn.transform(new BoolNode(chk_inst, BoolTest::ne));
4790 generate_slow_guard(test_inst, slow_region);
4791
4792 // Otherwise it's an instance and we can read the hash_offset from the InstanceKlass.
4793 Node* hash_offset_addr = basic_plus_adr(top(), obj_klass, InstanceKlass::hash_offset_offset_in_bytes());
4794 Node* hash_offset = make_load(control(), hash_offset_addr, TypeInt::INT, T_INT, MemNode::unordered);
4795 // hash_offset->dump();
4796 Node* hash_addr = basic_plus_adr(obj, ConvI2X(hash_offset));
4797 Compile::current()->set_has_unsafe_access(true);
4798 Node* loaded_hash = make_load(control(), hash_addr, TypeInt::INT, T_INT, MemNode::unordered);
4799 result_val->init_req(_fast_path2, loaded_hash);
4800 result_reg->init_req(_fast_path2, control());
4801 }
4802
4803 // Hashed-only path: recompute hash-code from object address.
4804 set_control(if_false);
4805 if (hashCode == 6) {
4806 // Our constants.
4807 Node* M = _gvn.intcon(0x337954D5);
4808 Node* A = _gvn.intcon(0xAAAAAAAA);
4809 // Split object address into lo and hi 32 bits.
4810 Node* obj_addr = _gvn.transform(new CastP2XNode(nullptr, obj));
4811 Node* x = _gvn.transform(new ConvL2INode(obj_addr));
4812 Node* upper_addr = _gvn.transform(new URShiftLNode(obj_addr, _gvn.intcon(32)));
4813 Node* y = _gvn.transform(new ConvL2INode(upper_addr));
4814
4815 Node* H0 = _gvn.transform(new XorINode(x, y));
4816 Node* L0 = _gvn.transform(new XorINode(x, A));
4817
4818 // Full multiplication of two 32 bit values L0 and M into a hi/lo result in two 32 bit values V0 and U0.
4819 Node* L0_64 = _gvn.transform(new ConvI2LNode(L0));
4820 L0_64 = _gvn.transform(new AndLNode(L0_64, _gvn.longcon(0xFFFFFFFF)));
4821 Node* M_64 = _gvn.transform(new ConvI2LNode(M));
4822 // M_64 = _gvn.transform(new AndLNode(M_64, _gvn.longcon(0xFFFFFFFF)));
4823 Node* prod64 = _gvn.transform(new MulLNode(L0_64, M_64));
4824 Node* V0 = _gvn.transform(new ConvL2INode(prod64));
4825 Node* prod_upper = _gvn.transform(new URShiftLNode(prod64, _gvn.intcon(32)));
4826 Node* U0 = _gvn.transform(new ConvL2INode(prod_upper));
4827
4828 Node* Q0 = _gvn.transform(new MulINode(H0, M));
4829 Node* L1 = _gvn.transform(new XorINode(Q0, U0));
4830
4831 // Full multiplication of two 32 bit values L1 and M into a hi/lo result in two 32 bit values V1 and U1.
4832 Node* L1_64 = _gvn.transform(new ConvI2LNode(L1));
4833 L1_64 = _gvn.transform(new AndLNode(L1_64, _gvn.longcon(0xFFFFFFFF)));
4834 prod64 = _gvn.transform(new MulLNode(L1_64, M_64));
4835 Node* V1 = _gvn.transform(new ConvL2INode(prod64));
4836 prod_upper = _gvn.transform(new URShiftLNode(prod64, _gvn.intcon(32)));
4837 Node* U1 = _gvn.transform(new ConvL2INode(prod_upper));
4838
4839 Node* P1 = _gvn.transform(new XorINode(V0, M));
4840
4841 // Right rotate P1 by distance L1.
4842 Node* distance = _gvn.transform(new AndINode(L1, _gvn.intcon(32 - 1)));
4843 Node* inverse_distance = _gvn.transform(new SubINode(_gvn.intcon(32), distance));
4844 Node* ror_part1 = _gvn.transform(new URShiftINode(P1, distance));
4845 Node* ror_part2 = _gvn.transform(new LShiftINode(P1, inverse_distance));
4846 Node* Q1 = _gvn.transform(new OrINode(ror_part1, ror_part2));
4847
4848 Node* L2 = _gvn.transform(new XorINode(Q1, U1));
4849 Node* hash = _gvn.transform(new XorINode(V1, L2));
4850 Node* hash_truncated = _gvn.transform(new AndINode(hash, _gvn.intcon(markWord::hash_mask)));
4851
4852 result_val->init_req(_fast_path, hash_truncated);
4853 } else if (hashCode == 2) {
4854 result_val->init_req(_fast_path, _gvn.intcon(1));
4855 }
4856 } else {
4857 // Get the header out of the object, use LoadMarkNode when available
4858 Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
4859 // The control of the load must be null. Otherwise, the load can move before
4860 // the null check after castPP removal.
4861 Node* no_ctrl = nullptr;
4862 Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
4863
4864 if (!UseObjectMonitorTable) {
4865 // Test the header to see if it is safe to read w.r.t. locking.
4866 Node *lock_mask = _gvn.MakeConX(markWord::lock_mask_in_place);
4867 Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask));
4868 Node *monitor_val = _gvn.MakeConX(markWord::monitor_value);
4869 Node *chk_monitor = _gvn.transform(new CmpXNode(lmasked_header, monitor_val));
4870 Node *test_monitor = _gvn.transform(new BoolNode(chk_monitor, BoolTest::eq));
4871
4872 generate_slow_guard(test_monitor, slow_region);
4873 }
4874
4875 // Get the hash value and check to see that it has been properly assigned.
4876 // We depend on hash_mask being at most 32 bits and avoid the use of
4877 // hash_mask_in_place because it could be larger than 32 bits in a 64-bit
4878 // vm: see markWord.hpp.
4879 Node *hash_mask = _gvn.intcon(markWord::hash_mask);
4880 Node *hash_shift = _gvn.intcon(markWord::hash_shift);
4881 Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift));
4882 // This hack lets the hash bits live anywhere in the mark object now, as long
4883 // as the shift drops the relevant bits into the low 32 bits. Note that
4884 // Java spec says that HashCode is an int so there's no point in capturing
4885 // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build).
4886 hshifted_header = ConvX2I(hshifted_header);
4887 Node *hash_val = _gvn.transform(new AndINode(hshifted_header, hash_mask));
4888
4889 Node *no_hash_val = _gvn.intcon(markWord::no_hash);
4890 Node *chk_assigned = _gvn.transform(new CmpINode( hash_val, no_hash_val));
4891 Node *test_assigned = _gvn.transform(new BoolNode( chk_assigned, BoolTest::eq));
4892
4893 generate_slow_guard(test_assigned, slow_region);
4894
4895 result_val->init_req(_fast_path, hash_val);
4896
4897 // _fast_path2 is not used here.
4898 result_val->del_req(_fast_path2);
4899 result_reg->del_req(_fast_path2);
4900 result_io->del_req(_fast_path2);
4901 result_mem->del_req(_fast_path2);
4902 }
4903
4904 Node* init_mem = reset_memory();
4905 // fill in the rest of the null path:
4906 result_io ->init_req(_null_path, i_o());
4907 result_mem->init_req(_null_path, init_mem);
4908
4909 result_reg->init_req(_fast_path, control());
4910 result_io ->init_req(_fast_path, i_o());
4911 result_mem->init_req(_fast_path, init_mem);
4912
4913 if (UseCompactObjectHeaders) {
4914 result_io->init_req(_fast_path2, i_o());
4915 result_mem->init_req(_fast_path2, init_mem);
4916 }
4917
4918 // Generate code for the slow case. We make a call to hashCode().
4919 assert(slow_region != nullptr, "must have slow_region");
4920 set_control(_gvn.transform(slow_region));
4921 if (!stopped()) {
4922 // No need for PreserveJVMState, because we're using up the present state.
4923 set_all_memory(init_mem);
4924 vmIntrinsics::ID hashCode_id = is_static ? vmIntrinsics::_identityHashCode : vmIntrinsics::_hashCode;
4925 CallJavaNode* slow_call = generate_method_call(hashCode_id, is_virtual, is_static, false);
4926 Node* slow_result = set_results_for_java_call(slow_call);
4927 // this->control() comes from set_results_for_java_call
4928 result_reg->init_req(_slow_path, control());
4929 result_val->init_req(_slow_path, slow_result);
4930 result_io ->set_req(_slow_path, i_o());
4931 result_mem ->set_req(_slow_path, reset_memory());
4932 }
4933
4934 // Return the combined state.
4935 set_i_o( _gvn.transform(result_io) );
4936 set_all_memory( _gvn.transform(result_mem));
4937
4938 set_result(result_reg, result_val);
4939 return true;
5672 _gvn.hash_delete(alloc);
5673 alloc->set_req(TypeFunc::Control, control());
5674 alloc->set_req(TypeFunc::I_O, i_o());
5675 Node *mem = reset_memory();
5676 set_all_memory(mem);
5677 alloc->set_req(TypeFunc::Memory, mem);
5678 set_control(init->proj_out_or_null(TypeFunc::Control));
5679 set_i_o(callprojs.fallthrough_ioproj);
5680
5681 // Update memory as done in GraphKit::set_output_for_allocation()
5682 const TypeInt* length_type = _gvn.find_int_type(alloc->in(AllocateNode::ALength));
5683 const TypeOopPtr* ary_type = _gvn.type(alloc->in(AllocateNode::KlassNode))->is_klassptr()->as_instance_type();
5684 if (ary_type->isa_aryptr() && length_type != nullptr) {
5685 ary_type = ary_type->is_aryptr()->cast_to_size(length_type);
5686 }
5687 const TypePtr* telemref = ary_type->add_offset(Type::OffsetBot);
5688 int elemidx = C->get_alias_index(telemref);
5689 // Need to properly move every memory projection for the Initialize
5690 #ifdef ASSERT
5691 int mark_idx = C->get_alias_index(ary_type->add_offset(oopDesc::mark_offset_in_bytes()));
5692 int klass_idx = C->get_alias_index(ary_type->add_offset(Type::klass_offset()));
5693 #endif
5694 auto move_proj = [&](ProjNode* proj) {
5695 int alias_idx = C->get_alias_index(proj->adr_type());
5696 assert(alias_idx == Compile::AliasIdxRaw ||
5697 alias_idx == elemidx ||
5698 alias_idx == mark_idx ||
5699 alias_idx == klass_idx, "should be raw memory or array element type");
5700 set_memory(proj, alias_idx);
5701 };
5702 init->for_each_proj(move_proj, TypeFunc::Memory);
5703
5704 Node* allocx = _gvn.transform(alloc);
5705 assert(allocx == alloc, "where has the allocation gone?");
5706 assert(dest->is_CheckCastPP(), "not an allocation result?");
5707
5708 _gvn.hash_delete(dest);
5709 dest->set_req(0, control());
5710 Node* destx = _gvn.transform(dest);
5711 assert(destx == dest, "where has the allocation result gone?");
5712
|