< prev index next >

src/hotspot/share/opto/macro.cpp

Print this page

 375     Node *in = mem->in(j);
 376     if (in == nullptr || in->is_top()) {
 377       values.at_put(j, in);
 378     } else  {
 379       Node *val = scan_mem_chain(in, alias_idx, offset, start_mem, alloc, &_igvn);
 380       if (val == start_mem || val == alloc_mem) {
 381         // hit a sentinel, return appropriate 0 value
 382         values.at_put(j, _igvn.zerocon(ft));
 383         continue;
 384       }
 385       if (val->is_Initialize()) {
 386         val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn);
 387       }
 388       if (val == nullptr) {
 389         return nullptr;  // can't find a value on this path
 390       }
 391       if (val == mem) {
 392         values.at_put(j, mem);
 393       } else if (val->is_Store()) {
 394         Node* n = val->in(MemNode::ValueIn);
 395         BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
 396         n = bs->step_over_gc_barrier(n);
 397         if (is_subword_type(ft)) {
 398           n = Compile::narrow_value(ft, n, phi_type, &_igvn, true);
 399         }
 400         values.at_put(j, n);
 401       } else if(val->is_Proj() && val->in(0) == alloc) {
 402         values.at_put(j, _igvn.zerocon(ft));
 403       } else if (val->is_Phi()) {
 404         val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1);
 405         if (val == nullptr) {
 406           return nullptr;
 407         }
 408         values.at_put(j, val);
 409       } else if (val->Opcode() == Op_SCMemProj) {
 410         assert(val->in(0)->is_LoadStore() ||
 411                val->in(0)->Opcode() == Op_EncodeISOArray ||
 412                val->in(0)->Opcode() == Op_StrCompressedCopy, "sanity");
 413         assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field");
 414         return nullptr;
 415       } else if (val->is_ArrayCopy()) {
 416         Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), val->in(TypeFunc::Memory), ft, phi_type, alloc);

 494           break;
 495         }
 496       }
 497       if (unique_input != nullptr && unique_input != top) {
 498         mem = unique_input;
 499       } else {
 500         done = true;
 501       }
 502     } else if (mem->is_ArrayCopy()) {
 503       done = true;
 504     } else {
 505       DEBUG_ONLY( mem->dump(); )
 506       assert(false, "unexpected node");
 507     }
 508   }
 509   if (mem != nullptr) {
 510     if (mem == start_mem || mem == alloc_mem) {
 511       // hit a sentinel, return appropriate 0 value
 512       return _igvn.zerocon(ft);
 513     } else if (mem->is_Store()) {
 514       Node* n = mem->in(MemNode::ValueIn);
 515       BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
 516       n = bs->step_over_gc_barrier(n);
 517       return n;
 518     } else if (mem->is_Phi()) {
 519       // attempt to produce a Phi reflecting the values on the input paths of the Phi
 520       Node_Stack value_phis(8);
 521       Node* phi = value_from_mem_phi(mem, ft, ftype, adr_t, alloc, &value_phis, ValueSearchLimit);
 522       if (phi != nullptr) {
 523         return phi;
 524       } else {
 525         // Kill all new Phis
 526         while(value_phis.is_nonempty()) {
 527           Node* n = value_phis.node();
 528           _igvn.replace_node(n, C->top());
 529           value_phis.pop();
 530         }
 531       }
 532     } else if (mem->is_ArrayCopy()) {
 533       Node* ctl = mem->in(0);
 534       Node* m = mem->in(TypeFunc::Memory);
 535       if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj()) {
 536         // pin the loads in the uncommon trap path
 537         ctl = sfpt_ctl;

 578   }
 579 
 580   if (can_eliminate && res != nullptr) {
 581     BarrierSetC2 *bs = BarrierSet::barrier_set()->barrier_set_c2();
 582     for (DUIterator_Fast jmax, j = res->fast_outs(jmax);
 583                                j < jmax && can_eliminate; j++) {
 584       Node* use = res->fast_out(j);
 585 
 586       if (use->is_AddP()) {
 587         const TypePtr* addp_type = igvn->type(use)->is_ptr();
 588         int offset = addp_type->offset();
 589 
 590         if (offset == Type::OffsetTop || offset == Type::OffsetBot) {
 591           NOT_PRODUCT(fail_eliminate = "Undefined field reference";)
 592           can_eliminate = false;
 593           break;
 594         }
 595         for (DUIterator_Fast kmax, k = use->fast_outs(kmax);
 596                                    k < kmax && can_eliminate; k++) {
 597           Node* n = use->fast_out(k);
 598           if (!n->is_Store() && n->Opcode() != Op_CastP2X && !bs->is_gc_pre_barrier_node(n) && !reduce_merge_precheck) {
 599             DEBUG_ONLY(disq_node = n;)
 600             if (n->is_Load() || n->is_LoadStore()) {
 601               NOT_PRODUCT(fail_eliminate = "Field load";)
 602             } else {
 603               NOT_PRODUCT(fail_eliminate = "Not store field reference";)
 604             }
 605             can_eliminate = false;
 606           }
 607         }
 608       } else if (use->is_ArrayCopy() &&
 609                  (use->as_ArrayCopy()->is_clonebasic() ||
 610                   use->as_ArrayCopy()->is_arraycopy_validated() ||
 611                   use->as_ArrayCopy()->is_copyof_validated() ||
 612                   use->as_ArrayCopy()->is_copyofrange_validated()) &&
 613                  use->in(ArrayCopyNode::Dest) == res) {
 614         // ok to eliminate
 615       } else if (use->is_SafePoint()) {
 616         SafePointNode* sfpt = use->as_SafePoint();
 617         if (sfpt->is_Call() && sfpt->as_Call()->has_non_debug_use(res)) {
 618           // Object is passed as argument.

 375     Node *in = mem->in(j);
 376     if (in == nullptr || in->is_top()) {
 377       values.at_put(j, in);
 378     } else  {
 379       Node *val = scan_mem_chain(in, alias_idx, offset, start_mem, alloc, &_igvn);
 380       if (val == start_mem || val == alloc_mem) {
 381         // hit a sentinel, return appropriate 0 value
 382         values.at_put(j, _igvn.zerocon(ft));
 383         continue;
 384       }
 385       if (val->is_Initialize()) {
 386         val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn);
 387       }
 388       if (val == nullptr) {
 389         return nullptr;  // can't find a value on this path
 390       }
 391       if (val == mem) {
 392         values.at_put(j, mem);
 393       } else if (val->is_Store()) {
 394         Node* n = val->in(MemNode::ValueIn);


 395         if (is_subword_type(ft)) {
 396           n = Compile::narrow_value(ft, n, phi_type, &_igvn, true);
 397         }
 398         values.at_put(j, n);
 399       } else if(val->is_Proj() && val->in(0) == alloc) {
 400         values.at_put(j, _igvn.zerocon(ft));
 401       } else if (val->is_Phi()) {
 402         val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1);
 403         if (val == nullptr) {
 404           return nullptr;
 405         }
 406         values.at_put(j, val);
 407       } else if (val->Opcode() == Op_SCMemProj) {
 408         assert(val->in(0)->is_LoadStore() ||
 409                val->in(0)->Opcode() == Op_EncodeISOArray ||
 410                val->in(0)->Opcode() == Op_StrCompressedCopy, "sanity");
 411         assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field");
 412         return nullptr;
 413       } else if (val->is_ArrayCopy()) {
 414         Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), val->in(TypeFunc::Memory), ft, phi_type, alloc);

 492           break;
 493         }
 494       }
 495       if (unique_input != nullptr && unique_input != top) {
 496         mem = unique_input;
 497       } else {
 498         done = true;
 499       }
 500     } else if (mem->is_ArrayCopy()) {
 501       done = true;
 502     } else {
 503       DEBUG_ONLY( mem->dump(); )
 504       assert(false, "unexpected node");
 505     }
 506   }
 507   if (mem != nullptr) {
 508     if (mem == start_mem || mem == alloc_mem) {
 509       // hit a sentinel, return appropriate 0 value
 510       return _igvn.zerocon(ft);
 511     } else if (mem->is_Store()) {
 512       return mem->in(MemNode::ValueIn);



 513     } else if (mem->is_Phi()) {
 514       // attempt to produce a Phi reflecting the values on the input paths of the Phi
 515       Node_Stack value_phis(8);
 516       Node* phi = value_from_mem_phi(mem, ft, ftype, adr_t, alloc, &value_phis, ValueSearchLimit);
 517       if (phi != nullptr) {
 518         return phi;
 519       } else {
 520         // Kill all new Phis
 521         while(value_phis.is_nonempty()) {
 522           Node* n = value_phis.node();
 523           _igvn.replace_node(n, C->top());
 524           value_phis.pop();
 525         }
 526       }
 527     } else if (mem->is_ArrayCopy()) {
 528       Node* ctl = mem->in(0);
 529       Node* m = mem->in(TypeFunc::Memory);
 530       if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj()) {
 531         // pin the loads in the uncommon trap path
 532         ctl = sfpt_ctl;

 573   }
 574 
 575   if (can_eliminate && res != nullptr) {
 576     BarrierSetC2 *bs = BarrierSet::barrier_set()->barrier_set_c2();
 577     for (DUIterator_Fast jmax, j = res->fast_outs(jmax);
 578                                j < jmax && can_eliminate; j++) {
 579       Node* use = res->fast_out(j);
 580 
 581       if (use->is_AddP()) {
 582         const TypePtr* addp_type = igvn->type(use)->is_ptr();
 583         int offset = addp_type->offset();
 584 
 585         if (offset == Type::OffsetTop || offset == Type::OffsetBot) {
 586           NOT_PRODUCT(fail_eliminate = "Undefined field reference";)
 587           can_eliminate = false;
 588           break;
 589         }
 590         for (DUIterator_Fast kmax, k = use->fast_outs(kmax);
 591                                    k < kmax && can_eliminate; k++) {
 592           Node* n = use->fast_out(k);
 593           if (!n->is_Store() && n->Opcode() != Op_CastP2X && !reduce_merge_precheck) {
 594             DEBUG_ONLY(disq_node = n;)
 595             if (n->is_Load() || n->is_LoadStore()) {
 596               NOT_PRODUCT(fail_eliminate = "Field load";)
 597             } else {
 598               NOT_PRODUCT(fail_eliminate = "Not store field reference";)
 599             }
 600             can_eliminate = false;
 601           }
 602         }
 603       } else if (use->is_ArrayCopy() &&
 604                  (use->as_ArrayCopy()->is_clonebasic() ||
 605                   use->as_ArrayCopy()->is_arraycopy_validated() ||
 606                   use->as_ArrayCopy()->is_copyof_validated() ||
 607                   use->as_ArrayCopy()->is_copyofrange_validated()) &&
 608                  use->in(ArrayCopyNode::Dest) == res) {
 609         // ok to eliminate
 610       } else if (use->is_SafePoint()) {
 611         SafePointNode* sfpt = use->as_SafePoint();
 612         if (sfpt->is_Call() && sfpt->as_Call()->has_non_debug_use(res)) {
 613           // Object is passed as argument.
< prev index next >