ssssssss61


Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
  Node* p0 = p->at(0);
  uint vlen = p->size();
  Node* opd = p0->in(opd_idx);
  if (same_inputs(p, opd_idx)) {
    if (opd->is_Vector() || opd->is_LoadVector()) {
      assert(((opd_idx != 2) || !VectorNode::is_shift(p0)), "shift's count can't be vector");
      return opd; // input is matching vector
    }
    if ((opd_idx == 2) && VectorNode::is_shift(p0)) {
      Compile* C = _phase->C;
      Node* cnt = opd;
      juint mask = (p0->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1);
      const TypeInt* t = opd->find_int_type();
      if (t != NULL && t->is_con()) {
        juint shift = t->get_con();
        if (shift > mask) { // Unsigned cmp
          cnt = ConNode::make(C, TypeInt::make(shift & mask));
        }
      } else {
        if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) {
          cnt = ConNode::make(C, TypeInt::make(mask));
          _igvn.register_new_node_with_optimizer(cnt);
          cnt = new (C) AndINode(opd, cnt);
          _igvn.register_new_node_with_optimizer(cnt);
          _phase->set_ctrl(cnt, _phase->get_ctrl(opd));
        }
        assert(opd->bottom_type()->isa_int(), "int type only");
        cnt = VectorNode::shift_count(C, p0, cnt, vlen, velt_basic_type(p0));
      }
      if (cnt != opd) {
        _igvn.register_new_node_with_optimizer(cnt);
        _phase->set_ctrl(cnt, _phase->get_ctrl(opd));
      }
      return cnt;
    }
    assert(!opd->is_StoreVector(), "such vector is not expected here");
    const Type* p0_t = velt_type(p0);
    VectorNode* vn = VectorNode::scalar2vector(_phase->C, opd, vlen, p0_t);
    _igvn.register_new_node_with_optimizer(vn);
    _phase->set_ctrl(vn, _phase->get_ctrl(opd));
#ifdef ASSERT
    if (TraceNewVectors) {
      tty->print("new Vector node: ");
      vn->dump();
    }
#endif
    return vn;
  }
  BasicType bt = velt_basic_type(p0);
  PackNode* pk = PackNode::make(_phase->C, opd, vlen, bt);
  DEBUG_ONLY( const BasicType opd_bt = opd->bottom_type()->basic_type(); )
  for (uint i = 1; i < vlen; i++) {
    Node* pi = p->at(i);
    Node* in = pi->in(opd_idx);
    assert(my_pack(in) == NULL, "Should already have been unpacked");
    assert(opd_bt == in->bottom_type()->basic_type(), "all same type");
    pk->add_opd(in);
  }
  _igvn.register_new_node_with_optimizer(pk);
  _phase->set_ctrl(pk, _phase->get_ctrl(opd));
#ifdef ASSERT
  if (TraceNewVectors) {
    tty->print("new Vector node: ");
    pk->dump();
  }
#endif
  return pk;
}
void SuperWord::insert_extracts(Node_List* p) {
  if (p->at(0)->is_Store()) return;
  assert(_n_idx_list.is_empty(), "empty (node,index) list");
  for (uint i = 0; i < p->size(); i++) {
    Node* def = p->at(i);
    for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) {
      Node* use = def->fast_out(j);
      for (uint k = 0; k < use->req(); k++) {
        Node* n = use->in(k);
        if (def == n) {
          if (!is_vector_use(use, k)) {
            _n_idx_list.push(use, k);
          }
        }
      }
    }
  }
  while (_n_idx_list.is_nonempty()) {
    Node* use = _n_idx_list.node();
    int   idx = _n_idx_list.index();
    _n_idx_list.pop();
    Node* def = use->in(idx);
    _igvn.hash_delete(def);
    int def_pos = alignment(def) / data_size(def);
    Node* ex = ExtractNode::make(_phase->C, def, def_pos, velt_basic_type(def));
    _igvn.register_new_node_with_optimizer(ex);
    _phase->set_ctrl(ex, _phase->get_ctrl(def));
    _igvn.replace_input_of(use, idx, ex);
    _igvn._worklist.push(def);
    bb_insert_after(ex, bb_idx(def));
    set_velt_type(ex, velt_type(def));
  }
}
bool SuperWord::is_vector_use(Node* use, int u_idx) {
  Node_List* u_pk = my_pack(use);
  if (u_pk == NULL) return false;
  Node* def = use->in(u_idx);
  Node_List* d_pk = my_pack(def);
  if (d_pk == NULL) {
    Node* n = u_pk->at(0)->in(u_idx);
    for (uint i = 1; i < u_pk->size(); i++) {
      if (u_pk->at(i)->in(u_idx) != n) return false;
    }
    return true;
  }
  if (u_pk->size() != d_pk->size())
    return false;
  for (uint i = 0; i < u_pk->size(); i++) {
    Node* ui = u_pk->at(i);
    Node* di = d_pk->at(i);
    if (ui->in(u_idx) != di || alignment(ui) != alignment(di))
      return false;
  }
  return true;
}
bool SuperWord::construct_bb() {
  Node* entry = bb();
  assert(_stk.length() == 0,            "stk is empty");
  assert(_block.length() == 0,          "block is empty");
  assert(_data_entry.length() == 0,     "data_entry is empty");
  assert(_mem_slice_head.length() == 0, "mem_slice_head is empty");
  assert(_mem_slice_tail.length() == 0, "mem_slice_tail is empty");
  int bb_ct = 0;
  for (uint i = 0; i < lpt()->_body.size(); i++ ) {
    Node *n = lpt()->_body.at(i);
    set_bb_idx(n, i); // Create a temporary map
    if (in_bb(n)) {
      if (n->is_LoadStore() || n->is_MergeMem() ||
          (n->is_Proj() && !n->as_Proj()->is_CFG())) {
        return false;
      }
      bb_ct++;
      if (!n->is_CFG()) {
        bool found = false;
        for (uint j = 0; j < n->req(); j++) {
          Node* def = n->in(j);
          if (def && in_bb(def)) {
            found = true;
            break;
          }
        }
        if (!found) {
          assert(n != entry, "can't be entry");
          _data_entry.push(n);
        }
      }
    }
  }
  for (DUIterator_Fast imax, i = lp()->fast_outs(imax); i < imax; i++) {
    Node *n = lp()->fast_out(i);
    if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) {
      Node* n_tail  = n->in(LoopNode::LoopBackControl);
      if (n_tail != n->in(LoopNode::EntryControl)) {
        if (!n_tail->is_Mem()) {
          assert(n_tail->is_Mem(), err_msg_res("unexpected node for memory slice: %s", n_tail->Name()));
          return false; // Bailout
        }
        _mem_slice_head.push(n);
        _mem_slice_tail.push(n_tail);
      }
    }
  }
  visited_clear();
  post_visited_clear();
  for (int j = 0; j < _data_entry.length(); j++) {
    Node* n = _data_entry.at(j);
    visited_set(n);
    _stk.push(n);
  }
  visited_set(entry);
  _stk.push(entry);
  int rpo_idx = bb_ct - 1;
  int size;
  while ((size = _stk.length()) > 0) {
    Node* n = _stk.top(); // Leave node on stack
    if (!visited_test_set(n)) {
    } else if (!post_visited_test(n)) {
      for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
        Node *use = n->fast_out(i);
        if (in_bb(use) && !visited_test(use) &&
            (!use->is_Phi() || n == entry)) {
          _stk.push(use);
        }
      }
      if (_stk.length() == size) {
        _stk.pop(); // Remove node from stack
        assert(rpo_idx >= 0, "");
        _block.at_put_grow(rpo_idx, n);
        rpo_idx--;
        post_visited_set(n);
        assert(rpo_idx >= 0 || _stk.is_empty(), "");
      }
    } else {
      _stk.pop(); // Remove post-visited node from stack
    }
  }
  for (int j = 0; j < _block.length(); j++) {
    Node* n = _block.at(j);
    set_bb_idx(n, j);
  }
  initialize_bb(); // Ensure extra info is allocated.
#ifndef PRODUCT
  if (TraceSuperWord) {
    print_bb();
    tty->print_cr("\ndata entry nodes: %s", _data_entry.length() > 0 ? "" : "NONE");
    for (int m = 0; m < _data_entry.length(); m++) {
      tty->print("%3d ", m);
      _data_entry.at(m)->dump();
    }
    tty->print_cr("\nmemory slices: %s", _mem_slice_head.length() > 0 ? "" : "NONE");
    for (int m = 0; m < _mem_slice_head.length(); m++) {
      tty->print("%3d ", m); _mem_slice_head.at(m)->dump();
      tty->print("    ");    _mem_slice_tail.at(m)->dump();
    }
  }
#endif
  assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found");
  return (_mem_slice_head.length() > 0) || (_data_entry.length() > 0);
}
void SuperWord::initialize_bb() {
  Node* last = _block.at(_block.length() - 1);
  grow_node_info(bb_idx(last));
}
void SuperWord::bb_insert_after(Node* n, int pos) {
  int n_pos = pos + 1;
  for (int i = _block.length() - 1; i >= n_pos; i--) {
    _block.at_put_grow(i+1, _block.at(i));
  }
  for (int j = _node_info.length() - 1; j >= n_pos; j--) {
    _node_info.at_put_grow(j+1, _node_info.at(j));
  }
  _block.at_put_grow(n_pos, n);
  _node_info.at_put_grow(n_pos, SWNodeInfo::initial);
  for (int i = n_pos; i < _block.length(); i++) {
    set_bb_idx(_block.at(i), i);
  }
}
void SuperWord::compute_max_depth() {
  int ct = 0;
  bool again;
  do {
    again = false;
    for (int i = 0; i < _block.length(); i++) {
      Node* n = _block.at(i);
      if (!n->is_Phi()) {
        int d_orig = depth(n);
        int d_in   = 0;
        for (DepPreds preds(n, _dg); !preds.done(); preds.next()) {
          Node* pred = preds.current();
          if (in_bb(pred)) {
            d_in = MAX2(d_in, depth(pred));
          }
        }
        if (d_in + 1 != d_orig) {
          set_depth(n, d_in + 1);
          again = true;
        }
      }
    }
    ct++;
  } while (again);
#ifndef PRODUCT
  if (TraceSuperWord && Verbose)
    tty->print_cr("compute_max_depth iterated: %d times", ct);
#endif
}
void SuperWord::compute_vector_element_type() {
#ifndef PRODUCT
  if (TraceSuperWord && Verbose)
    tty->print_cr("\ncompute_velt_type:");
#endif
  for (int i = 0; i < _block.length(); i++) {
    Node* n = _block.at(i);
    set_velt_type(n, container_type(n));
  }
  for (int i = _block.length() - 1; i >= 0; i--) {
    Node* n = _block.at(i);
    const Type* vtn = velt_type(n);
    if (vtn->basic_type() == T_INT) {
      uint start, end;
      VectorNode::vector_operands(n, &start, &end);
      for (uint j = start; j < end; j++) {
        Node* in  = n->in(j);
        if (!in->is_Mem() && in_bb(in) && velt_type(in)->basic_type() == T_INT &&
            data_size(n) < data_size(in)) {
          bool same_type = true;
          for (DUIterator_Fast kmax, k = in->fast_outs(kmax); k < kmax; k++) {
            Node *use = in->fast_out(k);
            if (!in_bb(use) || !same_velt_type(use, n)) {
              same_type = false;
              break;
            }
          }
          if (same_type) {
            const Type* vt = vtn;
            if (VectorNode::is_shift(in)) {
              Node* load = in->in(1);
              if (load->is_Load() && in_bb(load) && (velt_type(load)->basic_type() == T_INT)) {
                vt = velt_type(load);
              } else if (in->Opcode() != Op_LShiftI) {
                vt = TypeInt::INT;
              }
            }
            set_velt_type(in, vt);
          }
        }
      }
    }
  }
#ifndef PRODUCT
  if (TraceSuperWord && Verbose) {
    for (int i = 0; i < _block.length(); i++) {
      Node* n = _block.at(i);
      velt_type(n)->dump();
      tty->print("\t");
      n->dump();
    }
  }
#endif
}
int SuperWord::memory_alignment(MemNode* s, int iv_adjust) {
  SWPointer p(s, this);
  if (!p.valid()) {
    return bottom_align;
  }
  int vw = vector_width_in_bytes(s);
  if (vw < 2) {
    return bottom_align; // No vectors for this type
  }
  int offset  = p.offset_in_bytes();
  offset     += iv_adjust*p.memory_size();
  int off_rem = offset % vw;
  int off_mod = off_rem >= 0 ? off_rem : off_rem + vw;
  return off_mod;
}
const Type* SuperWord::container_type(Node* n) {
  if (n->is_Mem()) {
    BasicType bt = n->as_Mem()->memory_type();
    if (n->is_Store() && (bt == T_CHAR)) {
      bt = T_SHORT;
    }
    if (n->Opcode() == Op_LoadUB) {
      bt = T_BOOLEAN;
    }
    return Type::get_const_basic_type(bt);
  }
  const Type* t = _igvn.type(n);
  if (t->basic_type() == T_INT) {
    return TypeInt::INT;
  }
  return t;
}
bool SuperWord::same_velt_type(Node* n1, Node* n2) {
  const Type* vt1 = velt_type(n1);
  const Type* vt2 = velt_type(n2);
  if (vt1->basic_type() == T_INT && vt2->basic_type() == T_INT) {
    return data_size(n1) == data_size(n2);
  }
  return vt1 == vt2;
}
bool SuperWord::in_packset(Node* s1, Node* s2) {
  for (int i = 0; i < _packset.length(); i++) {
    Node_List* p = _packset.at(i);
    assert(p->size() == 2, "must be");
    if (p->at(0) == s1 && p->at(p->size()-1) == s2) {
      return true;
    }
  }
  return false;
}
Node_List* SuperWord::in_pack(Node* s, Node_List* p) {
  for (uint i = 0; i < p->size(); i++) {
    if (p->at(i) == s) {
      return p;
    }
  }
  return NULL;
}
void SuperWord::remove_pack_at(int pos) {
  Node_List* p = _packset.at(pos);
  for (uint i = 0; i < p->size(); i++) {
    Node* s = p->at(i);
    set_my_pack(s, NULL);
  }
  _packset.remove_at(pos);
}
Node* SuperWord::executed_first(Node_List* p) {
  Node* n = p->at(0);
  int n_rpo = bb_idx(n);
  for (uint i = 1; i < p->size(); i++) {
    Node* s = p->at(i);
    int s_rpo = bb_idx(s);
    if (s_rpo < n_rpo) {
      n = s;
      n_rpo = s_rpo;
    }
  }
  return n;
}
Node* SuperWord::executed_last(Node_List* p) {
  Node* n = p->at(0);
  int n_rpo = bb_idx(n);
  for (uint i = 1; i < p->size(); i++) {
    Node* s = p->at(i);
    int s_rpo = bb_idx(s);
    if (s_rpo > n_rpo) {
      n = s;
      n_rpo = s_rpo;
    }
  }
  return n;
}
LoadNode::ControlDependency SuperWord::control_dependency(Node_List* p) {
  LoadNode::ControlDependency dep = LoadNode::DependsOnlyOnTest;
  for (uint i = 0; i < p->size(); i++) {
    Node* n = p->at(i);
    assert(n->is_Load(), "only meaningful for loads");
    if (!n->depends_only_on_test()) {
      dep = LoadNode::Pinned;
    }
  }
  return dep;
}
void SuperWord::align_initial_loop_index(MemNode* align_to_ref) {
  CountedLoopNode *main_head = lp()->as_CountedLoop();
  assert(main_head->is_main_loop(), "");
  CountedLoopEndNode* pre_end = get_pre_loop_end(main_head);
  assert(pre_end != NULL, "we must have a correct pre-loop");
  Node *pre_opaq1 = pre_end->limit();
  assert(pre_opaq1->Opcode() == Op_Opaque1, "");
  Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1;
  Node *lim0 = pre_opaq->in(1);
  Node *pre_ctrl = pre_end->loopnode()->in(LoopNode::EntryControl);
  Node *orig_limit = pre_opaq->original_loop_limit();
  assert(orig_limit != NULL && _igvn.type(orig_limit) != Type::TOP, "");
  SWPointer align_to_ref_p(align_to_ref, this);
  assert(align_to_ref_p.valid(), "sanity");
  int vw = vector_width_in_bytes(align_to_ref);
  int stride   = iv_stride();
  int scale    = align_to_ref_p.scale_in_bytes();
  int elt_size = align_to_ref_p.memory_size();
  int v_align  = vw / elt_size;
  assert(v_align > 1, "sanity");
  int offset   = align_to_ref_p.offset_in_bytes() / elt_size;
  Node *offsn  = _igvn.intcon(offset);
  Node *e = offsn;
  if (align_to_ref_p.invar() != NULL) {
    Node* log2_elt = _igvn.intcon(exact_log2(elt_size));
    Node* aref     = new (_phase->C) URShiftINode(align_to_ref_p.invar(), log2_elt);
    _igvn.register_new_node_with_optimizer(aref);
    _phase->set_ctrl(aref, pre_ctrl);
    if (align_to_ref_p.negate_invar()) {
      e = new (_phase->C) SubINode(e, aref);
    } else {
      e = new (_phase->C) AddINode(e, aref);
    }
    _igvn.register_new_node_with_optimizer(e);
    _phase->set_ctrl(e, pre_ctrl);
  }
  if (vw > ObjectAlignmentInBytes) {
    Node* xbase = new(_phase->C) CastP2XNode(NULL, align_to_ref_p.base());
    _igvn.register_new_node_with_optimizer(xbase);
#ifdef _LP64
    xbase  = new (_phase->C) ConvL2INode(xbase);
    _igvn.register_new_node_with_optimizer(xbase);
#endif
    Node* mask = _igvn.intcon(vw-1);
    Node* masked_xbase  = new (_phase->C) AndINode(xbase, mask);
    _igvn.register_new_node_with_optimizer(masked_xbase);
    Node* log2_elt = _igvn.intcon(exact_log2(elt_size));
    Node* bref     = new (_phase->C) URShiftINode(masked_xbase, log2_elt);
    _igvn.register_new_node_with_optimizer(bref);
    _phase->set_ctrl(bref, pre_ctrl);
    e = new (_phase->C) AddINode(e, bref);
    _igvn.register_new_node_with_optimizer(e);
    _phase->set_ctrl(e, pre_ctrl);
  }
  if (scale < 0) {
    e = new (_phase->C) SubINode(e, lim0);
  } else {
    e = new (_phase->C) AddINode(e, lim0);
  }
  _igvn.register_new_node_with_optimizer(e);
  _phase->set_ctrl(e, pre_ctrl);
  if (stride * scale > 0) {
    Node* va  = _igvn.intcon(v_align);
    e = new (_phase->C) SubINode(va, e);
    _igvn.register_new_node_with_optimizer(e);
    _phase->set_ctrl(e, pre_ctrl);
  }
  Node* va_msk = _igvn.intcon(v_align - 1);
  Node* N = new (_phase->C) AndINode(e, va_msk);
  _igvn.register_new_node_with_optimizer(N);
  _phase->set_ctrl(N, pre_ctrl);
  Node* lim;
  if (stride < 0) {
    lim = new (_phase->C) SubINode(lim0, N);
  } else {
    lim = new (_phase->C) AddINode(lim0, N);
  }
  _igvn.register_new_node_with_optimizer(lim);
  _phase->set_ctrl(lim, pre_ctrl);
  Node* constrained =
    (stride > 0) ? (Node*) new (_phase->C) MinINode(lim, orig_limit)
                 : (Node*) new (_phase->C) MaxINode(lim, orig_limit);
  _igvn.register_new_node_with_optimizer(constrained);
  _phase->set_ctrl(constrained, pre_ctrl);
  _igvn.hash_delete(pre_opaq);
  pre_opaq->set_req(1, constrained);
}
CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode* cl) {
  if (!PhaseIdealLoop::is_canonical_main_loop_entry(cl)) {
    return NULL;
  }
  Node* p_f = cl->in(LoopNode::EntryControl)->in(0)->in(0);
  if (!p_f->is_IfFalse()) return NULL;
  if (!p_f->in(0)->is_CountedLoopEnd()) return NULL;
  CountedLoopEndNode* pre_end = p_f->in(0)->as_CountedLoopEnd();
  CountedLoopNode* loop_node = pre_end->loopnode();
  if (loop_node == NULL || !loop_node->is_pre_loop()) return NULL;
  return pre_end;
}
void SuperWord::init() {
  _dg.init();
  _packset.clear();
  _disjoint_ptrs.clear();
  _block.clear();
  _data_entry.clear();
  _mem_slice_head.clear();
  _mem_slice_tail.clear();
  _node_info.clear();
  _align_to_ref = NULL;
  _lpt = NULL;
  _lp = NULL;
  _bb = NULL;
  _iv = NULL;
}
void SuperWord::print_packset() {
#ifndef PRODUCT
  tty->print_cr("packset");
  for (int i = 0; i < _packset.length(); i++) {
    tty->print_cr("Pack: %d", i);
    Node_List* p = _packset.at(i);
    print_pack(p);
  }
#endif
}
void SuperWord::print_pack(Node_List* p) {
  for (uint i = 0; i < p->size(); i++) {
    print_stmt(p->at(i));
  }
}
void SuperWord::print_bb() {
#ifndef PRODUCT
  tty->print_cr("\nBlock");
  for (int i = 0; i < _block.length(); i++) {
    Node* n = _block.at(i);
    tty->print("%d ", i);
    if (n) {
      n->dump();
    }
  }
#endif
}
void SuperWord::print_stmt(Node* s) {
#ifndef PRODUCT
  tty->print(" align: %d \t", alignment(s));
  s->dump();
#endif
}
char* SuperWord::blank(uint depth) {
  static char blanks[101];
  assert(depth < 101, "too deep");
  for (uint i = 0; i < depth; i++) blanks[i] = ' ';
  blanks[depth] = '\0';
  return blanks;
}
SWPointer::SWPointer(MemNode* mem, SuperWord* slp) :
  _mem(mem), _slp(slp),  _base(NULL),  _adr(NULL),
  _scale(0), _offset(0), _invar(NULL), _negate_invar(false) {
  Node* adr = mem->in(MemNode::Address);
  if (!adr->is_AddP()) {
    assert(!valid(), "too complex");
    return;
  }
  Node* base = adr->in(AddPNode::Base);
  if (!invariant(base)) {
    assert(!valid(), "base address is loop variant");
    return;
  }
  if (base == NULL || base->bottom_type() == Type::TOP) {
    assert(!valid(), "unsafe access");
    return;
  }
  for (int i = 0; i < 3; i++) {
    if (!scaled_iv_plus_offset(adr->in(AddPNode::Offset))) {
      assert(!valid(), "too complex");
      return;
    }
    adr = adr->in(AddPNode::Address);
    if (base == adr || !adr->is_AddP()) {
      break; // stop looking at addp's
    }
  }
  _base = base;
  _adr  = adr;
  assert(valid(), "Usable");
}
SWPointer::SWPointer(SWPointer* p) :
  _mem(p->_mem), _slp(p->_slp),  _base(NULL),  _adr(NULL),
  _scale(0), _offset(0), _invar(NULL), _negate_invar(false) {}
bool SWPointer::scaled_iv_plus_offset(Node* n) {
  if (scaled_iv(n)) {
    return true;
  }
  if (offset_plus_k(n)) {
    return true;
  }
  int opc = n->Opcode();
  if (opc == Op_AddI) {
    if (scaled_iv(n->in(1)) && offset_plus_k(n->in(2))) {
      return true;
    }
    if (scaled_iv(n->in(2)) && offset_plus_k(n->in(1))) {
      return true;
    }
  } else if (opc == Op_SubI) {
    if (scaled_iv(n->in(1)) && offset_plus_k(n->in(2), true)) {
      return true;
    }
    if (scaled_iv(n->in(2)) && offset_plus_k(n->in(1))) {
      _scale *= -1;
      return true;
    }
  }
  return false;
}
bool SWPointer::scaled_iv(Node* n) {
  if (_scale != 0) {
    return false;  // already found a scale
  }
  if (n == iv()) {
    _scale = 1;
    return true;
  }
  int opc = n->Opcode();
  if (opc == Op_MulI) {
    if (n->in(1) == iv() && n->in(2)->is_Con()) {
      _scale = n->in(2)->get_int();
      return true;
    } else if (n->in(2) == iv() && n->in(1)->is_Con()) {
      _scale = n->in(1)->get_int();
      return true;
    }
  } else if (opc == Op_LShiftI) {
    if (n->in(1) == iv() && n->in(2)->is_Con()) {
      _scale = 1 << n->in(2)->get_int();
      return true;
    }
  } else if (opc == Op_ConvI2L) {
    if (n->in(1)->Opcode() == Op_CastII &&
        n->in(1)->as_CastII()->has_range_check()) {
      n = n->in(1);
    }
    if (scaled_iv_plus_offset(n->in(1))) {
      return true;
    }
  } else if (opc == Op_LShiftL) {
    if (!has_iv() && _invar == NULL) {
      SWPointer tmp(this);
      if (tmp.scaled_iv_plus_offset(n->in(1))) {
        if (tmp._invar == NULL) {
          int mult = 1 << n->in(2)->get_int();
          _scale   = tmp._scale  * mult;
          _offset += tmp._offset * mult;
          return true;
        }
      }
    }
  }
  return false;
}
bool SWPointer::offset_plus_k(Node* n, bool negate) {
  int opc = n->Opcode();
  if (opc == Op_ConI) {
    _offset += negate ? -(n->get_int()) : n->get_int();
    return true;
  } else if (opc == Op_ConL) {
    const TypeLong* t = n->find_long_type();
    if (t->higher_equal(TypeLong::INT)) {
      jlong loff = n->get_long();
      jint  off  = (jint)loff;
      _offset += negate ? -off : loff;
      return true;
    }
    return false;
  }
  if (_invar != NULL) return false; // already have an invariant
  if (opc == Op_AddI) {
    if (n->in(2)->is_Con() && invariant(n->in(1))) {
      _negate_invar = negate;
      _invar = n->in(1);
      _offset += negate ? -(n->in(2)->get_int()) : n->in(2)->get_int();
      return true;
    } else if (n->in(1)->is_Con() && invariant(n->in(2))) {
      _offset += negate ? -(n->in(1)->get_int()) : n->in(1)->get_int();
      _negate_invar = negate;
      _invar = n->in(2);
      return true;
    }
  }
  if (opc == Op_SubI) {
    if (n->in(2)->is_Con() && invariant(n->in(1))) {
      _negate_invar = negate;
      _invar = n->in(1);
      _offset += !negate ? -(n->in(2)->get_int()) : n->in(2)->get_int();
      return true;
    } else if (n->in(1)->is_Con() && invariant(n->in(2))) {
      _offset += negate ? -(n->in(1)->get_int()) : n->in(1)->get_int();
      _negate_invar = !negate;
      _invar = n->in(2);
      return true;
    }
  }
  if (invariant(n)) {
    _negate_invar = negate;
    _invar = n;
    return true;
  }
  return false;
}
void SWPointer::print() {
#ifndef PRODUCT
  tty->print("base: %d  adr: %d  scale: %d  offset: %d  invar: %c%d\n",
             _base != NULL ? _base->_idx : 0,
             _adr  != NULL ? _adr->_idx  : 0,
             _scale, _offset,
             _negate_invar?'-':'+',
             _invar != NULL ? _invar->_idx : 0);
#endif
}
const OrderedPair OrderedPair::initial;
const SWNodeInfo SWNodeInfo::initial;
DepMem* DepGraph::make_node(Node* node) {
  DepMem* m = new (_arena) DepMem(node);
  if (node != NULL) {
    assert(_map.at_grow(node->_idx) == NULL, "one init only");
    _map.at_put_grow(node->_idx, m);
  }
  return m;
}
DepEdge* DepGraph::make_edge(DepMem* dpred, DepMem* dsucc) {
  DepEdge* e = new (_arena) DepEdge(dpred, dsucc, dsucc->in_head(), dpred->out_head());
  dpred->set_out_head(e);
  dsucc->set_in_head(e);
  return e;
}
int DepMem::in_cnt() {
  int ct = 0;
  for (DepEdge* e = _in_head; e != NULL; e = e->next_in()) ct++;
  return ct;
}
int DepMem::out_cnt() {
  int ct = 0;
  for (DepEdge* e = _out_head; e != NULL; e = e->next_out()) ct++;
  return ct;
}
void DepMem::print() {
#ifndef PRODUCT
  tty->print("  DepNode %d (", _node->_idx);
  for (DepEdge* p = _in_head; p != NULL; p = p->next_in()) {
    Node* pred = p->pred()->node();
    tty->print(" %d", pred != NULL ? pred->_idx : 0);
  }
  tty->print(") [");
  for (DepEdge* s = _out_head; s != NULL; s = s->next_out()) {
    Node* succ = s->succ()->node();
    tty->print(" %d", succ != NULL ? succ->_idx : 0);
  }
  tty->print_cr(" ]");
#endif
}
void DepEdge::print() {
#ifndef PRODUCT
  tty->print_cr("DepEdge: %d [ %d ]", _pred->node()->_idx, _succ->node()->_idx);
#endif
}
DepPreds::DepPreds(Node* n, DepGraph& dg) {
  _n = n;
  _done = false;
  if (_n->is_Store() || _n->is_Load()) {
    _next_idx = MemNode::Address;
    _end_idx  = n->req();
    _dep_next = dg.dep(_n)->in_head();
  } else if (_n->is_Mem()) {
    _next_idx = 0;
    _end_idx  = 0;
    _dep_next = dg.dep(_n)->in_head();
  } else {
    _next_idx = 1;
    _end_idx  = _n->req();
    _dep_next = NULL;
  }
  next();
}
void DepPreds::next() {
  if (_dep_next != NULL) {
    _current  = _dep_next->pred()->node();
    _dep_next = _dep_next->next_in();
  } else if (_next_idx < _end_idx) {
    _current  = _n->in(_next_idx++);
  } else {
    _done = true;
  }
}
DepSuccs::DepSuccs(Node* n, DepGraph& dg) {
  _n = n;
  _done = false;
  if (_n->is_Load()) {
    _next_idx = 0;
    _end_idx  = _n->outcnt();
    _dep_next = dg.dep(_n)->out_head();
  } else if (_n->is_Mem() || _n->is_Phi() && _n->bottom_type() == Type::MEMORY) {
    _next_idx = 0;
    _end_idx  = 0;
    _dep_next = dg.dep(_n)->out_head();
  } else {
    _next_idx = 0;
    _end_idx  = _n->outcnt();
    _dep_next = NULL;
  }
  next();
}
void DepSuccs::next() {
  if (_dep_next != NULL) {
    _current  = _dep_next->succ()->node();
    _dep_next = _dep_next->next_out();
  } else if (_next_idx < _end_idx) {
    _current  = _n->raw_out(_next_idx++);
  } else {
    _done = true;
  }
}
C:\hotspot-69087d08d473\src\share\vm/opto/superword.hpp
#ifndef SHARE_VM_OPTO_SUPERWORD_HPP
#define SHARE_VM_OPTO_SUPERWORD_HPP
#include "opto/connode.hpp"
#include "opto/loopnode.hpp"
#include "opto/node.hpp"
#include "opto/phaseX.hpp"
#include "opto/vectornode.hpp"
#include "utilities/growableArray.hpp"
class SWPointer;
class OrderedPair;
class DepMem;
class DepEdge : public ResourceObj {
 protected:
  DepMem* _pred;
  DepMem* _succ;
  DepEdge* _next_in;   // list of in edges, null terminated
  DepEdge* _next_out;  // list of out edges, null terminated
 public:
  DepEdge(DepMem* pred, DepMem* succ, DepEdge* next_in, DepEdge* next_out) :
    _pred(pred), _succ(succ), _next_in(next_in), _next_out(next_out) {}
  DepEdge* next_in()  { return _next_in; }
  DepEdge* next_out() { return _next_out; }
  DepMem*  pred()     { return _pred; }
  DepMem*  succ()     { return _succ; }
  void print();
};
class DepMem : public ResourceObj {
 protected:
  Node*    _node;     // Corresponding ideal node
  DepEdge* _in_head;  // Head of list of in edges, null terminated
  DepEdge* _out_head; // Head of list of out edges, null terminated
 public:
  DepMem(Node* node) : _node(node), _in_head(NULL), _out_head(NULL) {}
  Node*    node()                { return _node;     }
  DepEdge* in_head()             { return _in_head;  }
  DepEdge* out_head()            { return _out_head; }
  void set_in_head(DepEdge* hd)  { _in_head = hd;    }
  void set_out_head(DepEdge* hd) { _out_head = hd;   }
  int in_cnt();  // Incoming edge count
  int out_cnt(); // Outgoing edge count
  void print();
};
class DepGraph VALUE_OBJ_CLASS_SPEC {
 protected:
  Arena* _arena;
  GrowableArray<DepMem*> _map;
  DepMem* _root;
  DepMem* _tail;
 public:
  DepGraph(Arena* a) : _arena(a), _map(a, 8,  0, NULL) {
    _root = new (_arena) DepMem(NULL);
    _tail = new (_arena) DepMem(NULL);
  }
  DepMem* root() { return _root; }
  DepMem* tail() { return _tail; }
  DepMem* dep(Node* node) { return _map.at(node->_idx); }
  DepMem* make_node(Node* node);
  DepEdge* make_edge(DepMem* dpred, DepMem* dsucc);
  DepEdge* make_edge(Node* pred,   Node* succ)   { return make_edge(dep(pred), dep(succ)); }
  DepEdge* make_edge(DepMem* pred, Node* succ)   { return make_edge(pred,      dep(succ)); }
  DepEdge* make_edge(Node* pred,   DepMem* succ) { return make_edge(dep(pred), succ);      }
  void init() { _map.clear(); } // initialize
  void print(Node* n)   { dep(n)->print(); }
  void print(DepMem* d) { d->print(); }
};
class DepPreds : public StackObj {
private:
  Node*    _n;
  int      _next_idx, _end_idx;
  DepEdge* _dep_next;
  Node*    _current;
  bool     _done;
public:
  DepPreds(Node* n, DepGraph& dg);
  Node* current() { return _current; }
  bool  done()    { return _done; }
  void  next();
};
class DepSuccs : public StackObj {
private:
  Node*    _n;
  int      _next_idx, _end_idx;
  DepEdge* _dep_next;
  Node*    _current;
  bool     _done;
public:
  DepSuccs(Node* n, DepGraph& dg);
  Node* current() { return _current; }
  bool  done()    { return _done; }
  void  next();
};
class SWNodeInfo VALUE_OBJ_CLASS_SPEC {
 public:
  int         _alignment; // memory alignment for a node
  int         _depth;     // Max expression (DAG) depth from block start
  const Type* _velt_type; // vector element type
  Node_List*  _my_pack;   // pack containing this node
  SWNodeInfo() : _alignment(-1), _depth(0), _velt_type(NULL), _my_pack(NULL) {}
  static const SWNodeInfo initial;
};
class OrderedPair VALUE_OBJ_CLASS_SPEC {
 protected:
  Node* _p1;
  Node* _p2;
 public:
  OrderedPair() : _p1(NULL), _p2(NULL) {}
  OrderedPair(Node* p1, Node* p2) {
    if (p1->_idx < p2->_idx) {
      _p1 = p1; _p2 = p2;
    } else {
      _p1 = p2; _p2 = p1;
    }
  }
  bool operator==(const OrderedPair &rhs) {
    return _p1 == rhs._p1 && _p2 == rhs._p2;
  }
  void print() { tty->print("  (%d, %d)", _p1->_idx, _p2->_idx); }
  static const OrderedPair initial;
};
class SuperWord : public ResourceObj {
 private:
  PhaseIdealLoop* _phase;
  Arena*          _arena;
  PhaseIterGVN   &_igvn;
  enum consts { top_align = -1, bottom_align = -666 };
  GrowableArray<Node_List*> _packset;    // Packs for the current block
  GrowableArray<int> _bb_idx;            // Map from Node _idx to index within block
  GrowableArray<Node*> _block;           // Nodes in current block
  GrowableArray<Node*> _data_entry;      // Nodes with all inputs from outside
  GrowableArray<Node*> _mem_slice_head;  // Memory slice head nodes
  GrowableArray<Node*> _mem_slice_tail;  // Memory slice tail nodes
  GrowableArray<SWNodeInfo> _node_info;  // Info needed per node
  MemNode* _align_to_ref;                // Memory reference that pre-loop will align to
  GrowableArray<OrderedPair> _disjoint_ptrs; // runtime disambiguated pointer pairs
  DepGraph _dg; // Dependence graph
  VectorSet    _visited;       // Visited set
  VectorSet    _post_visited;  // Post-visited set
  Node_Stack   _n_idx_list;    // List of (node,index) pairs
  GrowableArray<Node*> _nlist; // List of nodes
  GrowableArray<Node*> _stk;   // Stack of nodes
 public:
  SuperWord(PhaseIdealLoop* phase);
  void transform_loop(IdealLoopTree* lpt);
  PhaseIdealLoop* phase()          { return _phase; }
  IdealLoopTree* lpt()             { return _lpt; }
  PhiNode* iv()                    { return _iv; }
 private:
  IdealLoopTree* _lpt;             // Current loop tree node
  LoopNode*      _lp;              // Current LoopNode
  Node*          _bb;              // Current basic block
  PhiNode*       _iv;              // Induction var
  Arena* arena()                   { return _arena; }
  Node* bb()                       { return _bb; }
  void  set_bb(Node* bb)           { _bb = bb; }
  void set_lpt(IdealLoopTree* lpt) { _lpt = lpt; }
  LoopNode* lp()                   { return _lp; }
  void      set_lp(LoopNode* lp)   { _lp = lp;
                                     _iv = lp->as_CountedLoop()->phi()->as_Phi(); }
  int      iv_stride()             { return lp()->as_CountedLoop()->stride_con(); }
  int vector_width(Node* n) {
    BasicType bt = velt_basic_type(n);
    return MIN2(ABS(iv_stride()), Matcher::max_vector_size(bt));
  }
  int vector_width_in_bytes(Node* n) {
    BasicType bt = velt_basic_type(n);
    return vector_width(n)*type2aelembytes(bt);
  }
  MemNode* align_to_ref()            { return _align_to_ref; }
  void  set_align_to_ref(MemNode* m) { _align_to_ref = m; }
  Node* ctrl(Node* n) const { return _phase->has_ctrl(n) ? _phase->get_ctrl(n) : n; }
  bool in_bb(Node* n)      { return n != NULL && n->outcnt() > 0 && ctrl(n) == _bb; }
  int  bb_idx(Node* n)     { assert(in_bb(n), "must be"); return _bb_idx.at(n->_idx); }
  void set_bb_idx(Node* n, int i) { _bb_idx.at_put_grow(n->_idx, i); }
  void visited_clear()           { _visited.Clear(); }
  void visited_set(Node* n)      { return _visited.set(bb_idx(n)); }
  int visited_test(Node* n)      { return _visited.test(bb_idx(n)); }
  int visited_test_set(Node* n)  { return _visited.test_set(bb_idx(n)); }
  void post_visited_clear()      { _post_visited.Clear(); }
  void post_visited_set(Node* n) { return _post_visited.set(bb_idx(n)); }
  int post_visited_test(Node* n) { return _post_visited.test(bb_idx(n)); }
  void grow_node_info(int i) { if (i >= _node_info.length()) _node_info.at_put_grow(i, SWNodeInfo::initial); }
  int alignment(Node* n)                     { return _node_info.adr_at(bb_idx(n))->_alignment; }
  void set_alignment(Node* n, int a)         { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_alignment = a; }
  int depth(Node* n)                         { return _node_info.adr_at(bb_idx(n))->_depth; }
  void set_depth(Node* n, int d)             { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_depth = d; }
  const Type* velt_type(Node* n)             { return _node_info.adr_at(bb_idx(n))->_velt_type; }
  BasicType velt_basic_type(Node* n)         { return velt_type(n)->array_element_basic_type(); }
  void set_velt_type(Node* n, const Type* t) { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_velt_type = t; }
  bool same_velt_type(Node* n1, Node* n2);
  Node_List* my_pack(Node* n)                { return !in_bb(n) ? NULL : _node_info.adr_at(bb_idx(n))->_my_pack; }
  void set_my_pack(Node* n, Node_List* p)    { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_my_pack = p; }
  void SLP_extract();
  void find_adjacent_refs();
  MemNode* find_align_to_ref(Node_List &memops);
  int get_iv_adjustment(MemNode* mem);
  bool ref_is_alignable(SWPointer& p);
  void dependence_graph();
  void mem_slice_preds(Node* start, Node* stop, GrowableArray<Node*> &preds);
  bool stmts_can_pack(Node* s1, Node* s2, int align);
  bool exists_at(Node* s, uint pos);
  bool are_adjacent_refs(Node* s1, Node* s2);
  bool isomorphic(Node* s1, Node* s2);
  bool independent(Node* s1, Node* s2);
  bool independent_path(Node* shallow, Node* deep, uint dp=0);
  void set_alignment(Node* s1, Node* s2, int align);
  int data_size(Node* s);
  void extend_packlist();
  bool follow_use_defs(Node_List* p);
  bool follow_def_uses(Node_List* p);
  int est_savings(Node* s1, Node* s2);
  int adjacent_profit(Node* s1, Node* s2);
  int pack_cost(int ct);
  int unpack_cost(int ct);
  void combine_packs();
  void construct_my_pack_map();
  void filter_packs();
  void schedule();
  void remove_and_insert(MemNode *current, MemNode *prev, MemNode *lip, Node *uip, Unique_Node_List &schd_before);
  void co_locate_pack(Node_List* p);
  void output();
  Node* vector_opd(Node_List* p, int opd_idx);
  bool implemented(Node_List* p);
  bool profitable(Node_List* p);
  void insert_extracts(Node_List* p);
  bool is_vector_use(Node* use, int u_idx);
  bool construct_bb();
  void initialize_bb();
  void bb_insert_after(Node* n, int pos);
  void compute_max_depth();
  void compute_vector_element_type();
  bool in_packset(Node* s1, Node* s2);
  Node_List* in_pack(Node* s, Node_List* p);
  void remove_pack_at(int pos);
  Node* executed_first(Node_List* p);
  Node* executed_last(Node_List* p);
  static LoadNode::ControlDependency control_dependency(Node_List* p);
  int memory_alignment(MemNode* s, int iv_adjust);
  void vector_opd_range(Node* n, uint* start, uint* end);
  const Type* container_type(Node* n);
  void align_initial_loop_index(MemNode* align_to_ref);
  CountedLoopEndNode* get_pre_loop_end(CountedLoopNode *cl);
  bool opnd_positions_match(Node* d1, Node* u1, Node* d2, Node* u2);
  void init();
  void print_packset();
  void print_pack(Node_List* p);
  void print_bb();
  void print_stmt(Node* s);
  char* blank(uint depth);
};
class SWPointer VALUE_OBJ_CLASS_SPEC {
 protected:
  MemNode*   _mem;     // My memory reference node
  SuperWord* _slp;     // SuperWord class
  Node* _base;         // NULL if unsafe nonheap reference
  Node* _adr;          // address pointer
  jint  _scale;        // multiplier for iv (in bytes), 0 if no loop iv
  jint  _offset;       // constant offset (in bytes)
  Node* _invar;        // invariant offset (in bytes), NULL if none
  bool  _negate_invar; // if true then use: (0 - _invar)
  PhaseIdealLoop* phase() { return _slp->phase(); }
  IdealLoopTree*  lpt()   { return _slp->lpt(); }
  PhiNode*        iv()    { return _slp->iv();  } // Induction var
  bool invariant(Node* n) {
    Node *n_c = phase()->get_ctrl(n);
    return !lpt()->is_member(phase()->get_loop(n_c));
  }
  bool scaled_iv_plus_offset(Node* n);
  bool scaled_iv(Node* n);
  bool offset_plus_k(Node* n, bool negate = false);
 public:
  enum CMP {
    Less          = 1,
    Greater       = 2,
    Equal         = 4,
    NotEqual      = (Less | Greater),
    NotComparable = (Less | Greater | Equal)
  };
  SWPointer(MemNode* mem, SuperWord* slp);
  SWPointer(SWPointer* p);
  bool valid()  { return _adr != NULL; }
  bool has_iv() { return _scale != 0; }
  Node* base()            { return _base; }
  Node* adr()             { return _adr; }
  MemNode* mem()          { return _mem; }
  int   scale_in_bytes()  { return _scale; }
  Node* invar()           { return _invar; }
  bool  negate_invar()    { return _negate_invar; }
  int   offset_in_bytes() { return _offset; }
  int   memory_size()     { return _mem->memory_size(); }
  int cmp(SWPointer& q) {
    if (valid() && q.valid() &&
        (_adr == q._adr || _base == _adr && q._base == q._adr) &&
        _scale == q._scale   &&
        _invar == q._invar   &&
        _negate_invar == q._negate_invar) {
      bool overlap = q._offset <   _offset +   memory_size() &&
                       _offset < q._offset + q.memory_size();
      return overlap ? Equal : (_offset < q._offset ? Less : Greater);
    } else {
      return NotComparable;
    }
  }
  bool not_equal(SWPointer& q)    { return not_equal(cmp(q)); }
  bool equal(SWPointer& q)        { return equal(cmp(q)); }
  bool comparable(SWPointer& q)   { return comparable(cmp(q)); }
  static bool not_equal(int cmp)  { return cmp <= NotEqual; }
  static bool equal(int cmp)      { return cmp == Equal; }
  static bool comparable(int cmp) { return cmp < NotComparable; }
  void print();
};
#endif // SHARE_VM_OPTO_SUPERWORD_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/type.cpp
#include "precompiled.hpp"
#include "ci/ciMethodData.hpp"
#include "ci/ciTypeFlow.hpp"
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "compiler/compileLog.hpp"
#include "libadt/dict.hpp"
#include "memory/gcLocker.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/instanceMirrorKlass.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/typeArrayKlass.hpp"
#include "opto/matcher.hpp"
#include "opto/node.hpp"
#include "opto/opcodes.hpp"
#include "opto/type.hpp"
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
Dict* Type::_shared_type_dict = NULL;
const Type::TypeInfo Type::_type_info[Type::lastype] = {
  { Bad,             T_ILLEGAL,    "bad",           false, Node::NotAMachineReg, relocInfo::none          },  // Bad
  { Control,         T_ILLEGAL,    "control",       false, 0,                    relocInfo::none          },  // Control
  { Bottom,          T_VOID,       "top",           false, 0,                    relocInfo::none          },  // Top
  { Bad,             T_INT,        "int:",          false, Op_RegI,              relocInfo::none          },  // Int
  { Bad,             T_LONG,       "long:",         false, Op_RegL,              relocInfo::none          },  // Long
  { Half,            T_VOID,       "half",          false, 0,                    relocInfo::none          },  // Half
  { Bad,             T_NARROWOOP,  "narrowoop:",    false, Op_RegN,              relocInfo::none          },  // NarrowOop
  { Bad,             T_NARROWKLASS,"narrowklass:",  false, Op_RegN,              relocInfo::none          },  // NarrowKlass
  { Bad,             T_ILLEGAL,    "tuple:",        false, Node::NotAMachineReg, relocInfo::none          },  // Tuple
  { Bad,             T_ARRAY,      "array:",        false, Node::NotAMachineReg, relocInfo::none          },  // Array
#ifdef SPARC
  { Bad,             T_ILLEGAL,    "vectors:",      false, 0,                    relocInfo::none          },  // VectorS
  { Bad,             T_ILLEGAL,    "vectord:",      false, Op_RegD,              relocInfo::none          },  // VectorD
  { Bad,             T_ILLEGAL,    "vectorx:",      false, 0,                    relocInfo::none          },  // VectorX
  { Bad,             T_ILLEGAL,    "vectory:",      false, 0,                    relocInfo::none          },  // VectorY
#elif defined(PPC64)
  { Bad,             T_ILLEGAL,    "vectors:",      false, 0,                    relocInfo::none          },  // VectorS
  { Bad,             T_ILLEGAL,    "vectord:",      false, Op_RegL,              relocInfo::none          },  // VectorD
  { Bad,             T_ILLEGAL,    "vectorx:",      false, 0,                    relocInfo::none          },  // VectorX
  { Bad,             T_ILLEGAL,    "vectory:",      false, 0,                    relocInfo::none          },  // VectorY
#else // all other
  { Bad,             T_ILLEGAL,    "vectors:",      false, Op_VecS,              relocInfo::none          },  // VectorS
  { Bad,             T_ILLEGAL,    "vectord:",      false, Op_VecD,              relocInfo::none          },  // VectorD
  { Bad,             T_ILLEGAL,    "vectorx:",      false, Op_VecX,              relocInfo::none          },  // VectorX
  { Bad,             T_ILLEGAL,    "vectory:",      false, Op_VecY,              relocInfo::none          },  // VectorY
#endif
  { Bad,             T_ADDRESS,    "anyptr:",       false, Op_RegP,              relocInfo::none          },  // AnyPtr
  { Bad,             T_ADDRESS,    "rawptr:",       false, Op_RegP,              relocInfo::none          },  // RawPtr
  { Bad,             T_OBJECT,     "oop:",          true,  Op_RegP,              relocInfo::oop_type      },  // OopPtr
  { Bad,             T_OBJECT,     "inst:",         true,  Op_RegP,              relocInfo::oop_type      },  // InstPtr
  { Bad,             T_OBJECT,     "ary:",          true,  Op_RegP,              relocInfo::oop_type      },  // AryPtr
  { Bad,             T_METADATA,   "metadata:",     false, Op_RegP,              relocInfo::metadata_type },  // MetadataPtr
  { Bad,             T_METADATA,   "klass:",        false, Op_RegP,              relocInfo::metadata_type },  // KlassPtr
  { Bad,             T_OBJECT,     "func",          false, 0,                    relocInfo::none          },  // Function
  { Abio,            T_ILLEGAL,    "abIO",          false, 0,                    relocInfo::none          },  // Abio
  { Return_Address,  T_ADDRESS,    "return_address",false, Op_RegP,              relocInfo::none          },  // Return_Address
  { Memory,          T_ILLEGAL,    "memory",        false, 0,                    relocInfo::none          },  // Memory
  { FloatBot,        T_FLOAT,      "float_top",     false, Op_RegF,              relocInfo::none          },  // FloatTop
  { FloatCon,        T_FLOAT,      "ftcon:",        false, Op_RegF,              relocInfo::none          },  // FloatCon
  { FloatTop,        T_FLOAT,      "float",         false, Op_RegF,              relocInfo::none          },  // FloatBot
  { DoubleBot,       T_DOUBLE,     "double_top",    false, Op_RegD,              relocInfo::none          },  // DoubleTop
  { DoubleCon,       T_DOUBLE,     "dblcon:",       false, Op_RegD,              relocInfo::none          },  // DoubleCon
  { DoubleTop,       T_DOUBLE,     "double",        false, Op_RegD,              relocInfo::none          },  // DoubleBot
  { Top,             T_ILLEGAL,    "bottom",        false, 0,                    relocInfo::none          }   // Bottom
};
const Type *Type::mreg2type[_last_machine_leaf];
const Type* Type::     _const_basic_type[T_CONFLICT+1];
const Type* Type::            _zero_type[T_CONFLICT+1];
const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1];
const Type *Type::ABIO;         // State-of-machine only
const Type *Type::BOTTOM;       // All values
const Type *Type::CONTROL;      // Control only
const Type *Type::DOUBLE;       // All doubles
const Type *Type::FLOAT;        // All floats
const Type *Type::HALF;         // Placeholder half of doublewide type
const Type *Type::MEMORY;       // Abstract store only
const Type *Type::RETURN_ADDRESS;
const Type *Type::TOP;          // No values in set
const Type* Type::get_const_type(ciType* type) {
  if (type == NULL) {
    return NULL;
  } else if (type->is_primitive_type()) {
    return get_const_basic_type(type->basic_type());
  } else {
    return TypeOopPtr::make_from_klass(type->as_klass());
  }
}
BasicType Type::array_element_basic_type() const {
  BasicType bt = basic_type();
  if (bt == T_INT) {
    if (this == TypeInt::INT)   return T_INT;
    if (this == TypeInt::CHAR)  return T_CHAR;
    if (this == TypeInt::BYTE)  return T_BYTE;
    if (this == TypeInt::BOOL)  return T_BOOLEAN;
    if (this == TypeInt::SHORT) return T_SHORT;
    return T_VOID;
  }
  return bt;
}
void Type::get_arrays_base_elements(const Type *a1, const Type *a2,
                                    const TypeInstPtr **e1, const TypeInstPtr **e2) {
  if (e1) *e1 = NULL;
  if (e2) *e2 = NULL;
  const TypeAryPtr* a1tap = (a1 == NULL) ? NULL : a1->isa_aryptr();
  const TypeAryPtr* a2tap = (a2 == NULL) ? NULL : a2->isa_aryptr();
  if (a1tap != NULL && a2tap != NULL) {
    const TypePtr* a1tp = a1tap->elem()->make_ptr();
    const TypePtr* a2tp = a2tap->elem()->make_ptr();
    while (a1tp && a1tp->isa_aryptr() && a2tp && a2tp->isa_aryptr()) {
      a1tap = a1tp->is_aryptr();
      a2tap = a2tp->is_aryptr();
      a1tp = a1tap->elem()->make_ptr();
      a2tp = a2tap->elem()->make_ptr();
    }
    if (a1tp && a1tp->isa_instptr() && a2tp && a2tp->isa_instptr()) {
      if (e1) *e1 = a1tp->is_instptr();
      if (e2) *e2 = a2tp->is_instptr();
    }
  }
}
const Type* Type::get_typeflow_type(ciType* type) {
  switch (type->basic_type()) {
  case ciTypeFlow::StateVector::T_BOTTOM:
    assert(type == ciTypeFlow::StateVector::bottom_type(), "");
    return Type::BOTTOM;
  case ciTypeFlow::StateVector::T_TOP:
    assert(type == ciTypeFlow::StateVector::top_type(), "");
    return Type::TOP;
  case ciTypeFlow::StateVector::T_NULL:
    assert(type == ciTypeFlow::StateVector::null_type(), "");
    return TypePtr::NULL_PTR;
  case ciTypeFlow::StateVector::T_LONG2:
    assert(type == ciTypeFlow::StateVector::long2_type(), "");
    return TypeInt::TOP;
  case ciTypeFlow::StateVector::T_DOUBLE2:
    assert(type == ciTypeFlow::StateVector::double2_type(), "");
    return Type::TOP;
  case T_ADDRESS:
    assert(type->is_return_address(), "");
    return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci());
  default:
    assert(type != ciTypeFlow::StateVector::bottom_type(), "");
    assert(type != ciTypeFlow::StateVector::top_type(), "");
    assert(type != ciTypeFlow::StateVector::null_type(), "");
    assert(type != ciTypeFlow::StateVector::long2_type(), "");
    assert(type != ciTypeFlow::StateVector::double2_type(), "");
    assert(!type->is_return_address(), "");
    return Type::get_const_type(type);
  }
}
const Type* Type::make_from_constant(ciConstant constant,
                                     bool require_constant, bool is_autobox_cache) {
  switch (constant.basic_type()) {
  case T_BOOLEAN:  return TypeInt::make(constant.as_boolean());
  case T_CHAR:     return TypeInt::make(constant.as_char());
  case T_BYTE:     return TypeInt::make(constant.as_byte());
  case T_SHORT:    return TypeInt::make(constant.as_short());
  case T_INT:      return TypeInt::make(constant.as_int());
  case T_LONG:     return TypeLong::make(constant.as_long());
  case T_FLOAT:    return TypeF::make(constant.as_float());
  case T_DOUBLE:   return TypeD::make(constant.as_double());
  case T_ARRAY:
  case T_OBJECT:
    {
      ciObject* oop_constant = constant.as_object();
      if (oop_constant->is_null_object()) {
        return Type::get_zero_type(T_OBJECT);
      } else if (require_constant || oop_constant->should_be_constant()) {
        return TypeOopPtr::make_from_constant(oop_constant, require_constant, is_autobox_cache);
      }
    }
  }
  return NULL;
}
const Type *Type::make( enum TYPES t ) {
  return (new Type(t))->hashcons();
}
int Type::cmp( const Type *const t1, const Type *const t2 ) {
  if( t1->_base != t2->_base )
    return 1;                   // Missed badly
  assert(t1 != t2 || t1->eq(t2), "eq must be reflexive");
  return !t1->eq(t2);           // Return ZERO if equal
}
const Type* Type::maybe_remove_speculative(bool include_speculative) const {
  if (!include_speculative) {
    return remove_speculative();
  }
  return this;
}
int Type::uhash( const Type *const t ) {
  return t->hash();
}
#define SMALLINT ((juint)3)  // a value too insignificant to consider widening
void Type::Initialize_shared(Compile* current) {
  Arena* save = current->type_arena();
  Arena* shared_type_arena = new (mtCompiler)Arena(mtCompiler);
  current->set_type_arena(shared_type_arena);
  _shared_type_dict =
    new (shared_type_arena) Dict( (CmpKey)Type::cmp, (Hash)Type::uhash,
                                  shared_type_arena, 128 );
  current->set_type_dict(_shared_type_dict);
  CONTROL = make(Control);      // Control only
  TOP     = make(Top);          // No values in set
  MEMORY  = make(Memory);       // Abstract store only
  ABIO    = make(Abio);         // State-of-machine only
  RETURN_ADDRESS=make(Return_Address);
  FLOAT   = make(FloatBot);     // All floats
  DOUBLE  = make(DoubleBot);    // All doubles
  BOTTOM  = make(Bottom);       // Everything
  HALF    = make(Half);         // Placeholder half of doublewide type
  TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero)
  TypeF::ONE  = TypeF::make(1.0); // Float 1
  TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero)
  TypeD::ONE  = TypeD::make(1.0); // Double 1
  TypeInt::MINUS_1 = TypeInt::make(-1);  // -1
  TypeInt::ZERO    = TypeInt::make( 0);  //  0
  TypeInt::ONE     = TypeInt::make( 1);  //  1
  TypeInt::BOOL    = TypeInt::make(0,1,   WidenMin);  // 0 or 1, FALSE or TRUE.
  TypeInt::CC      = TypeInt::make(-1, 1, WidenMin);  // -1, 0 or 1, condition codes
  TypeInt::CC_LT   = TypeInt::make(-1,-1, WidenMin);  // == TypeInt::MINUS_1
  TypeInt::CC_GT   = TypeInt::make( 1, 1, WidenMin);  // == TypeInt::ONE
  TypeInt::CC_EQ   = TypeInt::make( 0, 0, WidenMin);  // == TypeInt::ZERO
  TypeInt::CC_LE   = TypeInt::make(-1, 0, WidenMin);
  TypeInt::CC_GE   = TypeInt::make( 0, 1, WidenMin);  // == TypeInt::BOOL
  TypeInt::BYTE    = TypeInt::make(-128,127,     WidenMin); // Bytes
  TypeInt::UBYTE   = TypeInt::make(0, 255,       WidenMin); // Unsigned Bytes
  TypeInt::CHAR    = TypeInt::make(0,65535,      WidenMin); // Java chars
  TypeInt::SHORT   = TypeInt::make(-32768,32767, WidenMin); // Java shorts
  TypeInt::POS     = TypeInt::make(0,max_jint,   WidenMin); // Non-neg values
  TypeInt::POS1    = TypeInt::make(1,max_jint,   WidenMin); // Positive values
  TypeInt::INT     = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
  TypeInt::SYMINT  = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range
  TypeInt::TYPE_DOMAIN  = TypeInt::INT;
  assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" );
  assert( TypeInt::CC_GT == TypeInt::ONE,     "types must match for CmpL to work" );
  assert( TypeInt::CC_EQ == TypeInt::ZERO,    "types must match for CmpL to work" );
  assert( TypeInt::CC_GE == TypeInt::BOOL,    "types must match for CmpL to work" );
  assert( (juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= SMALLINT, "CC is truly small");
  TypeLong::MINUS_1 = TypeLong::make(-1);        // -1
  TypeLong::ZERO    = TypeLong::make( 0);        //  0
  TypeLong::ONE     = TypeLong::make( 1);        //  1
  TypeLong::POS     = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values
  TypeLong::LONG    = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers
  TypeLong::INT     = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin);
  TypeLong::UINT    = TypeLong::make(0,(jlong)max_juint,WidenMin);
  TypeLong::TYPE_DOMAIN  = TypeLong::LONG;
  const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
  fboth[0] = Type::CONTROL;
  fboth[1] = Type::CONTROL;
  TypeTuple::IFBOTH = TypeTuple::make( 2, fboth );
  const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
  ffalse[0] = Type::CONTROL;
  ffalse[1] = Type::TOP;
  TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse );
  const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
  fneither[0] = Type::TOP;
  fneither[1] = Type::TOP;
  TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither );
  const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
  ftrue[0] = Type::TOP;
  ftrue[1] = Type::CONTROL;
  TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue );
  const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
  floop[0] = Type::CONTROL;
  floop[1] = TypeInt::INT;
  TypeTuple::LOOPBODY = TypeTuple::make( 2, floop );
  TypePtr::NULL_PTR= TypePtr::make( AnyPtr, TypePtr::Null, 0 );
  TypePtr::NOTNULL = TypePtr::make( AnyPtr, TypePtr::NotNull, OffsetBot );
  TypePtr::BOTTOM  = TypePtr::make( AnyPtr, TypePtr::BotPTR, OffsetBot );
  TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR );
  TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull );
  const Type **fmembar = TypeTuple::fields(0);
  TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar);
  const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
  fsc[0] = TypeInt::CC;
  fsc[1] = Type::MEMORY;
  TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc);
  TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
  TypeInstPtr::BOTTOM  = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass());
  TypeInstPtr::MIRROR  = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
  TypeInstPtr::MARK    = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass(),
                                           false, 0, oopDesc::mark_offset_in_bytes());
  TypeInstPtr::KLASS   = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass(),
                                           false, 0, oopDesc::klass_offset_in_bytes());
  TypeOopPtr::BOTTOM  = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot, NULL);
  TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot);
  TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
  TypeNarrowOop::BOTTOM   = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
  TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR );
  mreg2type[Op_Node] = Type::BOTTOM;
  mreg2type[Op_Set ] = 0;
  mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM;
  mreg2type[Op_RegI] = TypeInt::INT;
  mreg2type[Op_RegP] = TypePtr::BOTTOM;
  mreg2type[Op_RegF] = Type::FLOAT;
  mreg2type[Op_RegD] = Type::DOUBLE;
  mreg2type[Op_RegL] = TypeLong::LONG;
  mreg2type[Op_RegFlags] = TypeInt::CC;
  TypeAryPtr::RANGE   = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes());
  TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Type::OffsetBot);
#ifdef _LP64
  if (UseCompressedOops) {
    assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop");
    TypeAryPtr::OOPS  = TypeAryPtr::NARROWOOPS;
  } else
#endif
  {
    TypeAryPtr::OOPS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Type::OffsetBot);
  }
  TypeAryPtr::BYTES   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE      ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE),   true,  Type::OffsetBot);
  TypeAryPtr::SHORTS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT     ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT),  true,  Type::OffsetBot);
  TypeAryPtr::CHARS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR      ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR),   true,  Type::OffsetBot);
  TypeAryPtr::INTS    = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT       ,TypeInt::POS), ciTypeArrayKlass::make(T_INT),    true,  Type::OffsetBot);
  TypeAryPtr::LONGS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG     ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG),   true,  Type::OffsetBot);
  TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Type::OffsetBot);
  TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Type::OffsetBot);
  TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
  TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
  TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays
  TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
  TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
  TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
  TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
  TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
  TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
  TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
  TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
  TypeKlassPtr::OBJECT = TypeKlassPtr::make( TypePtr::NotNull, current->env()->Object_klass(), 0 );
  TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make( TypePtr::BotPTR, current->env()->Object_klass(), 0 );
  const Type **fi2c = TypeTuple::fields(2);
  fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
  fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
  TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
  const Type **intpair = TypeTuple::fields(2);
  intpair[0] = TypeInt::INT;
  intpair[1] = TypeInt::INT;
  TypeTuple::INT_PAIR = TypeTuple::make(2, intpair);
  const Type **longpair = TypeTuple::fields(2);
  longpair[0] = TypeLong::LONG;
  longpair[1] = TypeLong::LONG;
  TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair);
  const Type **intccpair = TypeTuple::fields(2);
  intccpair[0] = TypeInt::INT;
  intccpair[1] = TypeInt::CC;
  TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);
  const Type **longccpair = TypeTuple::fields(2);
  longccpair[0] = TypeLong::LONG;
  longccpair[1] = TypeInt::CC;
  TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair);
  _const_basic_type[T_NARROWOOP]   = TypeNarrowOop::BOTTOM;
  _const_basic_type[T_NARROWKLASS] = Type::BOTTOM;
  _const_basic_type[T_BOOLEAN]     = TypeInt::BOOL;
  _const_basic_type[T_CHAR]        = TypeInt::CHAR;
  _const_basic_type[T_BYTE]        = TypeInt::BYTE;
  _const_basic_type[T_SHORT]       = TypeInt::SHORT;
  _const_basic_type[T_INT]         = TypeInt::INT;
  _const_basic_type[T_LONG]        = TypeLong::LONG;
  _const_basic_type[T_FLOAT]       = Type::FLOAT;
  _const_basic_type[T_DOUBLE]      = Type::DOUBLE;
  _const_basic_type[T_OBJECT]      = TypeInstPtr::BOTTOM;
  _const_basic_type[T_ARRAY]       = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays
  _const_basic_type[T_VOID]        = TypePtr::NULL_PTR;   // reflection represents void this way
  _const_basic_type[T_ADDRESS]     = TypeRawPtr::BOTTOM;  // both interpreter return addresses & random raw ptrs
  _const_basic_type[T_CONFLICT]    = Type::BOTTOM;        // why not?
  _zero_type[T_NARROWOOP]   = TypeNarrowOop::NULL_PTR;
  _zero_type[T_NARROWKLASS] = TypeNarrowKlass::NULL_PTR;
  _zero_type[T_BOOLEAN]     = TypeInt::ZERO;     // false == 0
  _zero_type[T_CHAR]        = TypeInt::ZERO;     // '\0' == 0
  _zero_type[T_BYTE]        = TypeInt::ZERO;     // 0x00 == 0
  _zero_type[T_SHORT]       = TypeInt::ZERO;     // 0x0000 == 0
  _zero_type[T_INT]         = TypeInt::ZERO;
  _zero_type[T_LONG]        = TypeLong::ZERO;
  _zero_type[T_FLOAT]       = TypeF::ZERO;
  _zero_type[T_DOUBLE]      = TypeD::ZERO;
  _zero_type[T_OBJECT]      = TypePtr::NULL_PTR;
  _zero_type[T_ARRAY]       = TypePtr::NULL_PTR; // null array is null oop
  _zero_type[T_ADDRESS]     = TypePtr::NULL_PTR; // raw pointers use the same null
  _zero_type[T_VOID]        = Type::TOP;         // the only void value is no value at all
  _zero_type[T_CONFLICT]= NULL;
  if (Matcher::vector_size_supported(T_BYTE,4)) {
    TypeVect::VECTS = TypeVect::make(T_BYTE,4);
  }
  if (Matcher::vector_size_supported(T_FLOAT,2)) {
    TypeVect::VECTD = TypeVect::make(T_FLOAT,2);
  }
  if (Matcher::vector_size_supported(T_FLOAT,4)) {
    TypeVect::VECTX = TypeVect::make(T_FLOAT,4);
  }
  if (Matcher::vector_size_supported(T_FLOAT,8)) {
    TypeVect::VECTY = TypeVect::make(T_FLOAT,8);
  }
  mreg2type[Op_VecS] = TypeVect::VECTS;
  mreg2type[Op_VecD] = TypeVect::VECTD;
  mreg2type[Op_VecX] = TypeVect::VECTX;
  mreg2type[Op_VecY] = TypeVect::VECTY;
  current->set_type_arena(save);
  current->set_type_dict(NULL);
}
void Type::Initialize(Compile* current) {
  assert(current->type_arena() != NULL, "must have created type arena");
  if (_shared_type_dict == NULL) {
    Initialize_shared(current);
  }
  Arena* type_arena = current->type_arena();
  Dict *tdic = new (type_arena) Dict( (CmpKey)Type::cmp,(Hash)Type::uhash, type_arena, 128 );
  current->set_type_dict(tdic);
  DictI i(_shared_type_dict);
  for( ; i.test(); ++i ) {
    Type* t = (Type*)i._value;
    tdic->Insert(t,t);  // New Type, insert into Type table
  }
}
const Type *Type::hashcons(void) {
  debug_only(base());           // Check the assertion in Type::base().
  Dict *tdic = type_dict();
  Type* old = (Type*)(tdic->Insert(this, this, false));
  if( old ) {                   // Pre-existing Type?
    if( old != this )           // Yes, this guy is not the pre-existing?
      delete this;              // Yes, Nuke this guy
    assert( old->_dual, "" );
    return old;                 // Return pre-existing
  }
  assert( !_dual, "" );         // No dual yet
  _dual = xdual();              // Compute the dual
  if( cmp(this,_dual)==0 ) {    // Handle self-symmetric
    _dual = this;
    return this;
  }
  assert( !_dual->_dual, "" );  // No reverse dual yet
  assert( !(*tdic)[_dual], "" ); // Dual not in type system either
  tdic->Insert((void*)_dual,(void*)_dual);
  ((Type*)_dual)->_dual = this; // Finish up being symmetric
#ifdef ASSERT
  Type *dual_dual = (Type*)_dual->xdual();
  assert( eq(dual_dual), "xdual(xdual()) should be identity" );
  delete dual_dual;
#endif
  return this;                  // Return new Type
}
bool Type::eq( const Type * ) const {
  return true;                  // Nothing else can go wrong
}
int Type::hash(void) const {
  return _base;
}
bool Type::is_finite() const {
  return false;
}
bool Type::is_nan()    const {
  return false;
}
#ifdef ASSERT
bool Type::interface_vs_oop_helper(const Type *t) const {
  bool result = false;
  const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop
  const TypePtr*    t_ptr =    t->make_ptr();
  if( this_ptr == NULL || t_ptr == NULL )
    return result;
  const TypeInstPtr* this_inst = this_ptr->isa_instptr();
  const TypeInstPtr*    t_inst =    t_ptr->isa_instptr();
  if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) {
    bool this_interface = this_inst->klass()->is_interface();
    bool    t_interface =    t_inst->klass()->is_interface();
    result = this_interface ^ t_interface;
  }
  return result;
}
bool Type::interface_vs_oop(const Type *t) const {
  if (interface_vs_oop_helper(t)) {
    return true;
  }
  const TypeOopPtr* this_spec = isa_oopptr() != NULL ? isa_oopptr()->speculative() : NULL;
  const TypeOopPtr* t_spec = t->isa_oopptr() != NULL ? t->isa_oopptr()->speculative() : NULL;
  if (this_spec != NULL && t_spec != NULL) {
    if (this_spec->interface_vs_oop_helper(t_spec)) {
      return true;
    }
    return false;
  }
  if (this_spec != NULL && this_spec->interface_vs_oop_helper(t)) {
    return true;
  }
  if (t_spec != NULL && interface_vs_oop_helper(t_spec)) {
    return true;
  }
  return false;
}
#endif
void Type::check_symmetrical(const Type *t, const Type *mt) const {
#ifdef ASSERT
  assert(mt == t->xmeet(this), "meet not commutative");
  const Type* dual_join = mt->_dual;
  const Type *t2t    = dual_join->xmeet(t->_dual);
  const Type *t2this = dual_join->xmeet(this->_dual);
  if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != this->_dual) ) {
    tty->print_cr("=== Meet Not Symmetric ===");
    tty->print("t   =                   ");              t->dump(); tty->cr();
    tty->print("this=                   ");                 dump(); tty->cr();
    tty->print("mt=(t meet this)=       ");             mt->dump(); tty->cr();
    tty->print("t_dual=                 ");       t->_dual->dump(); tty->cr();
    tty->print("this_dual=              ");          _dual->dump(); tty->cr();
    tty->print("mt_dual=                ");      mt->_dual->dump(); tty->cr();
    tty->print("mt_dual meet t_dual=    "); t2t           ->dump(); tty->cr();
    tty->print("mt_dual meet this_dual= "); t2this        ->dump(); tty->cr();
    fatal("meet not symmetric" );
  }
#endif
}
const Type *Type::meet_helper(const Type *t, bool include_speculative) const {
  if (isa_narrowoop() && t->isa_narrowoop()) {
    const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative);
    return result->make_narrowoop();
  }
  if (isa_narrowklass() && t->isa_narrowklass()) {
    const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative);
    return result->make_narrowklass();
  }
  const Type *this_t = maybe_remove_speculative(include_speculative);
  t = t->maybe_remove_speculative(include_speculative);
  const Type *mt = this_t->xmeet(t);
#ifdef ASSERT
  if (isa_narrowoop() || t->isa_narrowoop()) return mt;
  if (isa_narrowklass() || t->isa_narrowklass()) return mt;
  Compile* C = Compile::current();
  if (!C->_type_verify_symmetry) {
    return mt;
  }
  this_t->check_symmetrical(t, mt);
  C->_type_verify_symmetry = false;
  const Type *mt_dual = this_t->_dual->xmeet(t->_dual);
  this_t->_dual->check_symmetrical(t->_dual, mt_dual);
  assert(!C->_type_verify_symmetry, "shouldn't have changed");
  C->_type_verify_symmetry = true;
#endif
  return mt;
}
const Type *Type::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  if( _base == Top ) return t;
  if( _base == Bottom ) return BOTTOM;
  switch (t->base()) {  // Switch on original type
  case FloatCon:
  case DoubleCon:
  case Int:
  case Long:
    return t->xmeet(this);
  case OopPtr:
    return t->xmeet(this);
  case InstPtr:
    return t->xmeet(this);
  case MetadataPtr:
  case KlassPtr:
    return t->xmeet(this);
  case AryPtr:
    return t->xmeet(this);
  case NarrowOop:
    return t->xmeet(this);
  case NarrowKlass:
    return t->xmeet(this);
  case Bad:                     // Type check
  default:                      // Bogus type not in lattice
    typerr(t);
    return Type::BOTTOM;
  case Bottom:                  // Ye Olde Default
    return t;
  case FloatTop:
    if( _base == FloatTop ) return this;
  case FloatBot:                // Float
    if( _base == FloatBot || _base == FloatTop ) return FLOAT;
    if( _base == DoubleTop || _base == DoubleBot ) return Type::BOTTOM;
    typerr(t);
    return Type::BOTTOM;
  case DoubleTop:
    if( _base == DoubleTop ) return this;
  case DoubleBot:               // Double
    if( _base == DoubleBot || _base == DoubleTop ) return DOUBLE;
    if( _base == FloatTop || _base == FloatBot ) return Type::BOTTOM;
    typerr(t);
    return Type::BOTTOM;
  case Control:                 // Control of code
  case Abio:                    // State of world outside of program
  case Memory:
    if( _base == t->_base )  return this;
    typerr(t);
    return Type::BOTTOM;
  case Top:                     // Top of the lattice
    return this;
  }
  return this;
}
const Type *Type::filter_helper(const Type *kills, bool include_speculative) const {
  const Type* ft = join_helper(kills, include_speculative);
  if (ft->empty())
    return Type::TOP;           // Canonical empty value
  return ft;
}
const Type::TYPES Type::dual_type[Type::lastype] = {
  Bad,          // Bad
  Control,      // Control
  Bottom,       // Top
  Bad,          // Int - handled in v-call
  Bad,          // Long - handled in v-call
  Half,         // Half
  Bad,          // NarrowOop - handled in v-call
  Bad,          // NarrowKlass - handled in v-call
  Bad,          // Tuple - handled in v-call
  Bad,          // Array - handled in v-call
  Bad,          // VectorS - handled in v-call
  Bad,          // VectorD - handled in v-call
  Bad,          // VectorX - handled in v-call
  Bad,          // VectorY - handled in v-call
  Bad,          // AnyPtr - handled in v-call
  Bad,          // RawPtr - handled in v-call
  Bad,          // OopPtr - handled in v-call
  Bad,          // InstPtr - handled in v-call
  Bad,          // AryPtr - handled in v-call
  Bad,          //  MetadataPtr - handled in v-call
  Bad,          // KlassPtr - handled in v-call
  Bad,          // Function - handled in v-call
  Abio,         // Abio
  Return_Address,// Return_Address
  Memory,       // Memory
  FloatBot,     // FloatTop
  FloatCon,     // FloatCon
  FloatTop,     // FloatBot
  DoubleBot,    // DoubleTop
  DoubleCon,    // DoubleCon
  DoubleTop,    // DoubleBot
  Top           // Bottom
};
const Type *Type::xdual() const {
  assert(_type_info[base()].dual_type != Bad, "implement with v-call");
  return new Type(_type_info[_base].dual_type);
}
bool Type::has_memory() const {
  Type::TYPES tx = base();
  if (tx == Memory) return true;
  if (tx == Tuple) {
    const TypeTuple *t = is_tuple();
    for (uint i=0; i < t->cnt(); i++) {
      tx = t->field_at(i)->base();
      if (tx == Memory)  return true;
    }
  }
  return false;
}
#ifndef PRODUCT
void Type::dump2( Dict &d, uint depth, outputStream *st ) const {
  st->print("%s", _type_info[_base].msg);
}
void Type::dump_on(outputStream *st) const {
  ResourceMark rm;
  Dict d(cmpkey,hashkey);       // Stop recursive type dumping
  dump2(d,1, st);
  if (is_ptr_to_narrowoop()) {
    st->print(" [narrow]");
  } else if (is_ptr_to_narrowklass()) {
    st->print(" [narrowklass]");
  }
}
const char* Type::str(const Type* t) {
  stringStream ss;
  t->dump_on(&ss);
  return ss.as_string();
}
#endif
bool Type::singleton(void) const {
  return _base == Top || _base == Half;
}
bool Type::empty(void) const {
  switch (_base) {
  case DoubleTop:
  case FloatTop:
  case Top:
    return true;
  case Half:
  case Abio:
  case Return_Address:
  case Memory:
  case Bottom:
  case FloatBot:
  case DoubleBot:
    return false;  // never a singleton, therefore never empty
  }
  ShouldNotReachHere();
  return false;
}
#ifndef PRODUCT
void Type::dump_stats() {
  tty->print("Types made: %d\n", type_dict()->Size());
}
#endif
void Type::typerr( const Type *t ) const {
#ifndef PRODUCT
  tty->print("\nError mixing types: ");
  dump();
  tty->print(" and ");
  t->dump();
  tty->print("\n");
#endif
  ShouldNotReachHere();
}
const TypeF *TypeF::ZERO;       // Floating point zero
const TypeF *TypeF::ONE;        // Floating point one
const TypeF *TypeF::make(float f) {
  return (TypeF*)(new TypeF(f))->hashcons();
}
const Type *TypeF::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // Switch on original type
  case AnyPtr:                  // Mixing with oops happens when javac
  case RawPtr:                  // reuses local variables
  case OopPtr:
  case InstPtr:
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
  case NarrowOop:
  case NarrowKlass:
  case Int:
  case Long:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case FloatBot:
    return t;
  default:                      // All else is a mistake
    typerr(t);
  case FloatCon:                // Float-constant vs Float-constant?
    if( jint_cast(_f) != jint_cast(t->getf()) )         // unequal constants?
      return FLOAT;             // Return generic float
  case Top:
  case FloatTop:
    break;                      // Return the float constant
  }
  return this;                  // Return the float constant
}
const Type *TypeF::xdual() const {
  return this;
}
bool TypeF::eq(const Type *t) const {
  return (jint_cast(_f) == jint_cast(t->getf()));
}
int TypeF::hash(void) const {
  return *(int*)(&_f);
}
bool TypeF::is_finite() const {
  return g_isfinite(getf()) != 0;
}
bool TypeF::is_nan()    const {
  return g_isnan(getf()) != 0;
}
#ifndef PRODUCT
void TypeF::dump2( Dict &d, uint depth, outputStream *st ) const {
  Type::dump2(d,depth, st);
  st->print("%f", _f);
}
#endif
bool TypeF::singleton(void) const {
  return true;                  // Always a singleton
}
bool TypeF::empty(void) const {
  return false;                 // always exactly a singleton
}
const TypeD *TypeD::ZERO;       // Floating point zero
const TypeD *TypeD::ONE;        // Floating point one
const TypeD *TypeD::make(double d) {
  return (TypeD*)(new TypeD(d))->hashcons();
}
const Type *TypeD::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // Switch on original type
  case AnyPtr:                  // Mixing with oops happens when javac
  case RawPtr:                  // reuses local variables
  case OopPtr:
  case InstPtr:
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
  case NarrowOop:
  case NarrowKlass:
  case Int:
  case Long:
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case DoubleBot:
    return t;
  default:                      // All else is a mistake
    typerr(t);
  case DoubleCon:               // Double-constant vs Double-constant?
    if( jlong_cast(_d) != jlong_cast(t->getd()) )       // unequal constants? (see comment in TypeF::xmeet)
      return DOUBLE;            // Return generic double
  case Top:
  case DoubleTop:
    break;
  }
  return this;                  // Return the double constant
}
const Type *TypeD::xdual() const {
  return this;
}
bool TypeD::eq(const Type *t) const {
  return (jlong_cast(_d) == jlong_cast(t->getd()));
}
int TypeD::hash(void) const {
  return *(int*)(&_d);
}
bool TypeD::is_finite() const {
  return g_isfinite(getd()) != 0;
}
bool TypeD::is_nan()    const {
  return g_isnan(getd()) != 0;
}
#ifndef PRODUCT
void TypeD::dump2( Dict &d, uint depth, outputStream *st ) const {
  Type::dump2(d,depth,st);
  st->print("%f", _d);
}
#endif
bool TypeD::singleton(void) const {
  return true;                  // Always a singleton
}
bool TypeD::empty(void) const {
  return false;                 // always exactly a singleton
}
const TypeInt *TypeInt::MINUS_1;// -1
const TypeInt *TypeInt::ZERO;   // 0
const TypeInt *TypeInt::ONE;    // 1
const TypeInt *TypeInt::BOOL;   // 0 or 1, FALSE or TRUE.
const TypeInt *TypeInt::CC;     // -1,0 or 1, condition codes
const TypeInt *TypeInt::CC_LT;  // [-1]  == MINUS_1
const TypeInt *TypeInt::CC_GT;  // [1]   == ONE
const TypeInt *TypeInt::CC_EQ;  // [0]   == ZERO
const TypeInt *TypeInt::CC_LE;  // [-1,0]
const TypeInt *TypeInt::CC_GE;  // [0,1] == BOOL (!)
const TypeInt *TypeInt::BYTE;   // Bytes, -128 to 127
const TypeInt *TypeInt::UBYTE;  // Unsigned Bytes, 0 to 255
const TypeInt *TypeInt::CHAR;   // Java chars, 0-65535
const TypeInt *TypeInt::SHORT;  // Java shorts, -32768-32767
const TypeInt *TypeInt::POS;    // Positive 32-bit integers or zero
const TypeInt *TypeInt::POS1;   // Positive 32-bit integers
const TypeInt *TypeInt::INT;    // 32-bit integers
const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint]
const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT
TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) {
}
const TypeInt *TypeInt::make( jint lo ) {
  return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons();
}
static int normalize_int_widen( jint lo, jint hi, int w ) {
  if (lo <= hi) {
    if (((juint)hi - lo) <= SMALLINT)  w = Type::WidenMin;
    if (((juint)hi - lo) >= max_juint) w = Type::WidenMax; // TypeInt::INT
  } else {
    if (((juint)lo - hi) <= SMALLINT)  w = Type::WidenMin;
    if (((juint)lo - hi) >= max_juint) w = Type::WidenMin; // dual TypeInt::INT
  }
  return w;
}
const TypeInt *TypeInt::make( jint lo, jint hi, int w ) {
  w = normalize_int_widen(lo, hi, w);
  return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons();
}
const Type *TypeInt::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type?
  switch (t->base()) {          // Switch on original type
  case AnyPtr:                  // Mixing with oops happens when javac
  case RawPtr:                  // reuses local variables
  case OopPtr:
  case InstPtr:
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
  case NarrowOop:
  case NarrowKlass:
  case Long:
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  default:                      // All else is a mistake
    typerr(t);
  case Top:                     // No change
    return this;
  case Int:                     // Int vs Int?
    break;
  }
  const TypeInt *r = t->is_int();
  return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) );
}
const Type *TypeInt::xdual() const {
  int w = normalize_int_widen(_hi,_lo, WidenMax-_widen);
  return new TypeInt(_hi,_lo,w);
}
const Type *TypeInt::widen( const Type *old, const Type* limit ) const {
  if( old->base() != Int ) return this;
  const TypeInt *ot = old->is_int();
  if( _lo == ot->_lo && _hi == ot->_hi )
    return old;
  if( _lo <= ot->_lo && _hi >= ot->_hi ) {
    if( _widen > ot->_widen ) return this;
    if (ot->_lo == ot->_hi)  return this;
    if (_widen == WidenMax) {
      int max = max_jint;
      int min = min_jint;
      if (limit->isa_int()) {
        max = limit->is_int()->_hi;
        min = limit->is_int()->_lo;
      }
      if (min < _lo && _hi < max) {
        if (_lo >= 0 ||                 // easy common case
            (juint)(_lo - min) >= (juint)(max - _hi)) {
          return make(_lo, max, WidenMax);
        } else {
          return make(min, _hi, WidenMax);
        }
      }
      return TypeInt::INT;
    }
    return make(_lo,_hi,_widen+1);
  }
  if ( ot->_lo <= _lo && ot->_hi >= _hi )
    return old;
  return TypeInt::INT;
}
const Type *TypeInt::narrow( const Type *old ) const {
  if (_lo >= _hi)  return this;   // already narrow enough
  if (old == NULL)  return this;
  const TypeInt* ot = old->isa_int();
  if (ot == NULL)  return this;
  jint olo = ot->_lo;
  jint ohi = ot->_hi;
  if (_lo == olo && _hi == ohi)  return old;
  if (olo == min_jint && ohi == max_jint)  return this;
  if (_lo < olo || _hi > ohi)
    return this;                // doesn't narrow; pretty wierd
  juint nrange = (juint)_hi - _lo;
  juint orange = (juint)ohi - olo;
  if (nrange < max_juint - 1 && nrange > (orange >> 1) + (SMALLINT*2)) {
    return old;
  }
  return this;
}
const Type *TypeInt::filter_helper(const Type *kills, bool include_speculative) const {
  const TypeInt* ft = join_helper(kills, include_speculative)->isa_int();
  if (ft == NULL || ft->empty())
    return Type::TOP;           // Canonical empty value
  if (ft->_widen < this->_widen) {
    ft = TypeInt::make(ft->_lo, ft->_hi, this->_widen);
  }
  return ft;
}
bool TypeInt::eq( const Type *t ) const {
  const TypeInt *r = t->is_int(); // Handy access
  return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen;
}
int TypeInt::hash(void) const {
  return java_add(java_add(_lo, _hi), java_add(_widen, (int)Type::Int));
}
bool TypeInt::is_finite() const {
  return true;
}
#ifndef PRODUCT
static const char* intname(char* buf, jint n) {
  if (n == min_jint)
    return "min";
  else if (n < min_jint + 10000)
    sprintf(buf, "min+" INT32_FORMAT, n - min_jint);
  else if (n == max_jint)
    return "max";
  else if (n > max_jint - 10000)
    sprintf(buf, "max-" INT32_FORMAT, max_jint - n);
  else
    sprintf(buf, INT32_FORMAT, n);
  return buf;
}
void TypeInt::dump2( Dict &d, uint depth, outputStream *st ) const {
  char buf[40], buf2[40];
  if (_lo == min_jint && _hi == max_jint)
    st->print("int");
  else if (is_con())
    st->print("int:%s", intname(buf, get_con()));
  else if (_lo == BOOL->_lo && _hi == BOOL->_hi)
    st->print("bool");
  else if (_lo == BYTE->_lo && _hi == BYTE->_hi)
    st->print("byte");
  else if (_lo == CHAR->_lo && _hi == CHAR->_hi)
    st->print("char");
  else if (_lo == SHORT->_lo && _hi == SHORT->_hi)
    st->print("short");
  else if (_hi == max_jint)
    st->print("int:>=%s", intname(buf, _lo));
  else if (_lo == min_jint)
    st->print("int:<=%s", intname(buf, _hi));
  else
    st->print("int:%s..%s", intname(buf, _lo), intname(buf2, _hi));
  if (_widen != 0 && this != TypeInt::INT)
    st->print(":%.*s", _widen, "wwww");
}
#endif
bool TypeInt::singleton(void) const {
  return _lo >= _hi;
}
bool TypeInt::empty(void) const {
  return _lo > _hi;
}
const TypeLong *TypeLong::MINUS_1;// -1
const TypeLong *TypeLong::ZERO; // 0
const TypeLong *TypeLong::ONE;  // 1
const TypeLong *TypeLong::POS;  // >=0
const TypeLong *TypeLong::LONG; // 64-bit integers
const TypeLong *TypeLong::INT;  // 32-bit subrange
const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange
const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG
TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) {
}
const TypeLong *TypeLong::make( jlong lo ) {
  return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons();
}
static int normalize_long_widen( jlong lo, jlong hi, int w ) {
  if (lo <= hi) {
    if (((julong)hi - lo) <= SMALLINT)   w = Type::WidenMin;
    if (((julong)hi - lo) >= max_julong) w = Type::WidenMax; // TypeLong::LONG
  } else {
    if (((julong)lo - hi) <= SMALLINT)   w = Type::WidenMin;
    if (((julong)lo - hi) >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG
  }
  return w;
}
const TypeLong *TypeLong::make( jlong lo, jlong hi, int w ) {
  w = normalize_long_widen(lo, hi, w);
  return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons();
}
const Type *TypeLong::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type?
  switch (t->base()) {          // Switch on original type
  case AnyPtr:                  // Mixing with oops happens when javac
  case RawPtr:                  // reuses local variables
  case OopPtr:
  case InstPtr:
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
  case NarrowOop:
  case NarrowKlass:
  case Int:
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  default:                      // All else is a mistake
    typerr(t);
  case Top:                     // No change
    return this;
  case Long:                    // Long vs Long?
    break;
  }
  const TypeLong *r = t->is_long(); // Turn into a TypeLong
  return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) );
}
const Type *TypeLong::xdual() const {
  int w = normalize_long_widen(_hi,_lo, WidenMax-_widen);
  return new TypeLong(_hi,_lo,w);
}
const Type *TypeLong::widen( const Type *old, const Type* limit ) const {
  if( old->base() != Long ) return this;
  const TypeLong *ot = old->is_long();
  if( _lo == ot->_lo && _hi == ot->_hi )
    return old;
  if( _lo <= ot->_lo && _hi >= ot->_hi ) {
    if( _widen > ot->_widen ) return this;
    if (ot->_lo == ot->_hi)  return this;
    if (_widen == WidenMax) {
      jlong max = max_jlong;
      jlong min = min_jlong;
      if (limit->isa_long()) {
        max = limit->is_long()->_hi;
        min = limit->is_long()->_lo;
      }
      if (min < _lo && _hi < max) {
        if (_lo >= 0 ||                 // easy common case
            ((julong)_lo - min) >= ((julong)max - _hi)) {
          if (max >= max_juint && _hi < max_juint)
            return make(_lo, max_juint, WidenMax);
          else
            return make(_lo, max, WidenMax);
        } else {
          return make(min, _hi, WidenMax);
        }
      }
      return TypeLong::LONG;
    }
    return make(_lo,_hi,_widen+1);
  }
  if ( ot->_lo <= _lo && ot->_hi >= _hi )
    return old;
  return TypeLong::LONG;
}
const Type *TypeLong::narrow( const Type *old ) const {
  if (_lo >= _hi)  return this;   // already narrow enough
  if (old == NULL)  return this;
  const TypeLong* ot = old->isa_long();
  if (ot == NULL)  return this;
  jlong olo = ot->_lo;
  jlong ohi = ot->_hi;
  if (_lo == olo && _hi == ohi)  return old;
  if (olo == min_jlong && ohi == max_jlong)  return this;
  if (_lo < olo || _hi > ohi)
    return this;                // doesn't narrow; pretty wierd
  julong nrange = _hi - _lo;
  julong orange = ohi - olo;
  if (nrange < max_julong - 1 && nrange > (orange >> 1) + (SMALLINT*2)) {
    return old;
  }
  return this;
}
const Type *TypeLong::filter_helper(const Type *kills, bool include_speculative) const {
  const TypeLong* ft = join_helper(kills, include_speculative)->isa_long();
  if (ft == NULL || ft->empty())
    return Type::TOP;           // Canonical empty value
  if (ft->_widen < this->_widen) {
    ft = TypeLong::make(ft->_lo, ft->_hi, this->_widen);
  }
  return ft;
}
bool TypeLong::eq( const Type *t ) const {
  const TypeLong *r = t->is_long(); // Handy access
  return r->_lo == _lo &&  r->_hi == _hi  && r->_widen == _widen;
}
int TypeLong::hash(void) const {
  return (int)(_lo+_hi+_widen+(int)Type::Long);
}
bool TypeLong::is_finite() const {
  return true;
}
#ifndef PRODUCT
static const char* longnamenear(jlong x, const char* xname, char* buf, jlong n) {
  if (n > x) {
    if (n >= x + 10000)  return NULL;
    sprintf(buf, "%s+" JLONG_FORMAT, xname, n - x);
  } else if (n < x) {
    if (n <= x - 10000)  return NULL;
    sprintf(buf, "%s-" JLONG_FORMAT, xname, x - n);
  } else {
    return xname;
  }
  return buf;
}
static const char* longname(char* buf, jlong n) {
  const char* str;
  if (n == min_jlong)
    return "min";
  else if (n < min_jlong + 10000)
    sprintf(buf, "min+" JLONG_FORMAT, n - min_jlong);
  else if (n == max_jlong)
    return "max";
  else if (n > max_jlong - 10000)
    sprintf(buf, "max-" JLONG_FORMAT, max_jlong - n);
  else if ((str = longnamenear(max_juint, "maxuint", buf, n)) != NULL)
    return str;
  else if ((str = longnamenear(max_jint, "maxint", buf, n)) != NULL)
    return str;
  else if ((str = longnamenear(min_jint, "minint", buf, n)) != NULL)
    return str;
  else
    sprintf(buf, JLONG_FORMAT, n);
  return buf;
}
void TypeLong::dump2( Dict &d, uint depth, outputStream *st ) const {
  char buf[80], buf2[80];
  if (_lo == min_jlong && _hi == max_jlong)
    st->print("long");
  else if (is_con())
    st->print("long:%s", longname(buf, get_con()));
  else if (_hi == max_jlong)
    st->print("long:>=%s", longname(buf, _lo));
  else if (_lo == min_jlong)
    st->print("long:<=%s", longname(buf, _hi));
  else
    st->print("long:%s..%s", longname(buf, _lo), longname(buf2, _hi));
  if (_widen != 0 && this != TypeLong::LONG)
    st->print(":%.*s", _widen, "wwww");
}
#endif
bool TypeLong::singleton(void) const {
  return _lo >= _hi;
}
bool TypeLong::empty(void) const {
  return _lo > _hi;
}
const TypeTuple *TypeTuple::IFBOTH;     // Return both arms of IF as reachable
const TypeTuple *TypeTuple::IFFALSE;
const TypeTuple *TypeTuple::IFTRUE;
const TypeTuple *TypeTuple::IFNEITHER;
const TypeTuple *TypeTuple::LOOPBODY;
const TypeTuple *TypeTuple::MEMBAR;
const TypeTuple *TypeTuple::STORECONDITIONAL;
const TypeTuple *TypeTuple::START_I2C;
const TypeTuple *TypeTuple::INT_PAIR;
const TypeTuple *TypeTuple::LONG_PAIR;
const TypeTuple *TypeTuple::INT_CC_PAIR;
const TypeTuple *TypeTuple::LONG_CC_PAIR;
const TypeTuple *TypeTuple::make_range(ciSignature* sig) {
  ciType* return_type = sig->return_type();
  uint total_fields = TypeFunc::Parms + return_type->size();
  const Type **field_array = fields(total_fields);
  switch (return_type->basic_type()) {
  case T_LONG:
    field_array[TypeFunc::Parms]   = TypeLong::LONG;
    field_array[TypeFunc::Parms+1] = Type::HALF;
    break;
  case T_DOUBLE:
    field_array[TypeFunc::Parms]   = Type::DOUBLE;
    field_array[TypeFunc::Parms+1] = Type::HALF;
    break;
  case T_OBJECT:
  case T_ARRAY:
  case T_BOOLEAN:
  case T_CHAR:
  case T_FLOAT:
  case T_BYTE:
  case T_SHORT:
  case T_INT:
    field_array[TypeFunc::Parms] = get_const_type(return_type);
    break;
  case T_VOID:
    break;
  default:
    ShouldNotReachHere();
  }
  return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons();
}
const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) {
  uint total_fields = TypeFunc::Parms + sig->size();
  uint pos = TypeFunc::Parms;
  const Type **field_array;
  if (recv != NULL) {
    total_fields++;
    field_array = fields(total_fields);
    field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL);
  } else {
    field_array = fields(total_fields);
  }
  int i = 0;
  while (pos < total_fields) {
    ciType* type = sig->type_at(i);
    switch (type->basic_type()) {
    case T_LONG:
      field_array[pos++] = TypeLong::LONG;
      field_array[pos++] = Type::HALF;
      break;
    case T_DOUBLE:
      field_array[pos++] = Type::DOUBLE;
      field_array[pos++] = Type::HALF;
      break;
    case T_OBJECT:
    case T_ARRAY:
    case T_FLOAT:
    case T_INT:
      field_array[pos++] = get_const_type(type);
      break;
    case T_BOOLEAN:
    case T_CHAR:
    case T_BYTE:
    case T_SHORT:
      field_array[pos++] = TypeInt::INT;
      break;
    default:
      ShouldNotReachHere();
    }
    i++;
  }
  return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons();
}
const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) {
  return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons();
}
const Type **TypeTuple::fields( uint arg_cnt ) {
  const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) ));
  flds[TypeFunc::Control  ] = Type::CONTROL;
  flds[TypeFunc::I_O      ] = Type::ABIO;
  flds[TypeFunc::Memory   ] = Type::MEMORY;
  flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM;
  flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS;
  return flds;
}
const Type *TypeTuple::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Bottom:                  // Ye Olde Default
    return t;
  default:                      // All else is a mistake
    typerr(t);
  case Tuple: {                 // Meeting 2 signatures?
    const TypeTuple *x = t->is_tuple();
    assert( _cnt == x->_cnt, "" );
    const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) ));
    for( uint i=0; i<_cnt; i++ )
      fields[i] = field_at(i)->xmeet( x->field_at(i) );
    return TypeTuple::make(_cnt,fields);
  }
  case Top:
    break;
  }
  return this;                  // Return the double constant
}
const Type *TypeTuple::xdual() const {
  const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) ));
  for( uint i=0; i<_cnt; i++ )
    fields[i] = _fields[i]->dual();
  return new TypeTuple(_cnt,fields);
}
bool TypeTuple::eq( const Type *t ) const {
  const TypeTuple *s = (const TypeTuple *)t;
  if (_cnt != s->_cnt)  return false;  // Unequal field counts
  for (uint i = 0; i < _cnt; i++)
    if (field_at(i) != s->field_at(i)) // POINTER COMPARE!  NO RECURSION!
      return false;             // Missed
  return true;
}
int TypeTuple::hash(void) const {
  intptr_t sum = _cnt;
  for( uint i=0; i<_cnt; i++ )
    sum += (intptr_t)_fields[i];     // Hash on pointers directly
  return sum;
}
#ifndef PRODUCT
void TypeTuple::dump2( Dict &d, uint depth, outputStream *st ) const {
  st->print("{");
  if( !depth || d[this] ) {     // Check for recursive print
    st->print("...}");
    return;
  }
  d.Insert((void*)this, (void*)this);   // Stop recursion
  if( _cnt ) {
    uint i;
    for( i=0; i<_cnt-1; i++ ) {
      st->print("%d:", i);
      _fields[i]->dump2(d, depth-1, st);
      st->print(", ");
    }
    st->print("%d:", i);
    _fields[i]->dump2(d, depth-1, st);
  }
  st->print("}");
}
#endif
bool TypeTuple::singleton(void) const {
  return false;                 // Never a singleton
}
bool TypeTuple::empty(void) const {
  for( uint i=0; i<_cnt; i++ ) {
    if (_fields[i]->empty())  return true;
  }
  return false;
}
inline const TypeInt* normalize_array_size(const TypeInt* size) {
  if (size->_widen != Type::WidenMin)
    return TypeInt::make(size->_lo, size->_hi, Type::WidenMin);
  else
    return size;
}
const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable) {
  if (UseCompressedOops && elem->isa_oopptr()) {
    elem = elem->make_narrowoop();
  }
  size = normalize_array_size(size);
  return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons();
}
const Type *TypeAry::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Bottom:                  // Ye Olde Default
    return t;
  default:                      // All else is a mistake
    typerr(t);
  case Array: {                 // Meeting 2 arrays?
    const TypeAry *a = t->is_ary();
    return TypeAry::make(_elem->meet_speculative(a->_elem),
                         _size->xmeet(a->_size)->is_int(),
                         _stable & a->_stable);
  }
  case Top:
    break;
  }
  return this;                  // Return the double constant
}
const Type *TypeAry::xdual() const {
  const TypeInt* size_dual = _size->dual()->is_int();
  size_dual = normalize_array_size(size_dual);
  return new TypeAry(_elem->dual(), size_dual, !_stable);
}
bool TypeAry::eq( const Type *t ) const {
  const TypeAry *a = (const TypeAry*)t;
  return _elem == a->_elem &&
    _stable == a->_stable &&
    _size == a->_size;
}
int TypeAry::hash(void) const {
  return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0);
}
const Type* TypeAry::remove_speculative() const {
  return make(_elem->remove_speculative(), _size, _stable);
}
#ifdef ASSERT
bool TypeAry::interface_vs_oop(const Type *t) const {
  const TypeAry* t_ary = t->is_ary();
  if (t_ary) {
    const TypePtr* this_ptr = _elem->make_ptr(); // In case we have narrow_oops
    const TypePtr*    t_ptr = t_ary->_elem->make_ptr();
    if(this_ptr != NULL && t_ptr != NULL) {
      return this_ptr->interface_vs_oop(t_ptr);
    }
  }
  return false;
}
#endif
#ifndef PRODUCT
void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const {
  if (_stable)  st->print("stable:");
  _elem->dump2(d, depth, st);
  st->print("[");
  _size->dump2(d, depth, st);
  st->print("]");
}
#endif
bool TypeAry::singleton(void) const {
  return false;                 // Never a singleton
}
bool TypeAry::empty(void) const {
  return _elem->empty() || _size->empty();
}
bool TypeAry::ary_must_be_exact() const {
  if (!UseExactTypes)       return false;
  if (_elem == BOTTOM)      return false;  // general array not exact
  if (_elem == TOP   )      return false;  // inverted general array not exact
  const TypeOopPtr*  toop = NULL;
  if (UseCompressedOops && _elem->isa_narrowoop()) {
    toop = _elem->make_ptr()->isa_oopptr();
  } else {
    toop = _elem->isa_oopptr();
  }
  if (!toop)                return true;   // a primitive type, like int
  ciKlass* tklass = toop->klass();
  if (tklass == NULL)       return false;  // unloaded class
  if (!tklass->is_loaded()) return false;  // unloaded class
  const TypeInstPtr* tinst;
  if (_elem->isa_narrowoop())
    tinst = _elem->make_ptr()->isa_instptr();
  else
    tinst = _elem->isa_instptr();
  if (tinst)
    return tklass->as_instance_klass()->is_final();
  const TypeAryPtr*  tap;
  if (_elem->isa_narrowoop())
    tap = _elem->make_ptr()->isa_aryptr();
  else
    tap = _elem->isa_aryptr();
  if (tap)
    return tap->ary()->ary_must_be_exact();
  return false;
}
const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
const TypeVect* TypeVect::make(const Type *elem, uint length) {
  BasicType elem_bt = elem->array_element_basic_type();
  assert(is_java_primitive(elem_bt), "only primitive types in vector");
  assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
  assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
  int size = length * type2aelembytes(elem_bt);
  switch (Matcher::vector_ideal_reg(size)) {
  case Op_VecS:
    return (TypeVect*)(new TypeVectS(elem, length))->hashcons();
  case Op_RegL:
  case Op_VecD:
  case Op_RegD:
    return (TypeVect*)(new TypeVectD(elem, length))->hashcons();
  case Op_VecX:
    return (TypeVect*)(new TypeVectX(elem, length))->hashcons();
  case Op_VecY:
    return (TypeVect*)(new TypeVectY(elem, length))->hashcons();
  }
 ShouldNotReachHere();
  return NULL;
}
const Type *TypeVect::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Bottom:                  // Ye Olde Default
    return t;
  default:                      // All else is a mistake
    typerr(t);
  case VectorS:
  case VectorD:
  case VectorX:
  case VectorY: {                // Meeting 2 vectors?
    const TypeVect* v = t->is_vect();
    assert(  base() == v->base(), "");
    assert(length() == v->length(), "");
    assert(element_basic_type() == v->element_basic_type(), "");
    return TypeVect::make(_elem->xmeet(v->_elem), _length);
  }
  case Top:
    break;
  }
  return this;
}
const Type *TypeVect::xdual() const {
  return new TypeVect(base(), _elem->dual(), _length);
}
bool TypeVect::eq(const Type *t) const {
  const TypeVect *v = t->is_vect();
  return (_elem == v->_elem) && (_length == v->_length);
}
int TypeVect::hash(void) const {
  return (intptr_t)_elem + (intptr_t)_length;
}
bool TypeVect::singleton(void) const {
  return false;
}
bool TypeVect::empty(void) const {
  return _elem->empty();
}
#ifndef PRODUCT
void TypeVect::dump2(Dict &d, uint depth, outputStream *st) const {
  switch (base()) {
  case VectorS:
    st->print("vectors["); break;
  case VectorD:
    st->print("vectord["); break;
  case VectorX:
    st->print("vectorx["); break;
  case VectorY:
    st->print("vectory["); break;
  default:
    ShouldNotReachHere();
  }
  st->print("%d]:{", _length);
  _elem->dump2(d, depth, st);
  st->print("}");
}
#endif
const TypePtr *TypePtr::NULL_PTR;
const TypePtr *TypePtr::NOTNULL;
const TypePtr *TypePtr::BOTTOM;
const TypePtr::PTR TypePtr::ptr_meet[TypePtr::lastPTR][TypePtr::lastPTR] = {
  { /* Top     */ TopPTR,    AnyNull,   Constant, Null,   NotNull, BotPTR,},
  { /* AnyNull */ AnyNull,   AnyNull,   Constant, BotPTR, NotNull, BotPTR,},
  { /* Constant*/ Constant,  Constant,  Constant, BotPTR, NotNull, BotPTR,},
  { /* Null    */ Null,      BotPTR,    BotPTR,   Null,   BotPTR,  BotPTR,},
  { /* NotNull */ NotNull,   NotNull,   NotNull,  BotPTR, NotNull, BotPTR,},
  { /* BotPTR  */ BotPTR,    BotPTR,    BotPTR,   BotPTR, BotPTR,  BotPTR,}
};
const TypePtr *TypePtr::make( TYPES t, enum PTR ptr, int offset ) {
  return (TypePtr*)(new TypePtr(t,ptr,offset))->hashcons();
}
const Type *TypePtr::cast_to_ptr_type(PTR ptr) const {
  assert(_base == AnyPtr, "subclass must override cast_to_ptr_type");
  if( ptr == _ptr ) return this;
  return make(_base, ptr, _offset);
}
intptr_t TypePtr::get_con() const {
  assert( _ptr == Null, "" );
  return _offset;
}
const Type *TypePtr::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Int:                     // Mixing ints & oops happens when javac
  case Long:                    // reuses local variables
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  case AnyPtr: {                // Meeting to AnyPtrs
    const TypePtr *tp = t->is_ptr();
    return make( AnyPtr, meet_ptr(tp->ptr()), meet_offset(tp->offset()) );
  }
  case RawPtr:                  // For these, flip the call around to cut down
  case OopPtr:
  case InstPtr:                 // on the cases I have to handle.
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
    return t->xmeet(this);      // Call in reverse direction
  default:                      // All else is a mistake
    typerr(t);
  }
  return this;
}
int TypePtr::meet_offset( int offset ) const {
  if( _offset == OffsetTop ) return offset;
  if( offset == OffsetTop ) return _offset;
  if( _offset != offset ) return OffsetBot;
  return _offset;
}
int TypePtr::dual_offset( ) const {
  if( _offset == OffsetTop ) return OffsetBot;// Map 'TOP' into 'BOTTOM'
  if( _offset == OffsetBot ) return OffsetTop;// Map 'BOTTOM' into 'TOP'
  return _offset;               // Map everything else into self
}
const TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = {
  BotPTR, NotNull, Constant, Null, AnyNull, TopPTR
};
const Type *TypePtr::xdual() const {
  return new TypePtr( AnyPtr, dual_ptr(), dual_offset() );
}
int TypePtr::xadd_offset( intptr_t offset ) const {
  if( _offset == OffsetTop || offset == OffsetTop ) return OffsetTop;
  if( _offset == OffsetBot || offset == OffsetBot ) return OffsetBot;
  offset += (intptr_t)_offset;
  if (offset != (int)offset || offset == OffsetTop) return OffsetBot;
  return (int)offset;        // Sum valid offsets
}
const TypePtr *TypePtr::add_offset( intptr_t offset ) const {
  return make( AnyPtr, _ptr, xadd_offset(offset) );
}
bool TypePtr::eq( const Type *t ) const {
  const TypePtr *a = (const TypePtr*)t;
  return _ptr == a->ptr() && _offset == a->offset();
}
int TypePtr::hash(void) const {
  return java_add(_ptr, _offset);
}
const char *const TypePtr::ptr_msg[TypePtr::lastPTR] = {
  "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR"
};
#ifndef PRODUCT
void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const {
  if( _ptr == Null ) st->print("NULL");
  else st->print("%s *", ptr_msg[_ptr]);
  if( _offset == OffsetTop ) st->print("+top");
  else if( _offset == OffsetBot ) st->print("+bot");
  else if( _offset ) st->print("+%d", _offset);
}
#endif
bool TypePtr::singleton(void) const {
  return (_offset != OffsetBot) && !below_centerline(_ptr);
}
bool TypePtr::empty(void) const {
  return (_offset == OffsetTop) || above_centerline(_ptr);
}
const TypeRawPtr *TypeRawPtr::BOTTOM;
const TypeRawPtr *TypeRawPtr::NOTNULL;
const TypeRawPtr *TypeRawPtr::make( enum PTR ptr ) {
  assert( ptr != Constant, "what is the constant?" );
  assert( ptr != Null, "Use TypePtr for NULL" );
  return (TypeRawPtr*)(new TypeRawPtr(ptr,0))->hashcons();
}
const TypeRawPtr *TypeRawPtr::make( address bits ) {
  assert( bits, "Use TypePtr for NULL" );
  return (TypeRawPtr*)(new TypeRawPtr(Constant,bits))->hashcons();
}
const Type *TypeRawPtr::cast_to_ptr_type(PTR ptr) const {
  assert( ptr != Constant, "what is the constant?" );
  assert( ptr != Null, "Use TypePtr for NULL" );
  assert( _bits==0, "Why cast a constant address?");
  if( ptr == _ptr ) return this;
  return make(ptr);
}
intptr_t TypeRawPtr::get_con() const {
  assert( _ptr == Null || _ptr == Constant, "" );
  return (intptr_t)_bits;
}
const Type *TypeRawPtr::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch( t->base() ) {         // switch on original type
  case Bottom:                  // Ye Olde Default
    return t;
  case Top:
    return this;
  case AnyPtr:                  // Meeting to AnyPtrs
    break;
  case RawPtr: {                // might be top, bot, any/not or constant
    enum PTR tptr = t->is_ptr()->ptr();
    enum PTR ptr = meet_ptr( tptr );
    if( ptr == Constant ) {     // Cannot be equal constants, so...
      if( tptr == Constant && _ptr != Constant)  return t;
      if( _ptr == Constant && tptr != Constant)  return this;
      ptr = NotNull;            // Fall down in lattice
    }
    return make( ptr );
  }
  case OopPtr:
  case InstPtr:
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
    return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  default:                      // All else is a mistake
    typerr(t);
  }
  const TypePtr *tp = t->is_ptr();
  switch (tp->ptr()) {
  case TypePtr::TopPTR:  return this;
  case TypePtr::BotPTR:  return t;
  case TypePtr::Null:
    if( _ptr == TypePtr::TopPTR ) return t;
    return TypeRawPtr::BOTTOM;
  case TypePtr::NotNull: return TypePtr::make( AnyPtr, meet_ptr(TypePtr::NotNull), tp->meet_offset(0) );
  case TypePtr::AnyNull:
    if( _ptr == TypePtr::Constant) return this;
    return make( meet_ptr(TypePtr::AnyNull) );
  default: ShouldNotReachHere();
  }
  return this;
}
const Type *TypeRawPtr::xdual() const {
  return new TypeRawPtr( dual_ptr(), _bits );
}
const TypePtr *TypeRawPtr::add_offset( intptr_t offset ) const {
  if( offset == OffsetTop ) return BOTTOM; // Undefined offset-> undefined pointer
  if( offset == OffsetBot ) return BOTTOM; // Unknown offset-> unknown pointer
  if( offset == 0 ) return this; // No change
  switch (_ptr) {
  case TypePtr::TopPTR:
  case TypePtr::BotPTR:
  case TypePtr::NotNull:
    return this;
  case TypePtr::Null:
  case TypePtr::Constant: {
    address bits = _bits+offset;
    if ( bits == 0 ) return TypePtr::NULL_PTR;
    return make( bits );
  }
  default:  ShouldNotReachHere();
  }
  return NULL;                  // Lint noise
}
bool TypeRawPtr::eq( const Type *t ) const {
  const TypeRawPtr *a = (const TypeRawPtr*)t;
  return _bits == a->_bits && TypePtr::eq(t);
}
int TypeRawPtr::hash(void) const {
  return (intptr_t)_bits + TypePtr::hash();
}
#ifndef PRODUCT
void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
  if( _ptr == Constant )
    st->print(INTPTR_FORMAT, _bits);
  else
    st->print("rawptr:%s", ptr_msg[_ptr]);
}
#endif
const TypeOopPtr *TypeOopPtr::BOTTOM;
TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth)
  : TypePtr(t, ptr, offset),
    _const_oop(o), _klass(k),
    _klass_is_exact(xk),
    _is_ptr_to_narrowoop(false),
    _is_ptr_to_narrowklass(false),
    _is_ptr_to_boxed_value(false),
    _instance_id(instance_id),
    _speculative(speculative),
    _inline_depth(inline_depth){
  if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
      (offset > 0) && xk && (k != 0) && k->is_instance_klass()) {
    _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset);
  }
#ifdef _LP64
  if (_offset != 0) {
    if (_offset == oopDesc::klass_offset_in_bytes()) {
      _is_ptr_to_narrowklass = UseCompressedClassPointers;
    } else if (klass() == NULL) {
      assert(this->isa_aryptr(), "only arrays without klass");
      _is_ptr_to_narrowoop = UseCompressedOops;
    } else if (this->isa_aryptr()) {
      _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
                             _offset != arrayOopDesc::length_offset_in_bytes());
    } else if (klass()->is_instance_klass()) {
      ciInstanceKlass* ik = klass()->as_instance_klass();
      ciField* field = NULL;
      if (this->isa_klassptr()) {
      } else if (_offset == OffsetBot || _offset == OffsetTop) {
        _is_ptr_to_narrowoop = UseCompressedOops;
      } else { // exclude unsafe ops
        assert(this->isa_instptr(), "must be an instance ptr.");
        if (klass() == ciEnv::current()->Class_klass() &&
            (_offset == java_lang_Class::klass_offset_in_bytes() ||
             _offset == java_lang_Class::array_klass_offset_in_bytes())) {
          assert(this->isa_instptr(), "must be an instance ptr.");
          _is_ptr_to_narrowoop = false;
        } else if (klass() == ciEnv::current()->Class_klass() &&
                   _offset >= InstanceMirrorKlass::offset_of_static_fields()) {
          assert(o != NULL, "must be constant");
          ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
          ciField* field = k->get_field_by_offset(_offset, true);
          assert(field != NULL, "missing field");
          BasicType basic_elem_type = field->layout_type();
          _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
                                                       basic_elem_type == T_ARRAY);
        } else {
          field = ik->get_field_by_offset(_offset, false);
          if (field != NULL) {
            BasicType basic_elem_type = field->layout_type();
            _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
                                                         basic_elem_type == T_ARRAY);
          } else if (klass()->equals(ciEnv::current()->Object_klass())) {
            _is_ptr_to_narrowoop = UseCompressedOops;
          } else {
            _is_ptr_to_narrowoop = UseCompressedOops;
          }
        }
      }
    }
  }
#endif
}
const TypeOopPtr *TypeOopPtr::make(PTR ptr,
                                   int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) {
  assert(ptr != Constant, "no constant generic pointers");
  ciKlass*  k = Compile::current()->env()->Object_klass();
  bool      xk = false;
  ciObject* o = NULL;
  return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
}
const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
  assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
  if( ptr == _ptr ) return this;
  return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
}
const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
  return this;
}
const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
  return this;
}
const TypeKlassPtr* TypeOopPtr::as_klass_type() const {
  ciKlass* k = klass();
  bool    xk = klass_is_exact();
  if (k == NULL)
    return TypeKlassPtr::OBJECT;
  else
    return TypeKlassPtr::make(xk? Constant: NotNull, k, 0);
}
const Type *TypeOopPtr::xmeet(const Type *t) const {
  const Type* res = xmeet_helper(t);
  if (res->isa_oopptr() == NULL) {
    return res;
  }
  const TypeOopPtr* res_oopptr = res->is_oopptr();
  if (res_oopptr->speculative() != NULL) {
    if (res_oopptr->remove_speculative() == res_oopptr->speculative()) {
      return res_oopptr->remove_speculative();
    }
  }
  return res;
}
const Type *TypeOopPtr::xmeet_helper(const Type *t) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Int:                     // Mixing ints & oops happens when javac
  case Long:                    // reuses local variables
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  default:                      // All else is a mistake
    typerr(t);
  case RawPtr:
  case MetadataPtr:
  case KlassPtr:
    return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  case AnyPtr: {
    const TypePtr *tp = t->is_ptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    switch (tp->ptr()) {
    case Null:
      if (ptr == Null)  return TypePtr::make(AnyPtr, ptr, offset);
    case TopPTR:
    case AnyNull: {
      int instance_id = meet_instance_id(InstanceTop);
      const TypeOopPtr* speculative = _speculative;
      return make(ptr, offset, instance_id, speculative, _inline_depth);
    }
    case BotPTR:
    case NotNull:
      return TypePtr::make(AnyPtr, ptr, offset);
    default: typerr(t);
    }
  }
  case OopPtr: {                 // Meeting to other OopPtrs
    const TypeOopPtr *tp = t->is_oopptr();
    int instance_id = meet_instance_id(tp->instance_id());
    const TypeOopPtr* speculative = xmeet_speculative(tp);
    int depth = meet_inline_depth(tp->inline_depth());
    return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
  }
  case InstPtr:                  // For these, flip the call around to cut down
  case AryPtr:
    return t->xmeet(this);      // Call in reverse direction
  } // End of switch
  return this;                  // Return the double constant
}
const Type *TypeOopPtr::xdual() const {
  assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
  assert(const_oop() == NULL,             "no constants here");
  return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
}
const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
  if (klass->is_instance_klass()) {
    Compile* C = Compile::current();
    Dependencies* deps = C->dependencies();
    assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
    bool klass_is_exact = false;
    if (klass->is_loaded()) {
      ciInstanceKlass* ik = klass->as_instance_klass();
      klass_is_exact = ik->is_final();
      if (!klass_is_exact && klass_change
          && deps != NULL && UseUniqueSubclasses) {
        ciInstanceKlass* sub = ik->unique_concrete_subklass();
        if (sub != NULL) {
          deps->assert_abstract_with_unique_concrete_subtype(ik, sub);
          klass = ik = sub;
          klass_is_exact = sub->is_final();
        }
      }
      if (!klass_is_exact && try_for_exact
          && deps != NULL && UseExactTypes) {
        if (!ik->is_interface() && !ik->has_subklass()) {
          deps->assert_leaf_type(ik);
          klass_is_exact = true;
        }
      }
    }
    return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0);
  } else if (klass->is_obj_array_klass()) {
    const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact);
    bool xk = etype->klass_is_exact();
    const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
    const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0);
    return arr;
  } else if (klass->is_type_array_klass()) {
    const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
    const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
    const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0);
    return arr;
  } else {
    ShouldNotReachHere();
    return NULL;
  }
}
const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o,
                                                 bool require_constant,
                                                 bool is_autobox_cache) {
  assert(!o->is_null_object(), "null object not yet handled here.");
  ciKlass* klass = o->klass();
  if (klass->is_instance_klass()) {
    if (require_constant) {
      if (!o->can_be_constant())  return NULL;
    } else if (!o->should_be_constant()) {
      return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
    }
    return TypeInstPtr::make(o);
  } else if (klass->is_obj_array_klass()) {
    const TypeOopPtr *etype =
      TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
    if (is_autobox_cache) {
      etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
    }
    const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
    if (require_constant) {
      if (!o->can_be_constant())  return NULL;
    } else if (!o->should_be_constant()) {
      return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
    }
    const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, InlineDepthBottom, is_autobox_cache);
    return arr;
  } else if (klass->is_type_array_klass()) {
    const Type* etype =
      (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
    const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
    if (require_constant) {
      if (!o->can_be_constant())  return NULL;
    } else if (!o->should_be_constant()) {
      return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
    }
    const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
    return arr;
  }
  fatal("unhandled object type");
  return NULL;
}
intptr_t TypeOopPtr::get_con() const {
  assert( _ptr == Null || _ptr == Constant, "" );
  assert( _offset >= 0, "" );
  if (_offset != 0) {
    tty->print_cr("Found oop constant with non-zero offset");
    ShouldNotReachHere();
  }
  return (intptr_t)const_oop()->constant_encoding();
}
const Type *TypeOopPtr::filter_helper(const Type *kills, bool include_speculative) const {
  const Type* ft = join_helper(kills, include_speculative);
  const TypeInstPtr* ftip = ft->isa_instptr();
  const TypeInstPtr* ktip = kills->isa_instptr();
  if (ft->empty()) {
    if (!empty()) {
      if (ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) {
        return kills;           // Uplift to interface
      }
      Type::get_arrays_base_elements(ft, kills, NULL, &ktip);
      if (ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) {
        return kills;           // Uplift to array of interface
      }
    }
    return Type::TOP;           // Canonical empty value
  }
  if (ftip != NULL && ktip != NULL &&
      ftip->is_loaded() &&  ftip->klass()->is_interface() &&
      ktip->is_loaded() && !ktip->klass()->is_interface()) {
    assert(!ftip->klass_is_exact(), "interface could not be exact");
    return ktip->cast_to_ptr_type(ftip->ptr());
  }
  return ft;
}
bool TypeOopPtr::eq( const Type *t ) const {
  const TypeOopPtr *a = (const TypeOopPtr*)t;
  if (_klass_is_exact != a->_klass_is_exact ||
      _instance_id != a->_instance_id ||
      !eq_speculative(a) ||
      _inline_depth != a->_inline_depth)  return false;
  ciObject* one = const_oop();
  ciObject* two = a->const_oop();
  if (one == NULL || two == NULL) {
    return (one == two) && TypePtr::eq(t);
  } else {
    return one->equals(two) && TypePtr::eq(t);
  }
}
int TypeOopPtr::hash(void) const {
  return
    java_add(java_add(java_add(const_oop() ? const_oop()->hash() : 0, _klass_is_exact),
                      java_add(_instance_id , hash_speculative())), java_add(_inline_depth , TypePtr::hash()));
}
#ifndef PRODUCT
void TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
  st->print("oopptr:%s", ptr_msg[_ptr]);
  if( _klass_is_exact ) st->print(":exact");
  if( const_oop() ) st->print(INTPTR_FORMAT, const_oop());
  switch( _offset ) {
  case OffsetTop: st->print("+top"); break;
  case OffsetBot: st->print("+any"); break;
  case         0: break;
  default:        st->print("+%d",_offset); break;
  }
  if (_instance_id == InstanceTop)
    st->print(",iid=top");
  else if (_instance_id != InstanceBot)
    st->print(",iid=%d",_instance_id);
  dump_inline_depth(st);
  dump_speculative(st);
}
void TypeOopPtr::dump_speculative(outputStream *st) const {
  if (_speculative != NULL) {
    st->print(" (speculative=");
    _speculative->dump_on(st);
    st->print(")");
  }
}
void TypeOopPtr::dump_inline_depth(outputStream *st) const {
  if (_inline_depth != InlineDepthBottom) {
    if (_inline_depth == InlineDepthTop) {
      st->print(" (inline_depth=InlineDepthTop)");
    } else {
      st->print(" (inline_depth=%d)", _inline_depth);
    }
  }
}
#endif
bool TypeOopPtr::singleton(void) const {
  return (_offset == 0) && !below_centerline(_ptr);
}
const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const {
  return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);
}
const Type* TypeOopPtr::remove_speculative() const {
  if (_speculative == NULL) {
    return this;
  }
  assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
  return make(_ptr, _offset, _instance_id, NULL, _inline_depth);
}
const TypeOopPtr* TypeOopPtr::with_inline_depth(int depth) const {
  if (!UseInlineDepthForSpeculativeTypes) {
    return this;
  }
  return make(_ptr, _offset, _instance_id, _speculative, depth);
}
bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
  if (klass_is_exact()) {
    return false;
  }
  if (exact_kls == NULL) {
    return false;
  }
  if (speculative_type() == NULL) {
    return true;
  }
  if (_speculative->inline_depth() == InlineDepthBottom) {
    return false;
  }
  assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison");
  return inline_depth < _speculative->inline_depth();
}
int TypeOopPtr::meet_instance_id( int instance_id ) const {
  if( _instance_id == InstanceTop ) return  instance_id;
  if(  instance_id == InstanceTop ) return _instance_id;
  if( _instance_id != instance_id ) return InstanceBot;
  return _instance_id;
}
int TypeOopPtr::dual_instance_id( ) const {
  if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM
  if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP
  return _instance_id;              // Map everything else into self
}
const TypeOopPtr* TypeOopPtr::xmeet_speculative(const TypeOopPtr* other) const {
  bool this_has_spec = (_speculative != NULL);
  bool other_has_spec = (other->speculative() != NULL);
  if (!this_has_spec && !other_has_spec) {
    return NULL;
  }
  const TypeOopPtr* this_spec = _speculative;
  const TypeOopPtr* other_spec = other->speculative();
  if (!this_has_spec) {
    this_spec = this;
  }
  if (!other_has_spec) {
    other_spec = other;
  }
  return this_spec->meet_speculative(other_spec)->is_oopptr();
}
const TypeOopPtr* TypeOopPtr::dual_speculative() const {
  if (_speculative == NULL) {
    return NULL;
  }
  return _speculative->dual()->is_oopptr();
}
const TypeOopPtr* TypeOopPtr::add_offset_speculative(intptr_t offset) const {
  if (_speculative == NULL) {
    return NULL;
  }
  return _speculative->add_offset(offset)->is_oopptr();
}
bool TypeOopPtr::eq_speculative(const TypeOopPtr* other) const {
  if (_speculative == NULL || other->speculative() == NULL) {
    return _speculative == other->speculative();
  }
  if (_speculative->base() != other->speculative()->base()) {
    return false;
  }
  return _speculative->eq(other->speculative());
}
int TypeOopPtr::hash_speculative() const {
  if (_speculative == NULL) {
    return 0;
  }
  return _speculative->hash();
}
int TypeOopPtr::dual_inline_depth() const {
  return -inline_depth();
}
int TypeOopPtr::meet_inline_depth(int depth) const {
  return MAX2(inline_depth(), depth);
}
const TypeInstPtr *TypeInstPtr::NOTNULL;
const TypeInstPtr *TypeInstPtr::BOTTOM;
const TypeInstPtr *TypeInstPtr::MIRROR;
const TypeInstPtr *TypeInstPtr::MARK;
const TypeInstPtr *TypeInstPtr::KLASS;
TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative, int inline_depth)
  : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), _name(k->name()) {
   assert(k != NULL &&
          (k->is_loaded() || o == NULL),
          "cannot have constants with non-loaded klass");
};
const TypeInstPtr *TypeInstPtr::make(PTR ptr,
                                     ciKlass* k,
                                     bool xk,
                                     ciObject* o,
                                     int offset,
                                     int instance_id,
                                     const TypeOopPtr* speculative,
                                     int inline_depth) {
  assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
  assert( (!o && ptr != Constant) || (o && ptr == Constant),
          "constant pointers must have a value supplied" );
  assert( ptr != Null, "NULL pointers are not typed" );
  assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
  if (!UseExactTypes)  xk = false;
  if (ptr == Constant) {
    xk = true;
  } else if (k->is_loaded()) {
    ciInstanceKlass* ik = k->as_instance_klass();
    if (!xk && ik->is_final())     xk = true;   // no inexact final klass
    if (xk && ik->is_interface())  xk = false;  // no exact interface
  }
  TypeInstPtr *result =
    (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons();
  return result;
}
const Type* TypeInstPtr::get_const_boxed_value() const {
  assert(is_ptr_to_boxed_value(), "should be called only for boxed value");
  assert((const_oop() != NULL), "should be called only for constant object");
  ciConstant constant = const_oop()->as_instance()->field_value_by_offset(offset());
  BasicType bt = constant.basic_type();
  switch (bt) {
    case T_BOOLEAN:  return TypeInt::make(constant.as_boolean());
    case T_INT:      return TypeInt::make(constant.as_int());
    case T_CHAR:     return TypeInt::make(constant.as_char());
    case T_BYTE:     return TypeInt::make(constant.as_byte());
    case T_SHORT:    return TypeInt::make(constant.as_short());
    case T_FLOAT:    return TypeF::make(constant.as_float());
    case T_DOUBLE:   return TypeD::make(constant.as_double());
    case T_LONG:     return TypeLong::make(constant.as_long());
    default:         break;
  }
  fatal(err_msg_res("Invalid boxed value type '%s'", type2name(bt)));
  return NULL;
}
const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
  if( ptr == _ptr ) return this;
  return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth);
}
const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
  if( klass_is_exact == _klass_is_exact ) return this;
  if (!UseExactTypes)  return this;
  if (!_klass->is_loaded())  return this;
  ciInstanceKlass* ik = _klass->as_instance_klass();
  if( (ik->is_final() || _const_oop) )  return this;  // cannot clear xk
  if( ik->is_interface() )              return this;  // cannot set xk
  return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
}
const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
  if( instance_id == _instance_id ) return this;
  return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
}
const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
    int off = meet_offset(tinst->offset());
    PTR ptr = meet_ptr(tinst->ptr());
    int instance_id = meet_instance_id(tinst->instance_id());
    const TypeOopPtr* speculative = xmeet_speculative(tinst);
    int depth = meet_inline_depth(tinst->inline_depth());
    const TypeInstPtr *loaded    = is_loaded() ? this  : tinst;
    const TypeInstPtr *unloaded  = is_loaded() ? tinst : this;
    if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
      assert(loaded->ptr() != TypePtr::Null, "insanity check");
      if(      loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
      else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); }
      else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
      else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
        if (unloaded->ptr() == TypePtr::BotPTR  ) { return TypeInstPtr::BOTTOM;  }
        else                                      { return TypeInstPtr::NOTNULL; }
      }
      else if( unloaded->ptr() == TypePtr::TopPTR )  { return unloaded; }
      return unloaded->cast_to_ptr_type(TypePtr::AnyNull)->is_instptr();
    }
    if( ptr != TypePtr::BotPTR ) {
      return TypeInstPtr::NOTNULL;
    }
    return TypeInstPtr::BOTTOM;
}
const Type *TypeInstPtr::xmeet_helper(const Type *t) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Int:                     // Mixing ints & oops happens when javac
  case Long:                    // reuses local variables
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  default:                      // All else is a mistake
    typerr(t);
  case MetadataPtr:
  case KlassPtr:
  case RawPtr: return TypePtr::BOTTOM;
  case AryPtr: {                // All arrays inherit from Object class
    const TypeAryPtr *tp = t->is_aryptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    int instance_id = meet_instance_id(tp->instance_id());
    const TypeOopPtr* speculative = xmeet_speculative(tp);
    int depth = meet_inline_depth(tp->inline_depth());
    switch (ptr) {
    case TopPTR:
    case AnyNull:                // Fall 'down' to dual of object klass
      if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
        return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth);
      } else {
        ptr = NotNull;
        instance_id = InstanceBot;
        return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
      }
    case Constant:
    case NotNull:
    case BotPTR:                // Fall down to object klass
      if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
        if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
          return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
                                  tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth);
        }
      }
      if( ptr == Constant )
         ptr = NotNull;
      instance_id = InstanceBot;
      return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
    default: typerr(t);
    }
  }
  case OopPtr: {                // Meeting to OopPtrs
    const TypeOopPtr *tp = t->is_oopptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    switch (tp->ptr()) {
    case TopPTR:
    case AnyNull: {
      int instance_id = meet_instance_id(InstanceTop);
      const TypeOopPtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      return make(ptr, klass(), klass_is_exact(),
                  (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth);
    }
    case NotNull:
    case BotPTR: {
      int instance_id = meet_instance_id(tp->instance_id());
      const TypeOopPtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
    }
    default: typerr(t);
    }
  }
  case AnyPtr: {                // Meeting to AnyPtrs
    const TypePtr *tp = t->is_ptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    switch (tp->ptr()) {
    case Null:
      if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
    case TopPTR:
    case AnyNull: {
      int instance_id = meet_instance_id(InstanceTop);
      const TypeOopPtr* speculative = _speculative;
      return make(ptr, klass(), klass_is_exact(),
                  (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, _inline_depth);
    }
    case NotNull:
    case BotPTR:
      return TypePtr::make(AnyPtr, ptr, offset);
    default: typerr(t);
    }
  }
                 A-top         }
               /   |   \       }  Tops
           B-top A-any C-top   }
              | /  |  \ |      }  Any-nulls
           B-any   |   C-any   }
              |    |    |
           B-con A-con C-con   } constants; not comparable across classes
              |    |    |
           B-not   |   C-not   }
              | \  |  / |      }  not-nulls
           B-bot A-not C-bot   }
               \   |   /       }  Bottoms
                 A-bot         }
  case InstPtr: {                // Meeting 2 Oops?
    const TypeInstPtr *tinst = t->is_instptr();
    int off = meet_offset( tinst->offset() );
    PTR ptr = meet_ptr( tinst->ptr() );
    int instance_id = meet_instance_id(tinst->instance_id());
    const TypeOopPtr* speculative = xmeet_speculative(tinst);
    int depth = meet_inline_depth(tinst->inline_depth());
    if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) {
      return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative, depth);
    }
    ciKlass* tinst_klass = tinst->klass();
    ciKlass* this_klass  = this->klass();
    bool tinst_xk = tinst->klass_is_exact();
    bool this_xk  = this->klass_is_exact();
    if (!tinst_klass->is_loaded() || !this_klass->is_loaded() ) {
      const TypeInstPtr *unloaded_meet = xmeet_unloaded(tinst);
#ifndef PRODUCT
      if( PrintOpto && Verbose ) {
        tty->print("meet of unloaded classes resulted in: "); unloaded_meet->dump(); tty->cr();
        tty->print("  this == "); this->dump(); tty->cr();
        tty->print(" tinst == "); tinst->dump(); tty->cr();
      }
#endif
      return unloaded_meet;
    }
    if( this_klass->is_interface() && !(tinst_klass->is_interface() ||
                                        tinst_klass == ciEnv::current()->Object_klass())) {
      ciKlass *tmp = tinst_klass; // Swap interface around
      tinst_klass = this_klass;
      this_klass = tmp;
      bool tmp2 = tinst_xk;
      tinst_xk = this_xk;
      this_xk = tmp2;
    }
    if (tinst_klass->is_interface() &&
        !(this_klass->is_interface() ||
          this_klass == ciEnv::current()->Object_klass())) {
      ciKlass *k;
      bool xk;
      if( this_klass->is_subtype_of( tinst_klass ) ) {
        k  = below_centerline(ptr) ? tinst_klass : this_klass;
        xk = below_centerline(ptr) ? tinst_xk    : this_xk;
      } else {                  // Does not implement, fall to Object
        k = above_centerline(ptr) ? tinst_klass : ciEnv::current()->Object_klass();
        xk = above_centerline(ptr) ? tinst_xk : false;
        if (ptr == Constant)  ptr = NotNull;   // forget it was a constant
        instance_id = InstanceBot;
      }
      ciObject* o = NULL;  // the Constant value, if any
      if (ptr == Constant) {
        o = (this_klass == klass()) ? const_oop() : tinst->const_oop();
      }
      return make(ptr, k, xk, o, off, instance_id, speculative, depth);
    }
    ciKlass *subtype = NULL;
    bool subtype_exact = false;
    if( tinst_klass->equals(this_klass) ) {
      subtype = this_klass;
      subtype_exact = below_centerline(ptr) ? (this_xk & tinst_xk) : (this_xk | tinst_xk);
    } else if( !tinst_xk && this_klass->is_subtype_of( tinst_klass ) ) {
      subtype = this_klass;     // Pick subtyping class
      subtype_exact = this_xk;
    } else if( !this_xk && tinst_klass->is_subtype_of( this_klass ) ) {
      subtype = tinst_klass;    // Pick subtyping class
      subtype_exact = tinst_xk;
    }
    if( subtype ) {
      if( above_centerline(ptr) ) { // both are up?
        this_klass = tinst_klass = subtype;
        this_xk = tinst_xk = subtype_exact;
      } else if( above_centerline(this ->_ptr) && !above_centerline(tinst->_ptr) ) {
        this_klass = tinst_klass; // tinst is down; keep down man
        this_xk = tinst_xk;
      } else if( above_centerline(tinst->_ptr) && !above_centerline(this ->_ptr) ) {
        tinst_klass = this_klass; // this is down; keep down man
        tinst_xk = this_xk;
      } else {
        this_xk = subtype_exact;  // either they are equal, or we'll do an LCA
      }
    }
    if (tinst_klass->equals(this_klass)) {
      ciObject* o = NULL;             // Assume not constant when done
      ciObject* this_oop  = const_oop();
      ciObject* tinst_oop = tinst->const_oop();
      if( ptr == Constant ) {
        if (this_oop != NULL && tinst_oop != NULL &&
            this_oop->equals(tinst_oop) )
          o = this_oop;
        else if (above_centerline(this ->_ptr))
          o = tinst_oop;
        else if (above_centerline(tinst ->_ptr))
          o = this_oop;
        else
          ptr = NotNull;
      }
      return make(ptr, this_klass, this_xk, o, off, instance_id, speculative, depth);
    } // Else classes are not equal
    if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
      ptr = NotNull;
    instance_id = InstanceBot;
    ciKlass* k = this_klass->least_common_ancestor(tinst_klass);
    return make(ptr, k, false, NULL, off, instance_id, speculative, depth);
  } // End of case InstPtr
  } // End of switch
  return this;                  // Return the double constant
}
ciType* TypeInstPtr::java_mirror_type() const {
  if( const_oop() == NULL )  return NULL;
  if( klass() != ciEnv::current()->Class_klass() )  return NULL;
  return const_oop()->as_instance()->java_mirror_type();
}
const Type *TypeInstPtr::xdual() const {
  return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
}
bool TypeInstPtr::eq( const Type *t ) const {
  const TypeInstPtr *p = t->is_instptr();
  return
    klass()->equals(p->klass()) &&
    TypeOopPtr::eq(p);          // Check sub-type stuff
}
int TypeInstPtr::hash(void) const {
  int hash = java_add(klass()->hash(), TypeOopPtr::hash());
  return hash;
}
#ifndef PRODUCT
void TypeInstPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
  klass()->print_name_on(st);
  switch( _ptr ) {
  case Constant:
    if (WizardMode || Verbose) {
      const_oop()->print_oop(st);
    }
  case BotPTR:
    if (!WizardMode && !Verbose) {
      if( _klass_is_exact ) st->print(":exact");
      break;
    }
  case TopPTR:
  case AnyNull:
  case NotNull:
    st->print(":%s", ptr_msg[_ptr]);
    if( _klass_is_exact ) st->print(":exact");
    break;
  }
  if( _offset ) {               // Dump offset, if any
    if( _offset == OffsetBot )      st->print("+any");
    else if( _offset == OffsetTop ) st->print("+unknown");
    else st->print("+%d", _offset);
  }
  st->print(" *");
  if (_instance_id == InstanceTop)
    st->print(",iid=top");
  else if (_instance_id != InstanceBot)
    st->print(",iid=%d",_instance_id);
  dump_inline_depth(st);
  dump_speculative(st);
}
#endif
const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const {
  return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset));
}
const Type *TypeInstPtr::remove_speculative() const {
  if (_speculative == NULL) {
    return this;
  }
  assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
  return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL, _inline_depth);
}
const TypeOopPtr *TypeInstPtr::with_inline_depth(int depth) const {
  if (!UseInlineDepthForSpeculativeTypes) {
    return this;
  }
  return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth);
}
const TypeAryPtr *TypeAryPtr::RANGE;
const TypeAryPtr *TypeAryPtr::OOPS;
const TypeAryPtr *TypeAryPtr::NARROWOOPS;
const TypeAryPtr *TypeAryPtr::BYTES;
const TypeAryPtr *TypeAryPtr::SHORTS;
const TypeAryPtr *TypeAryPtr::CHARS;
const TypeAryPtr *TypeAryPtr::INTS;
const TypeAryPtr *TypeAryPtr::LONGS;
const TypeAryPtr *TypeAryPtr::FLOATS;
const TypeAryPtr *TypeAryPtr::DOUBLES;
const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) {
  assert(!(k == NULL && ary->_elem->isa_int()),
         "integral arrays must be pre-equipped with a class");
  if (!xk)  xk = ary->ary_must_be_exact();
  assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
  if (!UseExactTypes)  xk = (ptr == Constant);
  return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons();
}
const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth, bool is_autobox_cache) {
  assert(!(k == NULL && ary->_elem->isa_int()),
         "integral arrays must be pre-equipped with a class");
  assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
  if (!xk)  xk = (o != NULL) || ary->ary_must_be_exact();
  assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
  if (!UseExactTypes)  xk = (ptr == Constant);
  return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons();
}
const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
  if( ptr == _ptr ) return this;
  return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
}
const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
  if( klass_is_exact == _klass_is_exact ) return this;
  if (!UseExactTypes)  return this;
  if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
  return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
}
const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
  if( instance_id == _instance_id ) return this;
  return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
}
jint TypeAryPtr::max_array_length(BasicType etype) {
  if (!is_java_primitive(etype) && !is_reference_type(etype)) {
    if (etype == T_NARROWOOP) {
      etype = T_OBJECT;
    } else if (etype == T_ILLEGAL) { // bottom[]
      etype = T_BYTE; // will produce conservatively high value
    } else {
      fatal(err_msg("not an element type: %s", type2name(etype)));
    }
  }
  return arrayOopDesc::max_array_length(etype);
}
const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
  jint hi = size->_hi;
  jint lo = size->_lo;
  jint min_lo = 0;
  jint max_hi = max_array_length(elem()->basic_type());
  bool chg = false;
  if (lo < min_lo) {
    lo = min_lo;
    if (size->is_con()) {
      hi = lo;
    }
    chg = true;
  }
  if (hi > max_hi) {
    hi = max_hi;
    if (size->is_con()) {
      lo = hi;
    }
    chg = true;
  }
  if (lo > hi)
    return TypeInt::ZERO;
  if (!chg)
    return size;
  return TypeInt::make(lo, hi, Type::WidenMin);
}
const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
  assert(new_size != NULL, "");
  new_size = narrow_size_type(new_size);
  if (new_size == size())  return this;
  const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable());
  return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
}
const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
  if (stable_dimension <= 0 || (stable_dimension == 1 && stable == this->is_stable()))
    return this;
  const Type* elem = this->elem();
  const TypePtr* elem_ptr = elem->make_ptr();
  if (stable_dimension > 1 && elem_ptr != NULL && elem_ptr->isa_aryptr()) {
    elem = elem_ptr = elem_ptr->is_aryptr()->cast_to_stable(stable, stable_dimension - 1);
  }
  const TypeAry* new_ary = TypeAry::make(elem, size(), stable);
  return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id);
}
int TypeAryPtr::stable_dimension() const {
  if (!is_stable())  return 0;
  int dim = 1;
  const TypePtr* elem_ptr = elem()->make_ptr();
  if (elem_ptr != NULL && elem_ptr->isa_aryptr())
    dim += elem_ptr->is_aryptr()->stable_dimension();
  return dim;
}
bool TypeAryPtr::eq( const Type *t ) const {
  const TypeAryPtr *p = t->is_aryptr();
  return
    _ary == p->_ary &&  // Check array
    TypeOopPtr::eq(p);  // Check sub-parts
}
int TypeAryPtr::hash(void) const {
  return (intptr_t)_ary + TypeOopPtr::hash();
}
const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Int:
  case Long:
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  default:                      // All else is a mistake
    typerr(t);
  case OopPtr: {                // Meeting to OopPtrs
    const TypeOopPtr *tp = t->is_oopptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    int depth = meet_inline_depth(tp->inline_depth());
    switch (tp->ptr()) {
    case TopPTR:
    case AnyNull: {
      int instance_id = meet_instance_id(InstanceTop);
      const TypeOopPtr* speculative = xmeet_speculative(tp);
      return make(ptr, (ptr == Constant ? const_oop() : NULL),
                  _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
    }
    case BotPTR:
    case NotNull: {
      int instance_id = meet_instance_id(tp->instance_id());
      const TypeOopPtr* speculative = xmeet_speculative(tp);
      return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
    }
    default: ShouldNotReachHere();
    }
  }
  case AnyPtr: {                // Meeting two AnyPtrs
    const TypePtr *tp = t->is_ptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    switch (tp->ptr()) {
    case TopPTR:
      return this;
    case BotPTR:
    case NotNull:
      return TypePtr::make(AnyPtr, ptr, offset);
    case Null:
      if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
    case AnyNull: {
      int instance_id = meet_instance_id(InstanceTop);
      const TypeOopPtr* speculative = _speculative;
      return make(ptr, (ptr == Constant ? const_oop() : NULL),
                  _ary, _klass, _klass_is_exact, offset, instance_id, speculative, _inline_depth);
    }
    default: ShouldNotReachHere();
    }
  }
  case MetadataPtr:
  case KlassPtr:
  case RawPtr: return TypePtr::BOTTOM;
  case AryPtr: {                // Meeting 2 references?
    const TypeAryPtr *tap = t->is_aryptr();
    int off = meet_offset(tap->offset());
    const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary();
    PTR ptr = meet_ptr(tap->ptr());
    int instance_id = meet_instance_id(tap->instance_id());
    const TypeOopPtr* speculative = xmeet_speculative(tap);
    int depth = meet_inline_depth(tap->inline_depth());
    ciKlass* lazy_klass = NULL;
    if (tary->_elem->isa_int()) {
      if (_klass == NULL)
        lazy_klass = tap->_klass;
      else if (tap->_klass == NULL || tap->_klass == _klass) {
        lazy_klass = _klass;
      } else {
        instance_id = InstanceBot;
        tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable);
      }
    } else // Non integral arrays.
      if ((above_centerline(ptr) || ptr == Constant) && klass() != tap->klass() &&
          tap->_klass != NULL  && this->_klass != NULL   &&
          ((tap->_klass_is_exact && this->_klass_is_exact) ||
           (tap->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) ||
           (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) {
      if (above_centerline(ptr) || (tary->_elem->make_ptr() && above_centerline(tary->_elem->make_ptr()->_ptr))) {
        tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable);
      }
      return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot, speculative, depth);
    }
    bool xk = false;
    switch (tap->ptr()) {
    case AnyNull:
    case TopPTR:
      if (below_centerline(this->_ptr)) {
        xk = this->_klass_is_exact;
      } else {
        xk = (tap->_klass_is_exact | this->_klass_is_exact);
      }
      return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth);
    case Constant: {
      ciObject* o = const_oop();
      if( _ptr == Constant ) {
        if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
          xk = (klass() == tap->klass());
          ptr = NotNull;
          o = NULL;
          instance_id = InstanceBot;
        } else {
          xk = true;
        }
      } else if(above_centerline(_ptr)) {
        o = tap->const_oop();
        xk = true;
      } else {
        xk = this->_klass_is_exact && (klass() == tap->klass());
      }
      return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative, depth);
    }
    case NotNull:
    case BotPTR:
      if (above_centerline(this->_ptr))
            xk = tap->_klass_is_exact;
      else  xk = (tap->_klass_is_exact & this->_klass_is_exact) &&
              (klass() == tap->klass()); // Only precise for identical arrays
      return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative, depth);
    default: ShouldNotReachHere();
    }
  }
  case InstPtr: {
    const TypeInstPtr *tp = t->is_instptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    int instance_id = meet_instance_id(tp->instance_id());
    const TypeOopPtr* speculative = xmeet_speculative(tp);
    int depth = meet_inline_depth(tp->inline_depth());
    switch (ptr) {
    case TopPTR:
    case AnyNull:                // Fall 'down' to dual of object klass
      if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
        return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
      } else {
        ptr = NotNull;
        instance_id = InstanceBot;
        return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
      }
    case Constant:
    case NotNull:
    case BotPTR:                // Fall down to object klass
      if (above_centerline(tp->ptr())) {
        if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
          return make(ptr, (ptr == Constant ? const_oop() : NULL),
                      _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
        }
      }
      if( ptr == Constant )
         ptr = NotNull;
      instance_id = InstanceBot;
      return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
    default: typerr(t);
    }
  }
  }
  return this;                  // Lint noise
}
const Type *TypeAryPtr::xdual() const {
  return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth());
}
#ifdef ASSERT
bool TypeAryPtr::interface_vs_oop(const Type *t) const {
  const TypeAryPtr* t_aryptr = t->isa_aryptr();
  if (t_aryptr) {
    return _ary->interface_vs_oop(t_aryptr->_ary);
  }
  return false;
}
#endif
#ifndef PRODUCT
void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
  _ary->dump2(d,depth,st);
  switch( _ptr ) {
  case Constant:
    const_oop()->print(st);
    break;
  case BotPTR:
    if (!WizardMode && !Verbose) {
      if( _klass_is_exact ) st->print(":exact");
      break;
    }
  case TopPTR:
  case AnyNull:
  case NotNull:
    st->print(":%s", ptr_msg[_ptr]);
    if( _klass_is_exact ) st->print(":exact");
    break;
  }
  if( _offset != 0 ) {
    int header_size = objArrayOopDesc::header_size() * wordSize;
    if( _offset == OffsetTop )       st->print("+undefined");
    else if( _offset == OffsetBot )  st->print("+any");
    else if( _offset < header_size ) st->print("+%d", _offset);
    else {
      BasicType basic_elem_type = elem()->basic_type();
      int array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
      int elem_size = type2aelembytes(basic_elem_type);
      st->print("[%d]", (_offset - array_base)/elem_size);
    }
  }
  st->print(" *");
  if (_instance_id == InstanceTop)
    st->print(",iid=top");
  else if (_instance_id != InstanceBot)
    st->print(",iid=%d",_instance_id);
  dump_inline_depth(st);
  dump_speculative(st);
}
#endif
bool TypeAryPtr::empty(void) const {
  if (_ary->empty())       return true;
  return TypeOopPtr::empty();
}
const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const {
  return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);
}
const Type *TypeAryPtr::remove_speculative() const {
  if (_speculative == NULL) {
    return this;
  }
  assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
  return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth);
}
const TypeOopPtr *TypeAryPtr::with_inline_depth(int depth) const {
  if (!UseInlineDepthForSpeculativeTypes) {
    return this;
  }
  return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth);
}
int TypeNarrowPtr::hash(void) const {
  return _ptrtype->hash() + 7;
}
bool TypeNarrowPtr::singleton(void) const {    // TRUE if type is a singleton
  return _ptrtype->singleton();
}
bool TypeNarrowPtr::empty(void) const {
  return _ptrtype->empty();
}
intptr_t TypeNarrowPtr::get_con() const {
  return _ptrtype->get_con();
}
bool TypeNarrowPtr::eq( const Type *t ) const {
  const TypeNarrowPtr* tc = isa_same_narrowptr(t);
  if (tc != NULL) {
    if (_ptrtype->base() != tc->_ptrtype->base()) {
      return false;
    }
    return tc->_ptrtype->eq(_ptrtype);
  }
  return false;
}
const Type *TypeNarrowPtr::xdual() const {    // Compute dual right now.
  const TypePtr* odual = _ptrtype->dual()->is_ptr();
  return make_same_narrowptr(odual);
}
const Type *TypeNarrowPtr::filter_helper(const Type *kills, bool include_speculative) const {
  if (isa_same_narrowptr(kills)) {
    const Type* ft =_ptrtype->filter_helper(is_same_narrowptr(kills)->_ptrtype, include_speculative);
    if (ft->empty())
      return Type::TOP;           // Canonical empty value
    if (ft->isa_ptr()) {
      return make_hash_same_narrowptr(ft->isa_ptr());
    }
    return ft;
  } else if (kills->isa_ptr()) {
    const Type* ft = _ptrtype->join_helper(kills, include_speculative);
    if (ft->empty())
      return Type::TOP;           // Canonical empty value
    return ft;
  } else {
    return Type::TOP;
  }
}
const Type *TypeNarrowPtr::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  if (t->base() == base()) {
    const Type* result = _ptrtype->xmeet(t->make_ptr());
    if (result->isa_ptr()) {
      return make_hash_same_narrowptr(result->is_ptr());
    }
    return result;
  }
  switch (t->base()) {          // switch on original type
  case Int:                     // Mixing ints & oops happens when javac
  case Long:                    // reuses local variables
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case AnyPtr:
  case RawPtr:
  case OopPtr:
  case InstPtr:
  case AryPtr:
  case MetadataPtr:
  case KlassPtr:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  default:                      // All else is a mistake
    typerr(t);
  } // End of switch
  return this;
}
#ifndef PRODUCT
void TypeNarrowPtr::dump2( Dict & d, uint depth, outputStream *st ) const {
  _ptrtype->dump2(d, depth, st);
}
#endif
const TypeNarrowOop *TypeNarrowOop::BOTTOM;
const TypeNarrowOop *TypeNarrowOop::NULL_PTR;
const TypeNarrowOop* TypeNarrowOop::make(const TypePtr* type) {
  return (const TypeNarrowOop*)(new TypeNarrowOop(type))->hashcons();
}
#ifndef PRODUCT
void TypeNarrowOop::dump2( Dict & d, uint depth, outputStream *st ) const {
  st->print("narrowoop: ");
  TypeNarrowPtr::dump2(d, depth, st);
}
#endif
const TypeNarrowKlass *TypeNarrowKlass::NULL_PTR;
const TypeNarrowKlass* TypeNarrowKlass::make(const TypePtr* type) {
  return (const TypeNarrowKlass*)(new TypeNarrowKlass(type))->hashcons();
}
#ifndef PRODUCT
void TypeNarrowKlass::dump2( Dict & d, uint depth, outputStream *st ) const {
  st->print("narrowklass: ");
  TypeNarrowPtr::dump2(d, depth, st);
}
#endif
bool TypeMetadataPtr::eq( const Type *t ) const {
  const TypeMetadataPtr *a = (const TypeMetadataPtr*)t;
  ciMetadata* one = metadata();
  ciMetadata* two = a->metadata();
  if (one == NULL || two == NULL) {
    return (one == two) && TypePtr::eq(t);
  } else {
    return one->equals(two) && TypePtr::eq(t);
  }
}
int TypeMetadataPtr::hash(void) const {
  return
    (metadata() ? metadata()->hash() : 0) +
    TypePtr::hash();
}
bool TypeMetadataPtr::singleton(void) const {
  return (_offset == 0) && !below_centerline(_ptr);
}
const TypePtr *TypeMetadataPtr::add_offset( intptr_t offset ) const {
  return make( _ptr, _metadata, xadd_offset(offset));
}
const Type *TypeMetadataPtr::filter_helper(const Type *kills, bool include_speculative) const {
  const TypeMetadataPtr* ft = join_helper(kills, include_speculative)->isa_metadataptr();
  if (ft == NULL || ft->empty())
    return Type::TOP;           // Canonical empty value
  return ft;
}
intptr_t TypeMetadataPtr::get_con() const {
  assert( _ptr == Null || _ptr == Constant, "" );
  assert( _offset >= 0, "" );
  if (_offset != 0) {
    tty->print_cr("Found oop constant with non-zero offset");
    ShouldNotReachHere();
  }
  return (intptr_t)metadata()->constant_encoding();
}
const Type *TypeMetadataPtr::cast_to_ptr_type(PTR ptr) const {
  if( ptr == _ptr ) return this;
  return make(ptr, metadata(), _offset);
}
const Type *TypeMetadataPtr::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Int:                     // Mixing ints & oops happens when javac
  case Long:                    // reuses local variables
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  default:                      // All else is a mistake
    typerr(t);
  case AnyPtr: {
    const TypePtr *tp = t->is_ptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    switch (tp->ptr()) {
    case Null:
      if (ptr == Null)  return TypePtr::make(AnyPtr, ptr, offset);
    case TopPTR:
    case AnyNull: {
      return make(ptr, _metadata, offset);
    }
    case BotPTR:
    case NotNull:
      return TypePtr::make(AnyPtr, ptr, offset);
    default: typerr(t);
    }
  }
  case RawPtr:
  case KlassPtr:
  case OopPtr:
  case InstPtr:
  case AryPtr:
    return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  case MetadataPtr: {
    const TypeMetadataPtr *tp = t->is_metadataptr();
    int offset = meet_offset(tp->offset());
    PTR tptr = tp->ptr();
    PTR ptr = meet_ptr(tptr);
    ciMetadata* md = (tptr == TopPTR) ? metadata() : tp->metadata();
    if (tptr == TopPTR || _ptr == TopPTR ||
        metadata()->equals(tp->metadata())) {
      return make(ptr, md, offset);
    }
    if( ptr == Constant ) {  // Cannot be equal constants, so...
      if( tptr == Constant && _ptr != Constant)  return t;
      if( _ptr == Constant && tptr != Constant)  return this;
      ptr = NotNull;            // Fall down in lattice
    }
    return make(ptr, NULL, offset);
    break;
  }
  } // End of switch
  return this;                  // Return the double constant
}
const Type *TypeMetadataPtr::xdual() const {
  return new TypeMetadataPtr(dual_ptr(), metadata(), dual_offset());
}
#ifndef PRODUCT
void TypeMetadataPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
  st->print("metadataptr:%s", ptr_msg[_ptr]);
  if( metadata() ) st->print(INTPTR_FORMAT, metadata());
  switch( _offset ) {
  case OffsetTop: st->print("+top"); break;
  case OffsetBot: st->print("+any"); break;
  case         0: break;
  default:        st->print("+%d",_offset); break;
  }
}
#endif
const TypeMetadataPtr *TypeMetadataPtr::BOTTOM;
TypeMetadataPtr::TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset):
  TypePtr(MetadataPtr, ptr, offset), _metadata(metadata) {
}
const TypeMetadataPtr* TypeMetadataPtr::make(ciMethod* m) {
  return make(Constant, m, 0);
}
const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) {
  return make(Constant, m, 0);
}
const TypeMetadataPtr *TypeMetadataPtr::make(PTR ptr, ciMetadata* m, int offset) {
  assert(m == NULL || !m->is_klass(), "wrong type");
  return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons();
}
const TypeKlassPtr *TypeKlassPtr::OBJECT;
const TypeKlassPtr *TypeKlassPtr::OBJECT_OR_NULL;
TypeKlassPtr::TypeKlassPtr( PTR ptr, ciKlass* klass, int offset )
  : TypePtr(KlassPtr, ptr, offset), _klass(klass), _klass_is_exact(ptr == Constant) {
}
const TypeKlassPtr *TypeKlassPtr::make( PTR ptr, ciKlass* k, int offset ) {
  assert( k != NULL, "Expect a non-NULL klass");
  assert(k->is_instance_klass() || k->is_array_klass(), "Incorrect type of klass oop");
  TypeKlassPtr *r =
    (TypeKlassPtr*)(new TypeKlassPtr(ptr, k, offset))->hashcons();
  return r;
}
bool TypeKlassPtr::eq( const Type *t ) const {
  const TypeKlassPtr *p = t->is_klassptr();
  return
    klass()->equals(p->klass()) &&
    TypePtr::eq(p);
}
int TypeKlassPtr::hash(void) const {
  return java_add(klass()->hash(), TypePtr::hash());
}
bool TypeKlassPtr::singleton(void) const {
  return (_offset == 0) && !below_centerline(_ptr);
}
const Type *TypeKlassPtr::filter_helper(const Type *kills, bool include_speculative) const {
  const Type* ft = join_helper(kills, include_speculative);
  const TypeKlassPtr* ftkp = ft->isa_klassptr();
  const TypeKlassPtr* ktkp = kills->isa_klassptr();
  if (ft->empty()) {
    if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface())
      return kills;             // Uplift to interface
    return Type::TOP;           // Canonical empty value
  }
  if (ftkp != NULL && ktkp != NULL &&
      ftkp->is_loaded() &&  ftkp->klass()->is_interface() &&
      !ftkp->klass_is_exact() && // Keep exact interface klass
      ktkp->is_loaded() && !ktkp->klass()->is_interface()) {
    return ktkp->cast_to_ptr_type(ftkp->ptr());
  }
  return ft;
}
ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const {
  ciKlass* k_ary = NULL;
  const TypeInstPtr *tinst;
  const TypeAryPtr *tary;
  const Type* el = elem();
  if (el->isa_narrowoop()) {
    el = el->make_ptr();
  }
  if ((tinst = el->isa_instptr()) != NULL) {
    k_ary = ciObjArrayKlass::make(tinst->klass());
  } else if ((tary = el->isa_aryptr()) != NULL) {
    ciKlass* k_elem = tary->klass();
    if (k_elem != NULL)
      k_ary = ciObjArrayKlass::make(k_elem);
  } else if ((el->base() == Type::Top) ||
             (el->base() == Type::Bottom)) {
  } else {
#ifdef ASSERT
    if (verify && el->isa_int()) {
      BasicType bt = T_ILLEGAL;
      if (el == TypeInt::BYTE) {
        bt = T_BYTE;
      } else if (el == TypeInt::SHORT) {
        bt = T_SHORT;
      } else if (el == TypeInt::CHAR) {
        bt = T_CHAR;
      } else if (el == TypeInt::INT) {
        bt = T_INT;
      } else {
        return _klass; // just return specified klass
      }
      return ciTypeArrayKlass::make(bt);
    }
#endif
    assert(!el->isa_int(),
           "integral arrays must be pre-equipped with a class");
    k_ary = ciTypeArrayKlass::make(el->basic_type());
  }
  return k_ary;
}
ciKlass* TypeAryPtr::klass() const {
  if( _klass ) return _klass;   // Return cached value, if possible
  ciKlass* k_ary = compute_klass();
  if( this != TypeAryPtr::OOPS && this->dual() != TypeAryPtr::OOPS ) {
    ((TypeAryPtr*)this)->_klass = k_ary;
    if (UseCompressedOops && k_ary != NULL && k_ary->is_obj_array_klass() &&
        _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes()) {
      ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true;
    }
  }
  return k_ary;
}
const TypePtr *TypeKlassPtr::add_offset( intptr_t offset ) const {
  return make( _ptr, klass(), xadd_offset(offset) );
}
const Type *TypeKlassPtr::cast_to_ptr_type(PTR ptr) const {
  assert(_base == KlassPtr, "subclass must override cast_to_ptr_type");
  if( ptr == _ptr ) return this;
  return make(ptr, _klass, _offset);
}
const Type *TypeKlassPtr::cast_to_exactness(bool klass_is_exact) const {
  if( klass_is_exact == _klass_is_exact ) return this;
  if (!UseExactTypes)  return this;
  return make(klass_is_exact ? Constant : NotNull, _klass, _offset);
}
const TypeOopPtr* TypeKlassPtr::as_instance_type() const {
  ciKlass* k = klass();
  bool    xk = klass_is_exact();
  const TypeOopPtr* toop = TypeOopPtr::make_from_klass_raw(k);
  guarantee(toop != NULL, "need type for given klass");
  toop = toop->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
  return toop->cast_to_exactness(xk)->is_oopptr();
}
const Type    *TypeKlassPtr::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Int:                     // Mixing ints & oops happens when javac
  case Long:                    // reuses local variables
  case FloatTop:
  case FloatCon:
  case FloatBot:
  case DoubleTop:
  case DoubleCon:
  case DoubleBot:
  case NarrowOop:
  case NarrowKlass:
  case Bottom:                  // Ye Olde Default
    return Type::BOTTOM;
  case Top:
    return this;
  default:                      // All else is a mistake
    typerr(t);
  case AnyPtr: {                // Meeting to AnyPtrs
    const TypePtr *tp = t->is_ptr();
    int offset = meet_offset(tp->offset());
    PTR ptr = meet_ptr(tp->ptr());
    switch (tp->ptr()) {
    case TopPTR:
      return this;
    case Null:
      if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset );
    case AnyNull:
      return make( ptr, klass(), offset );
    case BotPTR:
    case NotNull:
      return TypePtr::make(AnyPtr, ptr, offset);
    default: typerr(t);
    }
  }
  case RawPtr:
  case MetadataPtr:
  case OopPtr:
  case AryPtr:                  // Meet with AryPtr
  case InstPtr:                 // Meet with InstPtr
    return TypePtr::BOTTOM;
  case KlassPtr: {  // Meet two KlassPtr types
    const TypeKlassPtr *tkls = t->is_klassptr();
    int  off     = meet_offset(tkls->offset());
    PTR  ptr     = meet_ptr(tkls->ptr());
    if( ptr != Constant && tkls->klass()->equals(klass()) ) {
      return make( ptr, klass(), off );
    }
    ciKlass* tkls_klass = tkls->klass();
    ciKlass* this_klass = this->klass();
    assert( tkls_klass->is_loaded(), "This class should have been loaded.");
    assert( this_klass->is_loaded(), "This class should have been loaded.");
    if ((above_centerline(this->ptr())) &&
        tkls_klass->is_subtype_of(this_klass)) {
      this_klass = tkls_klass;
    }
    if ((above_centerline(tkls->ptr())) &&
        this_klass->is_subtype_of(tkls_klass)) {
      tkls_klass = this_klass;
    }
    if (tkls_klass->equals(this_klass)) {
      if( ptr == Constant ) {
        if (this->_ptr == Constant && tkls->_ptr == Constant &&
            this->klass()->equals(tkls->klass()));
        else if (above_centerline(this->ptr()));
        else if (above_centerline(tkls->ptr()));
        else
          ptr = NotNull;
      }
      return make( ptr, this_klass, off );
    } // Else classes are not equal
    if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
      ptr = NotNull;
    ciKlass* k = this_klass->least_common_ancestor(tkls_klass);
    return   make( ptr, k, off );
  } // End of case KlassPtr
  } // End of switch
  return this;                  // Return the double constant
}
const Type    *TypeKlassPtr::xdual() const {
  return new TypeKlassPtr( dual_ptr(), klass(), dual_offset() );
}
intptr_t TypeKlassPtr::get_con() const {
  assert( _ptr == Null || _ptr == Constant, "" );
  assert( _offset >= 0, "" );
  if (_offset != 0) {
    tty->print_cr("Found oop constant with non-zero offset");
    ShouldNotReachHere();
  }
  return (intptr_t)klass()->constant_encoding();
}
#ifndef PRODUCT
void TypeKlassPtr::dump2( Dict & d, uint depth, outputStream *st ) const {
  switch( _ptr ) {
  case Constant:
    st->print("precise ");
  case NotNull:
    {
      const char *name = klass()->name()->as_utf8();
      if( name ) {
        st->print("klass %s: " INTPTR_FORMAT, name, klass());
      } else {
        ShouldNotReachHere();
      }
    }
  case BotPTR:
    if( !WizardMode && !Verbose && !_klass_is_exact ) break;
  case TopPTR:
  case AnyNull:
    st->print(":%s", ptr_msg[_ptr]);
    if( _klass_is_exact ) st->print(":exact");
    break;
  }
  if( _offset ) {               // Dump offset, if any
    if( _offset == OffsetBot )      { st->print("+any"); }
    else if( _offset == OffsetTop ) { st->print("+unknown"); }
    else                            { st->print("+%d", _offset); }
  }
  st->print(" *");
}
#endif
const TypeFunc *TypeFunc::make( const TypeTuple *domain, const TypeTuple *range ) {
  return (TypeFunc*)(new TypeFunc(domain,range))->hashcons();
}
const TypeFunc *TypeFunc::make(ciMethod* method) {
  Compile* C = Compile::current();
  const TypeFunc* tf = C->last_tf(method); // check cache
  if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
  const TypeTuple *domain;
  if (method->is_static()) {
    domain = TypeTuple::make_domain(NULL, method->signature());
  } else {
    domain = TypeTuple::make_domain(method->holder(), method->signature());
  }
  const TypeTuple *range  = TypeTuple::make_range(method->signature());
  tf = TypeFunc::make(domain, range);
  C->set_last_tf(method, tf);  // fill cache
  return tf;
}
const Type *TypeFunc::xmeet( const Type *t ) const {
  if( this == t ) return this;  // Meeting same type-rep?
  switch (t->base()) {          // switch on original type
  case Bottom:                  // Ye Olde Default
    return t;
  default:                      // All else is a mistake
    typerr(t);
  case Top:
    break;
  }
  return this;                  // Return the double constant
}
const Type *TypeFunc::xdual() const {
  return this;
}
bool TypeFunc::eq( const Type *t ) const {
  const TypeFunc *a = (const TypeFunc*)t;
  return _domain == a->_domain &&
    _range == a->_range;
}
int TypeFunc::hash(void) const {
  return (intptr_t)_domain + (intptr_t)_range;
}
#ifndef PRODUCT
void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const {
  if( _range->_cnt <= Parms )
    st->print("void");
  else {
    uint i;
    for (i = Parms; i < _range->_cnt-1; i++) {
      _range->field_at(i)->dump2(d,depth,st);
      st->print("/");
    }
    _range->field_at(i)->dump2(d,depth,st);
  }
  st->print(" ");
  st->print("( ");
  if( !depth || d[this] ) {     // Check for recursive dump
    st->print("...)");
    return;
  }
  d.Insert((void*)this,(void*)this);    // Stop recursion
  if (Parms < _domain->_cnt)
    _domain->field_at(Parms)->dump2(d,depth-1,st);
  for (uint i = Parms+1; i < _domain->_cnt; i++) {
    st->print(", ");
    _domain->field_at(i)->dump2(d,depth-1,st);
  }
  st->print(" )");
}
#endif
bool TypeFunc::singleton(void) const {
  return false;                 // Never a singleton
}
bool TypeFunc::empty(void) const {
  return false;                 // Never empty
}
BasicType TypeFunc::return_type() const{
  if (range()->cnt() == TypeFunc::Parms) {
    return T_VOID;
  }
  return range()->field_at(TypeFunc::Parms)->basic_type();
}
C:\hotspot-69087d08d473\src\share\vm/opto/type.hpp
#ifndef SHARE_VM_OPTO_TYPE_HPP
#define SHARE_VM_OPTO_TYPE_HPP
#include "libadt/port.hpp"
#include "opto/adlcVMDeps.hpp"
#include "runtime/handles.hpp"
class Dict;
class Type;
class   TypeD;
class   TypeF;
class   TypeInt;
class   TypeLong;
class   TypeNarrowPtr;
class     TypeNarrowOop;
class     TypeNarrowKlass;
class   TypeAry;
class   TypeTuple;
class   TypeVect;
class     TypeVectS;
class     TypeVectD;
class     TypeVectX;
class     TypeVectY;
class   TypePtr;
class     TypeRawPtr;
class     TypeOopPtr;
class       TypeInstPtr;
class       TypeAryPtr;
class     TypeKlassPtr;
class     TypeMetadataPtr;
class Type {
  friend class VMStructs;
public:
  enum TYPES {
    Bad=0,                      // Type check
    Control,                    // Control of code (not in lattice)
    Top,                        // Top of the lattice
    Int,                        // Integer range (lo-hi)
    Long,                       // Long integer range (lo-hi)
    Half,                       // Placeholder half of doubleword
    NarrowOop,                  // Compressed oop pointer
    NarrowKlass,                // Compressed klass pointer
    Tuple,                      // Method signature or object layout
    Array,                      // Array types
    VectorS,                    //  32bit Vector types
    VectorD,                    //  64bit Vector types
    VectorX,                    // 128bit Vector types
    VectorY,                    // 256bit Vector types
    AnyPtr,                     // Any old raw, klass, inst, or array pointer
    RawPtr,                     // Raw (non-oop) pointers
    OopPtr,                     // Any and all Java heap entities
    InstPtr,                    // Instance pointers (non-array objects)
    AryPtr,                     // Array pointers
    MetadataPtr,                // Generic metadata
    KlassPtr,                   // Klass pointers
    Function,                   // Function signature
    Abio,                       // Abstract I/O
    Return_Address,             // Subroutine return address
    Memory,                     // Abstract store
    FloatTop,                   // No float value
    FloatCon,                   // Floating point constant
    FloatBot,                   // Any float value
    DoubleTop,                  // No double value
    DoubleCon,                  // Double precision constant
    DoubleBot,                  // Any double value
    Bottom,                     // Bottom of lattice
    lastype                     // Bogus ending type (not in lattice)
  };
  enum OFFSET_SIGNALS {
    OffsetTop = -2000000000,    // undefined offset
    OffsetBot = -2000000001     // any possible offset
  };
  enum WIDEN {
    WidenMin = 0,
    WidenMax = 3
  };
private:
  typedef struct {
    TYPES                dual_type;
    BasicType            basic_type;
    const char*          msg;
    bool                 isa_oop;
    uint                 ideal_reg;
    relocInfo::relocType reloc;
  } TypeInfo;
  static Dict* _shared_type_dict;
  static const TypeInfo _type_info[];
  static int uhash( const Type *const t );
  virtual bool eq( const Type *t ) const;
  static Dict *type_dict() {
    return Compile::current()->type_dict();
  }
  const Type *_dual;            // Cached dual value
  static const TYPES dual_type[lastype];
#ifdef ASSERT
  virtual bool interface_vs_oop_helper(const Type *t) const;
#endif
  const Type *meet_helper(const Type *t, bool include_speculative) const;
  void check_symmetrical(const Type *t, const Type *mt) const;
protected:
  const TYPES _base;            // Enum of Types type
  Type( TYPES t ) : _dual(NULL),  _base(t) {} // Simple types
  const Type *hashcons();       // Hash-cons the type
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
  const Type *join_helper(const Type *t, bool include_speculative) const {
    return dual()->meet_helper(t->dual(), include_speculative)->dual();
  }
public:
  inline void* operator new( size_t x ) throw() {
    Compile* compile = Compile::current();
    compile->set_type_last_size(x);
    void *temp = compile->type_arena()->Amalloc_D(x);
    compile->set_type_hwm(temp);
    return temp;
  }
  inline void operator delete( void* ptr ) {
    Compile* compile = Compile::current();
    compile->type_arena()->Afree(ptr,compile->type_last_size());
  }
  static void Initialize(Compile* compile);
  static void Initialize_shared(Compile* compile);
  TYPES base() const {
    assert(_base > Bad && _base < lastype, "sanity");
    return _base;
  }
  static const Type *make(enum TYPES);
  static int cmp( const Type *const t1, const Type *const t2 );
  bool higher_equal(const Type *t) const {
    return !cmp(meet(t),t->remove_speculative());
  }
  bool higher_equal_speculative(const Type *t) const {
    return !cmp(meet_speculative(t),t);
  }
  const Type *meet(const Type *t) const {
    return meet_helper(t, false);
  }
  const Type *meet_speculative(const Type *t) const {
    return meet_helper(t, true);
  }
  virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
  virtual const Type *narrow( const Type *old ) const { return this; }
  const Type *dual() const { return _dual; }
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  const Type *join(const Type *t) const {
    return join_helper(t, false);
  }
  const Type *join_speculative(const Type *t) const {
    return join_helper(t, true);
  }
  const Type *filter(const Type *kills) const {
    return filter_helper(kills, false);
  }
  const Type *filter_speculative(const Type *kills) const {
    return filter_helper(kills, true);
  }
#ifdef ASSERT
  virtual bool interface_vs_oop(const Type *t) const;
#endif
  bool is_ptr_to_narrowoop() const;
  bool is_ptr_to_narrowklass() const;
  bool is_ptr_to_boxing_obj() const;
  float getf() const;
  double getd() const;
  const TypeInt    *is_int() const;
  const TypeInt    *isa_int() const;             // Returns NULL if not an Int
  const TypeLong   *is_long() const;
  const TypeLong   *isa_long() const;            // Returns NULL if not a Long
  const TypeD      *isa_double() const;          // Returns NULL if not a Double{Top,Con,Bot}
  const TypeD      *is_double_constant() const;  // Asserts it is a DoubleCon
  const TypeD      *isa_double_constant() const; // Returns NULL if not a DoubleCon
  const TypeF      *isa_float() const;           // Returns NULL if not a Float{Top,Con,Bot}
  const TypeF      *is_float_constant() const;   // Asserts it is a FloatCon
  const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
  const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
  const TypeAry    *is_ary() const;              // Array, NOT array pointer
  const TypeVect   *is_vect() const;             // Vector
  const TypeVect   *isa_vect() const;            // Returns NULL if not a Vector
  const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
  const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
  const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
  const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
  const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
  const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
  const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
  const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
  const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
  const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
  const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
  const TypeInstPtr  *is_instptr() const;        // Instance
  const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
  const TypeAryPtr   *is_aryptr() const;         // Array oop
  const TypeMetadataPtr   *isa_metadataptr() const;   // Returns NULL if not oop ptr type
  const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
  const TypeKlassPtr      *isa_klassptr() const;      // Returns NULL if not KlassPtr
  const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
  virtual bool      is_finite() const;           // Has a finite value
  virtual bool      is_nan()    const;           // Is not a number (NaN)
  const TypePtr* make_ptr() const;
  const TypeOopPtr* make_oopptr() const;
  const TypeNarrowOop* make_narrowoop() const;
  const TypeNarrowKlass* make_narrowklass() const;
  bool is_floatingpoint() const;        // True if Float or Double base type
  bool has_memory( ) const;
  virtual bool singleton(void) const;
  virtual bool empty(void) const;
  virtual int hash() const;
  static const Type *mreg2type[];
#ifndef PRODUCT
  void         dump_on(outputStream *st) const;
  void         dump() const {
    dump_on(tty);
  }
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
  static  void dump_stats();
  static const char* str(const Type* t);
#endif
  void typerr(const Type *t) const; // Mixing types error
  static const Type* get_const_basic_type(BasicType type) {
    assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
    return _const_basic_type[type];
  }
  static void get_arrays_base_elements(const Type *a1, const Type *a2,
                                       const TypeInstPtr **e1, const TypeInstPtr **e2);
  BasicType array_element_basic_type() const;
  static const Type* get_const_type(ciType* type);
  static const Type* get_zero_type(BasicType type) {
    assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
    return _zero_type[type];
  }
  bool is_zero_type() const {
    BasicType type = basic_type();
    if (type == T_VOID || type >= T_CONFLICT)
      return false;
    else
      return (this == _zero_type[type]);
  }
  static const Type *ABIO;
  static const Type *BOTTOM;
  static const Type *CONTROL;
  static const Type *DOUBLE;
  static const Type *FLOAT;
  static const Type *HALF;
  static const Type *MEMORY;
  static const Type *MULTI;
  static const Type *RETURN_ADDRESS;
  static const Type *TOP;
  BasicType basic_type() const       { return _type_info[_base].basic_type; }
  uint ideal_reg() const             { return _type_info[_base].ideal_reg; }
  const char* msg() const            { return _type_info[_base].msg; }
  bool isa_oop_ptr() const           { return _type_info[_base].isa_oop; }
  relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
  static const Type* get_typeflow_type(ciType* type);
  static const Type* make_from_constant(ciConstant constant,
                                        bool require_constant = false,
                                        bool is_autobox_cache = false);
  virtual const TypeOopPtr* speculative() const { return NULL; }
  virtual ciKlass* speculative_type() const { return NULL; }
  const Type* maybe_remove_speculative(bool include_speculative) const;
  virtual const Type* remove_speculative() const { return this; }
  virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const {
    return exact_kls != NULL;
  }
private:
  static const Type*        _zero_type[T_CONFLICT+1];
  static const Type* _const_basic_type[T_CONFLICT+1];
};
class TypeF : public Type {
  TypeF( float f ) : Type(FloatCon), _f(f) {};
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
public:
  const float _f;               // Float constant
  static const TypeF *make(float f);
  virtual bool        is_finite() const;  // Has a finite value
  virtual bool        is_nan()    const;  // Is not a number (NaN)
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  static const TypeF *ZERO; // positive zero only
  static const TypeF *ONE;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeD : public Type {
  TypeD( double d ) : Type(DoubleCon), _d(d) {};
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
public:
  const double _d;              // Double constant
  static const TypeD *make(double d);
  virtual bool        is_finite() const;  // Has a finite value
  virtual bool        is_nan()    const;  // Is not a number (NaN)
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  static const TypeD *ZERO; // positive zero only
  static const TypeD *ONE;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeInt : public Type {
  TypeInt( jint lo, jint hi, int w );
protected:
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
public:
  typedef jint NativeType;
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
  const jint _lo, _hi;          // Lower bound, upper bound
  const short _widen;           // Limit on times we widen this sucker
  static const TypeInt *make(jint lo);
  static const TypeInt *make(jint lo, jint hi, int w);
  int is_con() const { return _lo==_hi; }
  bool is_con(int i) const { return is_con() && _lo == i; }
  jint get_con() const { assert( is_con(), "" );  return _lo; }
  virtual bool        is_finite() const;  // Has a finite value
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  virtual const Type *widen( const Type *t, const Type* limit_type ) const;
  virtual const Type *narrow( const Type *t ) const;
  static const TypeInt *MINUS_1;
  static const TypeInt *ZERO;
  static const TypeInt *ONE;
  static const TypeInt *BOOL;
  static const TypeInt *CC;
  static const TypeInt *CC_LT;  // [-1]  == MINUS_1
  static const TypeInt *CC_GT;  // [1]   == ONE
  static const TypeInt *CC_EQ;  // [0]   == ZERO
  static const TypeInt *CC_LE;  // [-1,0]
  static const TypeInt *CC_GE;  // [0,1] == BOOL (!)
  static const TypeInt *BYTE;
  static const TypeInt *UBYTE;
  static const TypeInt *CHAR;
  static const TypeInt *SHORT;
  static const TypeInt *POS;
  static const TypeInt *POS1;
  static const TypeInt *INT;
  static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
  static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
  static const TypeInt *as_self(const Type *t) { return t->is_int(); }
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeLong : public Type {
  TypeLong( jlong lo, jlong hi, int w );
protected:
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
public:
  typedef jlong NativeType;
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
public:
  const jlong _lo, _hi;         // Lower bound, upper bound
  const short _widen;           // Limit on times we widen this sucker
  static const TypeLong *make(jlong lo);
  static const TypeLong *make(jlong lo, jlong hi, int w);
  int is_con() const { return _lo==_hi; }
  bool is_con(int i) const { return is_con() && _lo == i; }
  jlong get_con() const { assert( is_con(), "" ); return _lo; }
  int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
  virtual bool        is_finite() const;  // Has a finite value
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  virtual const Type *widen( const Type *t, const Type* limit_type ) const;
  virtual const Type *narrow( const Type *t ) const;
  static const TypeLong *MINUS_1;
  static const TypeLong *ZERO;
  static const TypeLong *ONE;
  static const TypeLong *POS;
  static const TypeLong *LONG;
  static const TypeLong *INT;    // 32-bit subrange [min_jint..max_jint]
  static const TypeLong *UINT;   // 32-bit unsigned [0..max_juint]
  static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
  static const TypeLong *as_self(const Type *t) { return t->is_long(); }
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint, outputStream *st  ) const;// Specialized per-Type dumping
#endif
};
class TypeTuple : public Type {
  TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
public:
  const uint          _cnt;              // Count of fields
  const Type ** const _fields;           // Array of field types
  uint cnt() const { return _cnt; }
  const Type* field_at(uint i) const {
    assert(i < _cnt, "oob");
    return _fields[i];
  }
  void set_field_at(uint i, const Type* t) {
    assert(i < _cnt, "oob");
    _fields[i] = t;
  }
  static const TypeTuple *make( uint cnt, const Type **fields );
  static const TypeTuple *make_range(ciSignature *sig);
  static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
  static const Type **fields( uint arg_cnt );
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  static const TypeTuple *IFBOTH;
  static const TypeTuple *IFFALSE;
  static const TypeTuple *IFTRUE;
  static const TypeTuple *IFNEITHER;
  static const TypeTuple *LOOPBODY;
  static const TypeTuple *MEMBAR;
  static const TypeTuple *STORECONDITIONAL;
  static const TypeTuple *START_I2C;
  static const TypeTuple *INT_PAIR;
  static const TypeTuple *LONG_PAIR;
  static const TypeTuple *INT_CC_PAIR;
  static const TypeTuple *LONG_CC_PAIR;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
#endif
};
class TypeAry : public Type {
  TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
      _elem(elem), _size(size), _stable(stable) {}
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
private:
  const Type *_elem;            // Element type of array
  const TypeInt *_size;         // Elements in array
  const bool _stable;           // Are elements @Stable?
  friend class TypeAryPtr;
public:
  static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  bool ary_must_be_exact() const;  // true if arrays of such are never generic
  virtual const Type* remove_speculative() const;
#ifdef ASSERT
  virtual bool interface_vs_oop(const Type *t) const;
#endif
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
#endif
};
class TypeVect : public Type {
  const Type*   _elem;  // Vector's element type
  const uint  _length;  // Elements in vector (power of 2)
protected:
  TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
    _elem(elem), _length(length) {}
public:
  const Type* element_type() const { return _elem; }
  BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
  uint length() const { return _length; }
  uint length_in_bytes() const {
   return _length * type2aelembytes(element_basic_type());
  }
  virtual bool eq(const Type *t) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
  static const TypeVect *make(const BasicType elem_bt, uint length) {
    return make(get_const_basic_type(elem_bt), length);
  }
  static const TypeVect *make(const Type* elem, uint length);
  virtual const Type *xmeet( const Type *t) const;
  virtual const Type *xdual() const;     // Compute dual right now.
  static const TypeVect *VECTS;
  static const TypeVect *VECTD;
  static const TypeVect *VECTX;
  static const TypeVect *VECTY;
#ifndef PRODUCT
  virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
#endif
};
class TypeVectS : public TypeVect {
  friend class TypeVect;
  TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
};
class TypeVectD : public TypeVect {
  friend class TypeVect;
  TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
};
class TypeVectX : public TypeVect {
  friend class TypeVect;
  TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
};
class TypeVectY : public TypeVect {
  friend class TypeVect;
  TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
};
class TypePtr : public Type {
  friend class TypeNarrowPtr;
public:
  enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
protected:
  TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  static const PTR ptr_meet[lastPTR][lastPTR];
  static const PTR ptr_dual[lastPTR];
  static const char * const ptr_msg[lastPTR];
public:
  const int _offset;            // Offset into oop, with TOP & BOT
  const PTR _ptr;               // Pointer equivalence class
  const int offset() const { return _offset; }
  const PTR ptr()    const { return _ptr; }
  static const TypePtr *make( TYPES t, PTR ptr, int offset );
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual intptr_t get_con() const;
  int xadd_offset( intptr_t offset ) const;
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
  virtual const Type *xmeet( const Type *t ) const;
  int meet_offset( int offset ) const;
  int dual_offset( ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
  PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
  PTR join_ptr( const PTR in_ptr ) const {
    return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
  }
  static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
  static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
  static const TypePtr *NULL_PTR;
  static const TypePtr *NOTNULL;
  static const TypePtr *BOTTOM;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
#endif
};
class TypeRawPtr : public TypePtr {
protected:
  TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;     // Type specific hashing
  const address _bits;          // Constant value, if applicable
  static const TypeRawPtr *make( PTR ptr );
  static const TypeRawPtr *make( address bits );
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual intptr_t get_con() const;
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  static const TypeRawPtr *BOTTOM;
  static const TypeRawPtr *NOTNULL;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
#endif
};
class TypeOopPtr : public TypePtr {
protected:
  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  enum {
   InstanceTop = -1,   // undefined instance
   InstanceBot = 0     // any possible instance
  };
protected:
  enum {
    InlineDepthBottom = INT_MAX,
    InlineDepthTop = -InlineDepthBottom
  };
  ciObject*     _const_oop;   // Constant oop
  ciKlass*      _klass;       // Klass object
  bool          _klass_is_exact;
  bool          _is_ptr_to_narrowoop;
  bool          _is_ptr_to_narrowklass;
  bool          _is_ptr_to_boxed_value;
  int           _instance_id;
  const TypeOopPtr*   _speculative;
  int _inline_depth;
  static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
  int dual_instance_id() const;
  int meet_instance_id(int uid) const;
  const TypeOopPtr* dual_speculative() const;
  const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
  bool eq_speculative(const TypeOopPtr* other) const;
  int hash_speculative() const;
  const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
#ifndef PRODUCT
  void dump_speculative(outputStream *st) const;
#endif
  int dual_inline_depth() const;
  int meet_inline_depth(int depth) const;
#ifndef PRODUCT
  void dump_inline_depth(outputStream *st) const;
#endif
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
public:
  static const TypeOopPtr* make_from_klass(ciKlass* klass) {
    return make_from_klass_common(klass, true, false);
  }
  static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
    return make_from_klass_common(klass, true, true);
  }
  static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
    return make_from_klass_common(klass, false, false);
  }
  static const TypeOopPtr* make_from_constant(ciObject* o,
                                              bool require_constant = false,
                                              bool not_null_elements = false);
  static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
  ciObject* const_oop()    const { return _const_oop; }
  virtual ciKlass* klass() const { return _klass;     }
  bool klass_is_exact()    const { return _klass_is_exact; }
  bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
  bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
  bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
  bool is_known_instance()       const { return _instance_id > 0; }
  int  instance_id()             const { return _instance_id; }
  bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
  virtual const TypeOopPtr* speculative() const { return _speculative; }
  virtual intptr_t get_con() const;
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual const Type *cast_to_exactness(bool klass_is_exact) const;
  virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
  const TypeKlassPtr* as_klass_type() const;
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual const Type* remove_speculative() const;
  virtual const Type *xmeet(const Type *t) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  virtual const Type *xmeet_helper(const Type *t) const;
  static const TypeOopPtr *BOTTOM;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
  ciKlass* speculative_type() const {
    if (_speculative != NULL) {
      const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
      if (speculative->klass_is_exact()) {
        return speculative->klass();
      }
    }
    return NULL;
  }
  int inline_depth() const {
    return _inline_depth;
  }
  virtual const TypeOopPtr* with_inline_depth(int depth) const;
  virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
};
class TypeInstPtr : public TypeOopPtr {
  TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  ciSymbol*  _name;        // class name
 public:
  ciSymbol* name()         const { return _name; }
  bool  is_loaded() const { return _klass->is_loaded(); }
  static const TypeInstPtr *make(ciObject* o) {
    return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
  }
  static const TypeInstPtr *make(ciObject* o, int offset) {
    return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
  }
  static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
    return make(ptr, klass, false, NULL, 0, InstanceBot);
  }
  static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
    return make(ptr, klass, true, NULL, 0, InstanceBot);
  }
  static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
    return make(ptr, klass, false, NULL, offset, InstanceBot);
  }
  static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
  const Type* get_const_boxed_value() const;
  ciType* java_mirror_type() const;
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual const Type *cast_to_exactness(bool klass_is_exact) const;
  virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual const Type* remove_speculative() const;
  virtual const TypeOopPtr* with_inline_depth(int depth) const;
  virtual const Type *xmeet_helper(const Type *t) const;
  virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  static const TypeInstPtr *NOTNULL;
  static const TypeInstPtr *BOTTOM;
  static const TypeInstPtr *MIRROR;
  static const TypeInstPtr *MARK;
  static const TypeInstPtr *KLASS;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
#endif
};
class TypeAryPtr : public TypeOopPtr {
  TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
              int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative, int inline_depth)
    : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
    _ary(ary),
    _is_autobox_cache(is_autobox_cache)
 {
#ifdef ASSERT
    if (k != NULL) {
      ciKlass* ck = compute_klass(true);
      if (k != ck) {
        this->dump(); tty->cr();
        tty->print(" k: ");
        k->print(); tty->cr();
        tty->print("ck: ");
        if (ck != NULL) ck->print();
        else tty->print("<NULL>");
        tty->cr();
        assert(false, "unexpected TypeAryPtr::_klass");
      }
    }
#endif
  }
  virtual bool eq( const Type *t ) const;
  virtual int hash() const;     // Type specific hashing
  const TypeAry *_ary;          // Array we point into
  const bool     _is_autobox_cache;
  ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
public:
  ciKlass* klass() const;
  const TypeAry* ary() const  { return _ary; }
  const Type*    elem() const { return _ary->_elem; }
  const TypeInt* size() const { return _ary->_size; }
  bool      is_stable() const { return _ary->_stable; }
  bool is_autobox_cache() const { return _is_autobox_cache; }
  static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
  static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom, bool is_autobox_cache= false);
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual const Type *cast_to_exactness(bool klass_is_exact) const;
  virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
  virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
  virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
  virtual bool empty(void) const;        // TRUE if type is vacuous
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual const Type* remove_speculative() const;
  virtual const TypeOopPtr* with_inline_depth(int depth) const;
  virtual const Type *xmeet_helper(const Type *t) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
  int stable_dimension() const;
  static jint max_array_length(BasicType etype) ;
  static const TypeAryPtr *RANGE;
  static const TypeAryPtr *OOPS;
  static const TypeAryPtr *NARROWOOPS;
  static const TypeAryPtr *BYTES;
  static const TypeAryPtr *SHORTS;
  static const TypeAryPtr *CHARS;
  static const TypeAryPtr *INTS;
  static const TypeAryPtr *LONGS;
  static const TypeAryPtr *FLOATS;
  static const TypeAryPtr *DOUBLES;
  static const TypeAryPtr *get_array_body_type(BasicType elem) {
    assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
    return _array_body_type[elem];
  }
  static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
#ifdef ASSERT
  virtual bool interface_vs_oop(const Type *t) const;
#endif
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
#endif
};
class TypeMetadataPtr : public TypePtr {
protected:
  TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
private:
  ciMetadata*   _metadata;
public:
  static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
  static const TypeMetadataPtr* make(ciMethod* m);
  static const TypeMetadataPtr* make(ciMethodData* m);
  ciMetadata* metadata() const { return _metadata; }
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  virtual intptr_t get_con() const;
  static const TypeMetadataPtr *BOTTOM;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeKlassPtr : public TypePtr {
  TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
protected:
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 public:
  virtual bool eq( const Type *t ) const;
  virtual int hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
 private:
  static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
  ciKlass* _klass;
  bool          _klass_is_exact;
public:
  ciSymbol* name()  const { return klass()->name(); }
  ciKlass* klass() const { return  _klass; }
  bool klass_is_exact()    const { return _klass_is_exact; }
  bool  is_loaded() const { return klass()->is_loaded(); }
  static const TypeKlassPtr* make_from_klass(ciKlass* klass) {
    return make_from_klass_common(klass, true, false);
  }
  static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) {
    return make_from_klass_common(klass, true, true);
  }
  static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) {
    return make_from_klass_common(klass, false, false);
  }
  static const TypeKlassPtr* make(PTR ptr, int offset);
  static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
  static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
  static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
  virtual const Type *cast_to_ptr_type(PTR ptr) const;
  virtual const Type *cast_to_exactness(bool klass_is_exact) const;
  const TypeOopPtr* as_instance_type() const;
  virtual const TypePtr *add_offset( intptr_t offset ) const;
  virtual const Type    *xmeet( const Type *t ) const;
  virtual const Type    *xdual() const;      // Compute dual right now.
  virtual intptr_t get_con() const;
  static const TypeKlassPtr* OBJECT; // Not-null object klass or below
  static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
#endif
};
class TypeNarrowPtr : public Type {
protected:
  const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
  TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): _ptrtype(ptrtype),
                                                  Type(t) {
    assert(ptrtype->offset() == 0 ||
           ptrtype->offset() == OffsetBot ||
           ptrtype->offset() == OffsetTop, "no real offsets");
  }
  virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
  virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
  virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
  virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
public:
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  virtual intptr_t get_con() const;
  virtual bool empty(void) const;        // TRUE if type is vacuous
  const TypePtr *get_ptrtype() const {
    return _ptrtype;
  }
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeNarrowOop : public TypeNarrowPtr {
protected:
  TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
  }
  virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
    return t->isa_narrowoop();
  }
  virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
    return t->is_narrowoop();
  }
  virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
    return new TypeNarrowOop(t);
  }
  virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
    return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
  }
public:
  static const TypeNarrowOop *make( const TypePtr* type);
  static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
    return make(TypeOopPtr::make_from_constant(con, require_constant));
  }
  static const TypeNarrowOop *BOTTOM;
  static const TypeNarrowOop *NULL_PTR;
  virtual const Type* remove_speculative() const {
    return make(_ptrtype->remove_speculative()->is_ptr());
  }
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeNarrowKlass : public TypeNarrowPtr {
protected:
  TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
  }
  virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
    return t->isa_narrowklass();
  }
  virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
    return t->is_narrowklass();
  }
  virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
    return new TypeNarrowKlass(t);
  }
  virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
    return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
  }
public:
  static const TypeNarrowKlass *make( const TypePtr* type);
  static const TypeNarrowKlass *NULL_PTR;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
#endif
};
class TypeFunc : public Type {
  TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}
  virtual bool eq( const Type *t ) const;
  virtual int  hash() const;             // Type specific hashing
  virtual bool singleton(void) const;    // TRUE if type is a singleton
  virtual bool empty(void) const;        // TRUE if type is vacuous
public:
  enum { Control    = AdlcVMDeps::Control,
         I_O        = AdlcVMDeps::I_O,
         Memory     = AdlcVMDeps::Memory,
         FramePtr   = AdlcVMDeps::FramePtr,
         ReturnAdr  = AdlcVMDeps::ReturnAdr,
         Parms      = AdlcVMDeps::Parms
  };
  const TypeTuple* const _domain;     // Domain of inputs
  const TypeTuple* const _range;      // Range of results
  const TypeTuple* domain() const { return _domain; }
  const TypeTuple* range()  const { return _range; }
  static const TypeFunc *make(ciMethod* method);
  static const TypeFunc *make(ciSignature signature, const Type* extra);
  static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
  virtual const Type *xmeet( const Type *t ) const;
  virtual const Type *xdual() const;    // Compute dual right now.
  BasicType return_type() const;
#ifndef PRODUCT
  virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
#endif
};
inline bool Type::is_ptr_to_narrowoop() const {
#ifdef _LP64
  return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
#else
  return false;
#endif
}
inline bool Type::is_ptr_to_narrowklass() const {
#ifdef _LP64
  return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
#else
  return false;
#endif
}
inline float Type::getf() const {
  assert( _base == FloatCon, "Not a FloatCon" );
  return ((TypeF*)this)->_f;
}
inline double Type::getd() const {
  assert( _base == DoubleCon, "Not a DoubleCon" );
  return ((TypeD*)this)->_d;
}
inline const TypeInt *Type::is_int() const {
  assert( _base == Int, "Not an Int" );
  return (TypeInt*)this;
}
inline const TypeInt *Type::isa_int() const {
  return ( _base == Int ? (TypeInt*)this : NULL);
}
inline const TypeLong *Type::is_long() const {
  assert( _base == Long, "Not a Long" );
  return (TypeLong*)this;
}
inline const TypeLong *Type::isa_long() const {
  return ( _base == Long ? (TypeLong*)this : NULL);
}
inline const TypeF *Type::isa_float() const {
  return ((_base == FloatTop ||
           _base == FloatCon ||
           _base == FloatBot) ? (TypeF*)this : NULL);
}
inline const TypeF *Type::is_float_constant() const {
  assert( _base == FloatCon, "Not a Float" );
  return (TypeF*)this;
}
inline const TypeF *Type::isa_float_constant() const {
  return ( _base == FloatCon ? (TypeF*)this : NULL);
}
inline const TypeD *Type::isa_double() const {
  return ((_base == DoubleTop ||
           _base == DoubleCon ||
           _base == DoubleBot) ? (TypeD*)this : NULL);
}
inline const TypeD *Type::is_double_constant() const {
  assert( _base == DoubleCon, "Not a Double" );
  return (TypeD*)this;
}
inline const TypeD *Type::isa_double_constant() const {
  return ( _base == DoubleCon ? (TypeD*)this : NULL);
}
inline const TypeTuple *Type::is_tuple() const {
  assert( _base == Tuple, "Not a Tuple" );
  return (TypeTuple*)this;
}
inline const TypeAry *Type::is_ary() const {
  assert( _base == Array , "Not an Array" );
  return (TypeAry*)this;
}
inline const TypeVect *Type::is_vect() const {
  assert( _base >= VectorS && _base <= VectorY, "Not a Vector" );
  return (TypeVect*)this;
}
inline const TypeVect *Type::isa_vect() const {
  return (_base >= VectorS && _base <= VectorY) ? (TypeVect*)this : NULL;
}
inline const TypePtr *Type::is_ptr() const {
  assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
  return (TypePtr*)this;
}
inline const TypePtr *Type::isa_ptr() const {
  return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
}
inline const TypeOopPtr *Type::is_oopptr() const {
  assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
  return (TypeOopPtr*)this;
}
inline const TypeOopPtr *Type::isa_oopptr() const {
  return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
}
inline const TypeRawPtr *Type::isa_rawptr() const {
  return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
}
inline const TypeRawPtr *Type::is_rawptr() const {
  assert( _base == RawPtr, "Not a raw pointer" );
  return (TypeRawPtr*)this;
}
inline const TypeInstPtr *Type::isa_instptr() const {
  return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
}
inline const TypeInstPtr *Type::is_instptr() const {
  assert( _base == InstPtr, "Not an object pointer" );
  return (TypeInstPtr*)this;
}
inline const TypeAryPtr *Type::isa_aryptr() const {
  return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
}
inline const TypeAryPtr *Type::is_aryptr() const {
  assert( _base == AryPtr, "Not an array pointer" );
  return (TypeAryPtr*)this;
}
inline const TypeNarrowOop *Type::is_narrowoop() const {
  assert(_base == NarrowOop, "Not a narrow oop" ) ;
  return (TypeNarrowOop*)this;
}
inline const TypeNarrowOop *Type::isa_narrowoop() const {
  return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
}
inline const TypeNarrowKlass *Type::is_narrowklass() const {
  assert(_base == NarrowKlass, "Not a narrow oop" ) ;
  return (TypeNarrowKlass*)this;
}
inline const TypeNarrowKlass *Type::isa_narrowklass() const {
  return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
}
inline const TypeMetadataPtr *Type::is_metadataptr() const {
  assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
  return (TypeMetadataPtr*)this;
}
inline const TypeMetadataPtr *Type::isa_metadataptr() const {
  return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
}
inline const TypeKlassPtr *Type::isa_klassptr() const {
  return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
}
inline const TypeKlassPtr *Type::is_klassptr() const {
  assert( _base == KlassPtr, "Not a klass pointer" );
  return (TypeKlassPtr*)this;
}
inline const TypePtr* Type::make_ptr() const {
  return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
    ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
     (isa_ptr() ? is_ptr() : NULL));
}
inline const TypeOopPtr* Type::make_oopptr() const {
  return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
}
inline const TypeNarrowOop* Type::make_narrowoop() const {
  return (_base == NarrowOop) ? is_narrowoop() :
                                (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
}
inline const TypeNarrowKlass* Type::make_narrowklass() const {
  return (_base == NarrowKlass) ? is_narrowklass() :
                                (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
}
inline bool Type::is_floatingpoint() const {
  if( (_base == FloatCon)  || (_base == FloatBot) ||
      (_base == DoubleCon) || (_base == DoubleBot) )
    return true;
  return false;
}
inline bool Type::is_ptr_to_boxing_obj() const {
  const TypeInstPtr* tp = isa_instptr();
  return (tp != NULL) && (tp->offset() == 0) &&
         tp->klass()->is_instance_klass()  &&
         tp->klass()->as_instance_klass()->is_box_klass();
}
#ifdef _LP64
#define is_intptr_t  is_long
#define isa_intptr_t isa_long
#define find_intptr_t_type find_long_type
#define find_intptr_t_con  find_long_con
#define TypeX        TypeLong
#define Type_X       Type::Long
#define TypeX_X      TypeLong::LONG
#define TypeX_ZERO   TypeLong::ZERO
#define Op_RegX      Op_RegL
#define MakeConX     longcon
#define ConXNode     ConLNode
#define MulXNode     MulLNode
#define AndXNode     AndLNode
#define OrXNode      OrLNode
#define CmpXNode     CmpLNode
#define SubXNode     SubLNode
#define LShiftXNode  LShiftLNode
#define AddXNode     AddLNode
#define RShiftXNode  RShiftLNode
#define URShiftXNode URShiftLNode
#define XorXNode     XorLNode
#define StoreXConditionalNode StoreLConditionalNode
#define Op_LShiftX   Op_LShiftL
#define Op_AndX      Op_AndL
#define Op_AddX      Op_AddL
#define Op_SubX      Op_SubL
#define Op_XorX      Op_XorL
#define Op_URShiftX  Op_URShiftL
#define ConvI2X(x)   ConvI2L(x)
#define ConvL2X(x)   (x)
#define ConvX2I(x)   ConvL2I(x)
#define ConvX2L(x)   (x)
#define ConvX2UL(x)  (x)
#else
#define is_intptr_t  is_int
#define isa_intptr_t isa_int
#define find_intptr_t_type find_int_type
#define find_intptr_t_con  find_int_con
#define TypeX        TypeInt
#define Type_X       Type::Int
#define TypeX_X      TypeInt::INT
#define TypeX_ZERO   TypeInt::ZERO
#define Op_RegX      Op_RegI
#define MakeConX     intcon
#define ConXNode     ConINode
#define MulXNode     MulINode
#define AndXNode     AndINode
#define OrXNode      OrINode
#define CmpXNode     CmpINode
#define SubXNode     SubINode
#define LShiftXNode  LShiftINode
#define AddXNode     AddINode
#define RShiftXNode  RShiftINode
#define URShiftXNode URShiftINode
#define XorXNode     XorINode
#define StoreXConditionalNode StoreIConditionalNode
#define Op_LShiftX   Op_LShiftI
#define Op_AndX      Op_AndI
#define Op_AddX      Op_AddI
#define Op_SubX      Op_SubI
#define Op_XorX      Op_XorI
#define Op_URShiftX  Op_URShiftI
#define ConvI2X(x)   (x)
#define ConvL2X(x)   ConvL2I(x)
#define ConvX2I(x)   (x)
#define ConvX2L(x)   ConvI2L(x)
#define ConvX2UL(x)  ConvI2UL(x)
#endif
#endif // SHARE_VM_OPTO_TYPE_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/vectornode.cpp
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "opto/connode.hpp"
#include "opto/vectornode.hpp"
int VectorNode::opcode(int sopc, BasicType bt) {
  switch (sopc) {
  case Op_AddI:
    switch (bt) {
    case T_BOOLEAN:
    case T_BYTE:      return Op_AddVB;
    case T_CHAR:
    case T_SHORT:     return Op_AddVS;
    case T_INT:       return Op_AddVI;
    }
    ShouldNotReachHere();
  case Op_AddL:
    assert(bt == T_LONG, "must be");
    return Op_AddVL;
  case Op_AddF:
    assert(bt == T_FLOAT, "must be");
    return Op_AddVF;
  case Op_AddD:
    assert(bt == T_DOUBLE, "must be");
    return Op_AddVD;
  case Op_SubI:
    switch (bt) {
    case T_BOOLEAN:
    case T_BYTE:   return Op_SubVB;
    case T_CHAR:
    case T_SHORT:  return Op_SubVS;
    case T_INT:    return Op_SubVI;
    }
    ShouldNotReachHere();
  case Op_SubL:
    assert(bt == T_LONG, "must be");
    return Op_SubVL;
  case Op_SubF:
    assert(bt == T_FLOAT, "must be");
    return Op_SubVF;
  case Op_SubD:
    assert(bt == T_DOUBLE, "must be");
    return Op_SubVD;
  case Op_MulI:
    switch (bt) {
    case T_BOOLEAN:
    case T_BYTE:   return 0;   // Unimplemented
    case T_CHAR:
    case T_SHORT:  return Op_MulVS;
    case T_INT:    return Op_MulVI;
    }
    ShouldNotReachHere();
  case Op_MulF:
    assert(bt == T_FLOAT, "must be");
    return Op_MulVF;
  case Op_MulD:
    assert(bt == T_DOUBLE, "must be");
    return Op_MulVD;
  case Op_DivF:
    assert(bt == T_FLOAT, "must be");
    return Op_DivVF;
  case Op_DivD:
    assert(bt == T_DOUBLE, "must be");
    return Op_DivVD;
  case Op_LShiftI:
    switch (bt) {
    case T_BOOLEAN:
    case T_BYTE:   return Op_LShiftVB;
    case T_CHAR:
    case T_SHORT:  return Op_LShiftVS;
    case T_INT:    return Op_LShiftVI;
    }
    ShouldNotReachHere();
  case Op_LShiftL:
    assert(bt == T_LONG, "must be");
    return Op_LShiftVL;
  case Op_RShiftI:
    switch (bt) {
    case T_BOOLEAN:return Op_URShiftVB; // boolean is unsigned value
    case T_CHAR:   return Op_URShiftVS; // char is unsigned value
    case T_BYTE:   return Op_RShiftVB;
    case T_SHORT:  return Op_RShiftVS;
    case T_INT:    return Op_RShiftVI;
    }
    ShouldNotReachHere();
  case Op_RShiftL:
    assert(bt == T_LONG, "must be");
    return Op_RShiftVL;
  case Op_URShiftI:
    switch (bt) {
    case T_BOOLEAN:return Op_URShiftVB;
    case T_CHAR:   return Op_URShiftVS;
    case T_BYTE:
    case T_SHORT:  return 0; // Vector logical right shift for signed short
    case T_INT:    return Op_URShiftVI;
    }
    ShouldNotReachHere();
  case Op_URShiftL:
    assert(bt == T_LONG, "must be");
    return Op_URShiftVL;
  case Op_AndI:
  case Op_AndL:
    return Op_AndV;
  case Op_OrI:
  case Op_OrL:
    return Op_OrV;
  case Op_XorI:
  case Op_XorL:
    return Op_XorV;
  case Op_LoadB:
  case Op_LoadUB:
  case Op_LoadUS:
  case Op_LoadS:
  case Op_LoadI:
  case Op_LoadL:
  case Op_LoadF:
  case Op_LoadD:
    return Op_LoadVector;
  case Op_StoreB:
  case Op_StoreC:
  case Op_StoreI:
  case Op_StoreL:
  case Op_StoreF:
  case Op_StoreD:
    return Op_StoreVector;
  }
  return 0; // Unimplemented
}
bool VectorNode::implemented(int opc, uint vlen, BasicType bt) {
  if (is_java_primitive(bt) &&
      (vlen > 1) && is_power_of_2(vlen) &&
      Matcher::vector_size_supported(bt, vlen)) {
    int vopc = VectorNode::opcode(opc, bt);
    return vopc > 0 && Matcher::match_rule_supported(vopc);
  }
  return false;
}
bool VectorNode::is_shift(Node* n) {
  switch (n->Opcode()) {
  case Op_LShiftI:
  case Op_LShiftL:
  case Op_RShiftI:
  case Op_RShiftL:
  case Op_URShiftI:
  case Op_URShiftL:
    return true;
  }
  return false;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值