< prev index next >

src/hotspot/share/opto/macro.cpp

Print this page




  30 #include "opto/arraycopynode.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/compile.hpp"
  35 #include "opto/convertnode.hpp"
  36 #include "opto/graphKit.hpp"
  37 #include "opto/locknode.hpp"
  38 #include "opto/loopnode.hpp"
  39 #include "opto/macro.hpp"
  40 #include "opto/memnode.hpp"
  41 #include "opto/narrowptrnode.hpp"
  42 #include "opto/node.hpp"
  43 #include "opto/opaquenode.hpp"
  44 #include "opto/phaseX.hpp"
  45 #include "opto/rootnode.hpp"
  46 #include "opto/runtime.hpp"
  47 #include "opto/subnode.hpp"
  48 #include "opto/type.hpp"
  49 #include "runtime/sharedRuntime.hpp"

  50 #if INCLUDE_G1GC
  51 #include "gc/g1/g1ThreadLocalData.hpp"
  52 #endif // INCLUDE_G1GC



  53 
  54 
  55 //
  56 // Replace any references to "oldref" in inputs to "use" with "newref".
  57 // Returns the number of replacements made.
  58 //
  59 int PhaseMacroExpand::replace_input(Node *use, Node *oldref, Node *newref) {
  60   int nreplacements = 0;
  61   uint req = use->req();
  62   for (uint j = 0; j < use->len(); j++) {
  63     Node *uin = use->in(j);
  64     if (uin == oldref) {
  65       if (j < req)
  66         use->set_req(j, newref);
  67       else
  68         use->set_prec(j, newref);
  69       nreplacements++;
  70     } else if (j >= req && uin == NULL) {
  71       break;
  72     }


 612   }
 613 
 614   if (can_eliminate && res != NULL) {
 615     for (DUIterator_Fast jmax, j = res->fast_outs(jmax);
 616                                j < jmax && can_eliminate; j++) {
 617       Node* use = res->fast_out(j);
 618 
 619       if (use->is_AddP()) {
 620         const TypePtr* addp_type = _igvn.type(use)->is_ptr();
 621         int offset = addp_type->offset();
 622 
 623         if (offset == Type::OffsetTop || offset == Type::OffsetBot) {
 624           NOT_PRODUCT(fail_eliminate = "Undefined field referrence";)
 625           can_eliminate = false;
 626           break;
 627         }
 628         for (DUIterator_Fast kmax, k = use->fast_outs(kmax);
 629                                    k < kmax && can_eliminate; k++) {
 630           Node* n = use->fast_out(k);
 631           if (!n->is_Store() && n->Opcode() != Op_CastP2X &&

 632               !(n->is_ArrayCopy() &&
 633                 n->as_ArrayCopy()->is_clonebasic() &&
 634                 n->in(ArrayCopyNode::Dest) == use)) {
 635             DEBUG_ONLY(disq_node = n;)
 636             if (n->is_Load() || n->is_LoadStore()) {
 637               NOT_PRODUCT(fail_eliminate = "Field load";)
 638             } else {
 639               NOT_PRODUCT(fail_eliminate = "Not store field referrence";)
 640             }
 641             can_eliminate = false;
 642           }
 643         }
 644       } else if (use->is_ArrayCopy() &&
 645                  (use->as_ArrayCopy()->is_arraycopy_validated() ||
 646                   use->as_ArrayCopy()->is_copyof_validated() ||
 647                   use->as_ArrayCopy()->is_copyofrange_validated()) &&
 648                  use->in(ArrayCopyNode::Dest) == res) {
 649         // ok to eliminate
 650       } else if (use->is_SafePoint()) {
 651         SafePointNode* sfpt = use->as_SafePoint();




  30 #include "opto/arraycopynode.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/compile.hpp"
  35 #include "opto/convertnode.hpp"
  36 #include "opto/graphKit.hpp"
  37 #include "opto/locknode.hpp"
  38 #include "opto/loopnode.hpp"
  39 #include "opto/macro.hpp"
  40 #include "opto/memnode.hpp"
  41 #include "opto/narrowptrnode.hpp"
  42 #include "opto/node.hpp"
  43 #include "opto/opaquenode.hpp"
  44 #include "opto/phaseX.hpp"
  45 #include "opto/rootnode.hpp"
  46 #include "opto/runtime.hpp"
  47 #include "opto/subnode.hpp"
  48 #include "opto/type.hpp"
  49 #include "runtime/sharedRuntime.hpp"
  50 #include "utilities/macros.hpp"
  51 #if INCLUDE_G1GC
  52 #include "gc/g1/g1ThreadLocalData.hpp"
  53 #endif // INCLUDE_G1GC
  54 #if INCLUDE_SHENANDOAHGC
  55 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  56 #endif
  57 
  58 
  59 //
  60 // Replace any references to "oldref" in inputs to "use" with "newref".
  61 // Returns the number of replacements made.
  62 //
  63 int PhaseMacroExpand::replace_input(Node *use, Node *oldref, Node *newref) {
  64   int nreplacements = 0;
  65   uint req = use->req();
  66   for (uint j = 0; j < use->len(); j++) {
  67     Node *uin = use->in(j);
  68     if (uin == oldref) {
  69       if (j < req)
  70         use->set_req(j, newref);
  71       else
  72         use->set_prec(j, newref);
  73       nreplacements++;
  74     } else if (j >= req && uin == NULL) {
  75       break;
  76     }


 616   }
 617 
 618   if (can_eliminate && res != NULL) {
 619     for (DUIterator_Fast jmax, j = res->fast_outs(jmax);
 620                                j < jmax && can_eliminate; j++) {
 621       Node* use = res->fast_out(j);
 622 
 623       if (use->is_AddP()) {
 624         const TypePtr* addp_type = _igvn.type(use)->is_ptr();
 625         int offset = addp_type->offset();
 626 
 627         if (offset == Type::OffsetTop || offset == Type::OffsetBot) {
 628           NOT_PRODUCT(fail_eliminate = "Undefined field referrence";)
 629           can_eliminate = false;
 630           break;
 631         }
 632         for (DUIterator_Fast kmax, k = use->fast_outs(kmax);
 633                                    k < kmax && can_eliminate; k++) {
 634           Node* n = use->fast_out(k);
 635           if (!n->is_Store() && n->Opcode() != Op_CastP2X &&
 636               SHENANDOAHGC_ONLY((!UseShenandoahGC || !ShenandoahBarrierSetC2::is_shenandoah_wb_pre_call(n)) &&)
 637               !(n->is_ArrayCopy() &&
 638                 n->as_ArrayCopy()->is_clonebasic() &&
 639                 n->in(ArrayCopyNode::Dest) == use)) {
 640             DEBUG_ONLY(disq_node = n;)
 641             if (n->is_Load() || n->is_LoadStore()) {
 642               NOT_PRODUCT(fail_eliminate = "Field load";)
 643             } else {
 644               NOT_PRODUCT(fail_eliminate = "Not store field referrence";)
 645             }
 646             can_eliminate = false;
 647           }
 648         }
 649       } else if (use->is_ArrayCopy() &&
 650                  (use->as_ArrayCopy()->is_arraycopy_validated() ||
 651                   use->as_ArrayCopy()->is_copyof_validated() ||
 652                   use->as_ArrayCopy()->is_copyofrange_validated()) &&
 653                  use->in(ArrayCopyNode::Dest) == res) {
 654         // ok to eliminate
 655       } else if (use->is_SafePoint()) {
 656         SafePointNode* sfpt = use->as_SafePoint();


< prev index next >