299 } else if (in->is_MemBar()) { 300 mem = in->in(TypeFunc::Memory); 301 } else { 302 assert(false, "unexpected projection"); 303 } 304 } else if (mem->is_Store()) { 305 const TypePtr* atype = mem->as_Store()->adr_type(); 306 int adr_idx = Compile::current()->get_alias_index(atype); 307 if (adr_idx == alias_idx) { 308 assert(atype->isa_oopptr(), "address type must be oopptr"); 309 int adr_offset = atype->offset(); 310 uint adr_iid = atype->is_oopptr()->instance_id(); 311 // Array elements references have the same alias_idx 312 // but different offset and different instance_id. 313 if (adr_offset == offset && adr_iid == alloc->_idx) 314 return mem; 315 } else { 316 assert(adr_idx == Compile::AliasIdxRaw, "address must match or be raw"); 317 } 318 mem = mem->in(MemNode::Memory); 319 } else if (mem->Opcode() == Op_SCMemProj) { 320 assert(mem->in(0)->is_LoadStore(), "sanity"); 321 const TypePtr* atype = mem->in(0)->in(MemNode::Address)->bottom_type()->is_ptr(); 322 int adr_idx = Compile::current()->get_alias_index(atype); 323 if (adr_idx == alias_idx) { 324 assert(false, "Object is not scalar replaceable if a LoadStore node access its field"); 325 return NULL; 326 } 327 mem = mem->in(0)->in(MemNode::Memory); 328 } else { 329 return mem; 330 } 331 assert(mem != orig_mem, "dead memory loop"); 332 } 333 } 334 335 // 336 // Given a Memory Phi, compute a value Phi containing the values from stores 337 // on the input paths. 338 // Note: this function is recursive, its depth is limied by the "level" argument 806 } 807 } 808 safepoints_done.append_if_missing(sfpt); // keep it for rollback 809 } 810 return true; 811 } 812 813 // Process users of eliminated allocation. 814 void PhaseMacroExpand::process_users_of_allocation(AllocateNode *alloc) { 815 Node* res = alloc->result_cast(); 816 if (res != NULL) { 817 for (DUIterator_Last jmin, j = res->last_outs(jmin); j >= jmin; ) { 818 Node *use = res->last_out(j); 819 uint oc1 = res->outcnt(); 820 821 if (use->is_AddP()) { 822 for (DUIterator_Last kmin, k = use->last_outs(kmin); k >= kmin; ) { 823 Node *n = use->last_out(k); 824 uint oc2 = use->outcnt(); 825 if (n->is_Store()) { 826 _igvn.replace_node(n, n->in(MemNode::Memory)); 827 } else { 828 eliminate_card_mark(n); 829 } 830 k -= (oc2 - use->outcnt()); 831 } 832 } else { 833 eliminate_card_mark(use); 834 } 835 j -= (oc1 - res->outcnt()); 836 } 837 assert(res->outcnt() == 0, "all uses of allocated objects must be deleted"); 838 _igvn.remove_dead_node(res); 839 } 840 841 // 842 // Process other users of allocation's projections 843 // 844 if (_resproj != NULL && _resproj->outcnt() != 0) { 845 for (DUIterator_Last jmin, j = _resproj->last_outs(jmin); j >= jmin; ) { | 299 } else if (in->is_MemBar()) { 300 mem = in->in(TypeFunc::Memory); 301 } else { 302 assert(false, "unexpected projection"); 303 } 304 } else if (mem->is_Store()) { 305 const TypePtr* atype = mem->as_Store()->adr_type(); 306 int adr_idx = Compile::current()->get_alias_index(atype); 307 if (adr_idx == alias_idx) { 308 assert(atype->isa_oopptr(), "address type must be oopptr"); 309 int adr_offset = atype->offset(); 310 uint adr_iid = atype->is_oopptr()->instance_id(); 311 // Array elements references have the same alias_idx 312 // but different offset and different instance_id. 313 if (adr_offset == offset && adr_iid == alloc->_idx) 314 return mem; 315 } else { 316 assert(adr_idx == Compile::AliasIdxRaw, "address must match or be raw"); 317 } 318 mem = mem->in(MemNode::Memory); 319 } else if (mem->Opcode() == Op_ClearArray) { 320 intptr_t offset; 321 AllocateNode* clear_alloc = AllocateNode::Ideal_allocation(mem->in(3), phase, offset); 322 // We can not bypass initialization of the instance we are looking for 323 // or when something is wrong. 324 if (clear_alloc == NULL) 325 return mem; 326 InitializeNode* init = clear_alloc->initialization(); 327 if (clear_alloc == alloc) { 328 // We are looking for value, return Initialize node. 329 assert(init != NULL, "should have"); 330 return init; 331 } else { 332 // Otherwise skip it. 333 if (init != NULL) 334 mem = init->in(TypeFunc::Memory); 335 else 336 mem = clear_alloc->in(TypeFunc::Memory); 337 } 338 } else if (mem->Opcode() == Op_SCMemProj) { 339 assert(mem->in(0)->is_LoadStore(), "sanity"); 340 const TypePtr* atype = mem->in(0)->in(MemNode::Address)->bottom_type()->is_ptr(); 341 int adr_idx = Compile::current()->get_alias_index(atype); 342 if (adr_idx == alias_idx) { 343 assert(false, "Object is not scalar replaceable if a LoadStore node access its field"); 344 return NULL; 345 } 346 mem = mem->in(0)->in(MemNode::Memory); 347 } else { 348 return mem; 349 } 350 assert(mem != orig_mem, "dead memory loop"); 351 } 352 } 353 354 // 355 // Given a Memory Phi, compute a value Phi containing the values from stores 356 // on the input paths. 357 // Note: this function is recursive, its depth is limied by the "level" argument 825 } 826 } 827 safepoints_done.append_if_missing(sfpt); // keep it for rollback 828 } 829 return true; 830 } 831 832 // Process users of eliminated allocation. 833 void PhaseMacroExpand::process_users_of_allocation(AllocateNode *alloc) { 834 Node* res = alloc->result_cast(); 835 if (res != NULL) { 836 for (DUIterator_Last jmin, j = res->last_outs(jmin); j >= jmin; ) { 837 Node *use = res->last_out(j); 838 uint oc1 = res->outcnt(); 839 840 if (use->is_AddP()) { 841 for (DUIterator_Last kmin, k = use->last_outs(kmin); k >= kmin; ) { 842 Node *n = use->last_out(k); 843 uint oc2 = use->outcnt(); 844 if (n->is_Store()) { 845 #ifdef ASSERT 846 // Verify that there is no dependent MemBarVolatile nodes, 847 // they should be removed during IGVN, see MemBarNode::Ideal(). 848 for (DUIterator_Fast pmax, p = n->fast_outs(pmax); 849 p < pmax; p++) { 850 Node* mb = n->fast_out(p); 851 assert(mb->is_Initialize() || !mb->is_MemBar() || 852 mb->req() <= MemBarNode::Precedent || 853 mb->in(MemBarNode::Precedent) != n, 854 "MemBarVolatile should be eliminated for non-escaping object"); 855 } 856 #endif 857 _igvn.replace_node(n, n->in(MemNode::Memory)); 858 } else { 859 eliminate_card_mark(n); 860 } 861 k -= (oc2 - use->outcnt()); 862 } 863 } else { 864 eliminate_card_mark(use); 865 } 866 j -= (oc1 - res->outcnt()); 867 } 868 assert(res->outcnt() == 0, "all uses of allocated objects must be deleted"); 869 _igvn.remove_dead_node(res); 870 } 871 872 // 873 // Process other users of allocation's projections 874 // 875 if (_resproj != NULL && _resproj->outcnt() != 0) { 876 for (DUIterator_Last jmin, j = _resproj->last_outs(jmin); j >= jmin; ) { |