< prev index next >

src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp

Print this page
*** 452,11 ***
            { -1,  ShenandoahNone},                 { -1,  ShenandoahNone},                 { -1,  ShenandoahNone} },
        };
  
        if (call->is_call_to_arraycopystub()) {
          Node* dest = nullptr;
!         const TypeTuple* args = n->as_Call()->_tf->domain();
          for (uint i = TypeFunc::Parms, j = 0; i < args->cnt(); i++) {
            if (args->field_at(i)->isa_ptr()) {
              j++;
              if (j == 2) {
                dest = n->in(i);
--- 452,11 ---
            { -1,  ShenandoahNone},                 { -1,  ShenandoahNone},                 { -1,  ShenandoahNone} },
        };
  
        if (call->is_call_to_arraycopystub()) {
          Node* dest = nullptr;
!         const TypeTuple* args = n->as_Call()->_tf->domain_sig();
          for (uint i = TypeFunc::Parms, j = 0; i < args->cnt(); i++) {
            if (args->field_at(i)->isa_ptr()) {
              j++;
              if (j == 2) {
                dest = n->in(i);

*** 573,11 ***
        for (; i < others_len; i++) {
          if (others[i].opcode == n->Opcode()) {
            break;
          }
        }
!       uint stop = n->is_Call() ? n->as_Call()->tf()->domain()->cnt() : n->req();
        if (i != others_len) {
          const uint inputs_len = sizeof(others[0].inputs) / sizeof(others[0].inputs[0]);
          for (uint j = 0; j < inputs_len; j++) {
            int pos = others[i].inputs[j].pos;
            if (pos == -1) {
--- 573,11 ---
        for (; i < others_len; i++) {
          if (others[i].opcode == n->Opcode()) {
            break;
          }
        }
!       uint stop = n->is_Call() ? n->as_Call()->tf()->domain_sig()->cnt() : n->req();
        if (i != others_len) {
          const uint inputs_len = sizeof(others[0].inputs) / sizeof(others[0].inputs[0]);
          for (uint j = 0; j < inputs_len; j++) {
            int pos = others[i].inputs[j].pos;
            if (pos == -1) {

*** 793,22 ***
            }
          }
        }
      } else {
        if (c->is_Call() && c->as_Call()->adr_type() != nullptr) {
!         CallProjections projs;
!         c->as_Call()->extract_projections(&projs, true, false);
!         if (projs.fallthrough_memproj != nullptr) {
!           if (projs.fallthrough_memproj->adr_type() == TypePtr::BOTTOM) {
!             if (projs.catchall_memproj == nullptr) {
-               mem = projs.fallthrough_memproj;
              } else {
!               if (phase->is_dominator(projs.fallthrough_catchproj, ctrl)) {
!                 mem = projs.fallthrough_memproj;
                } else {
!                 assert(phase->is_dominator(projs.catchall_catchproj, ctrl), "one proj must dominate barrier");
!                 mem = projs.catchall_memproj;
                }
              }
            }
          } else {
            Node* proj = c->as_Call()->proj_out(TypeFunc::Memory);
--- 793,21 ---
            }
          }
        }
      } else {
        if (c->is_Call() && c->as_Call()->adr_type() != nullptr) {
!         CallProjections* projs = c->as_Call()->extract_projections(true, false);
!         if (projs->fallthrough_memproj != nullptr) {
!           if (projs->fallthrough_memproj->adr_type() == TypePtr::BOTTOM) {
!             if (projs->catchall_memproj == nullptr) {
!               mem = projs->fallthrough_memproj;
              } else {
!               if (phase->is_dominator(projs->fallthrough_catchproj, ctrl)) {
!                 mem = projs->fallthrough_memproj;
                } else {
!                 assert(phase->is_dominator(projs->catchall_catchproj, ctrl), "one proj must dominate barrier");
!                 mem = projs->catchall_memproj;
                }
              }
            }
          } else {
            Node* proj = c->as_Call()->proj_out(TypeFunc::Memory);

*** 1064,11 ***
        }
      }
    }
  }
  
! static Node* create_phis_on_call_return(Node* ctrl, Node* c, Node* n, Node* n_clone, const CallProjections& projs, PhaseIdealLoop* phase) {
    Node* region = nullptr;
    while (c != ctrl) {
      if (c->is_Region()) {
        region = c;
      }
--- 1063,11 ---
        }
      }
    }
  }
  
! static Node* create_phis_on_call_return(Node* ctrl, Node* c, Node* n, Node* n_clone, const CallProjections* projs, PhaseIdealLoop* phase) {
    Node* region = nullptr;
    while (c != ctrl) {
      if (c->is_Region()) {
        region = c;
      }

*** 1076,13 ***
    }
    assert(region != nullptr, "");
    Node* phi = new PhiNode(region, n->bottom_type());
    for (uint j = 1; j < region->req(); j++) {
      Node* in = region->in(j);
!     if (phase->is_dominator(projs.fallthrough_catchproj, in)) {
        phi->init_req(j, n);
!     } else if (phase->is_dominator(projs.catchall_catchproj, in)) {
        phi->init_req(j, n_clone);
      } else {
        phi->init_req(j, create_phis_on_call_return(ctrl, in, n, n_clone, projs, phase));
      }
    }
--- 1075,13 ---
    }
    assert(region != nullptr, "");
    Node* phi = new PhiNode(region, n->bottom_type());
    for (uint j = 1; j < region->req(); j++) {
      Node* in = region->in(j);
!     if (phase->is_dominator(projs->fallthrough_catchproj, in)) {
        phi->init_req(j, n);
!     } else if (phase->is_dominator(projs->catchall_catchproj, in)) {
        phi->init_req(j, n_clone);
      } else {
        phi->init_req(j, create_phis_on_call_return(ctrl, in, n, n_clone, projs, phase));
      }
    }

*** 1180,19 ***
              stack.pop();
            }
          } while(stack.size() > 0);
          continue;
        }
!       CallProjections projs;
-       call->extract_projections(&projs, false, false);
- 
  #ifdef ASSERT
        VectorSet cloned;
  #endif
        Node* lrb_clone = lrb->clone();
!       phase->register_new_node(lrb_clone, projs.catchall_catchproj);
!       phase->set_ctrl(lrb, projs.fallthrough_catchproj);
  
        stack.push(lrb, 0);
        clones.push(lrb_clone);
  
        do {
--- 1179,17 ---
              stack.pop();
            }
          } while(stack.size() > 0);
          continue;
        }
!       CallProjections* projs = call->extract_projections(false, false);
  #ifdef ASSERT
        VectorSet cloned;
  #endif
        Node* lrb_clone = lrb->clone();
!       phase->register_new_node(lrb_clone, projs->catchall_catchproj);
!       phase->set_ctrl(lrb, projs->fallthrough_catchproj);
  
        stack.push(lrb, 0);
        clones.push(lrb_clone);
  
        do {

*** 1210,42 ***
          uint idx = stack.index();
          Node* n_clone = clones.at(clones.size()-1);
          if (idx < n->outcnt()) {
            Node* u = n->raw_out(idx);
            Node* c = phase->ctrl_or_self(u);
!           if (phase->is_dominator(call, c) && phase->is_dominator(c, projs.fallthrough_proj)) {
              stack.set_index(idx+1);
              assert(!u->is_CFG(), "");
              stack.push(u, 0);
              assert(!cloned.test_set(u->_idx), "only one clone");
              Node* u_clone = u->clone();
              int nb = u_clone->replace_edge(n, n_clone, &phase->igvn());
              assert(nb > 0, "should have replaced some uses");
!             phase->register_new_node(u_clone, projs.catchall_catchproj);
              clones.push(u_clone);
!             phase->set_ctrl(u, projs.fallthrough_catchproj);
            } else {
              bool replaced = false;
              if (u->is_Phi()) {
                for (uint k = 1; k < u->req(); k++) {
                  if (u->in(k) == n) {
!                   if (phase->is_dominator(projs.catchall_catchproj, u->in(0)->in(k))) {
                      phase->igvn().replace_input_of(u, k, n_clone);
                      replaced = true;
!                   } else if (!phase->is_dominator(projs.fallthrough_catchproj, u->in(0)->in(k))) {
                      phase->igvn().replace_input_of(u, k, create_phis_on_call_return(ctrl, u->in(0)->in(k), n, n_clone, projs, phase));
                      replaced = true;
                    }
                  }
                }
              } else {
!               if (phase->is_dominator(projs.catchall_catchproj, c)) {
                  phase->igvn().rehash_node_delayed(u);
                  int nb = u->replace_edge(n, n_clone, &phase->igvn());
                  assert(nb > 0, "should have replaced some uses");
                  replaced = true;
!               } else if (!phase->is_dominator(projs.fallthrough_catchproj, c)) {
                  if (u->is_If()) {
                    // Can't break If/Bool/Cmp chain
                    assert(n->is_Bool(), "unexpected If shape");
                    assert(stack.node_at(stack.size()-2)->is_Cmp(), "unexpected If shape");
                    assert(n_clone->is_Bool(), "unexpected clone");
--- 1207,42 ---
          uint idx = stack.index();
          Node* n_clone = clones.at(clones.size()-1);
          if (idx < n->outcnt()) {
            Node* u = n->raw_out(idx);
            Node* c = phase->ctrl_or_self(u);
!           if (phase->is_dominator(call, c) && phase->is_dominator(c, projs->fallthrough_proj)) {
              stack.set_index(idx+1);
              assert(!u->is_CFG(), "");
              stack.push(u, 0);
              assert(!cloned.test_set(u->_idx), "only one clone");
              Node* u_clone = u->clone();
              int nb = u_clone->replace_edge(n, n_clone, &phase->igvn());
              assert(nb > 0, "should have replaced some uses");
!             phase->register_new_node(u_clone, projs->catchall_catchproj);
              clones.push(u_clone);
!             phase->set_ctrl(u, projs->fallthrough_catchproj);
            } else {
              bool replaced = false;
              if (u->is_Phi()) {
                for (uint k = 1; k < u->req(); k++) {
                  if (u->in(k) == n) {
!                   if (phase->is_dominator(projs->catchall_catchproj, u->in(0)->in(k))) {
                      phase->igvn().replace_input_of(u, k, n_clone);
                      replaced = true;
!                   } else if (!phase->is_dominator(projs->fallthrough_catchproj, u->in(0)->in(k))) {
                      phase->igvn().replace_input_of(u, k, create_phis_on_call_return(ctrl, u->in(0)->in(k), n, n_clone, projs, phase));
                      replaced = true;
                    }
                  }
                }
              } else {
!               if (phase->is_dominator(projs->catchall_catchproj, c)) {
                  phase->igvn().rehash_node_delayed(u);
                  int nb = u->replace_edge(n, n_clone, &phase->igvn());
                  assert(nb > 0, "should have replaced some uses");
                  replaced = true;
!               } else if (!phase->is_dominator(projs->fallthrough_catchproj, c)) {
                  if (u->is_If()) {
                    // Can't break If/Bool/Cmp chain
                    assert(n->is_Bool(), "unexpected If shape");
                    assert(stack.node_at(stack.size()-2)->is_Cmp(), "unexpected If shape");
                    assert(n_clone->is_Bool(), "unexpected clone");

*** 2062,18 ***
  Node* MemoryGraphFixer::get_ctrl(Node* n) const {
    Node* c = _phase->get_ctrl(n);
    if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Call()) {
      assert(c == n->in(0), "");
      CallNode* call = c->as_Call();
!     CallProjections projs;
!     call->extract_projections(&projs, true, false);
!     if (projs.catchall_memproj != nullptr) {
!       if (projs.fallthrough_memproj == n) {
-         c = projs.fallthrough_catchproj;
        } else {
!         assert(projs.catchall_memproj == n, "");
!         c = projs.catchall_catchproj;
        }
      }
    }
    return c;
  }
--- 2059,17 ---
  Node* MemoryGraphFixer::get_ctrl(Node* n) const {
    Node* c = _phase->get_ctrl(n);
    if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Call()) {
      assert(c == n->in(0), "");
      CallNode* call = c->as_Call();
!     CallProjections* projs = call->extract_projections(true, false);
!     if (projs->catchall_memproj != nullptr) {
!       if (projs->fallthrough_memproj == n) {
!         c = projs->fallthrough_catchproj;
        } else {
!         assert(projs->catchall_memproj == n, "");
!         c = projs->catchall_catchproj;
        }
      }
    }
    return c;
  }
< prev index next >