hotspot/src/share/vm/opto/multnode.cpp
author kvn
Thu, 29 May 2008 12:04:14 -0700
changeset 594 9f4474e5dbaf
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops Summary: Generate addresses and implicit null checks with narrow oops to avoid decoding. Reviewed-by: jrose, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_multnode.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
//------------------------------MultiNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
const RegMask &MultiNode::out_RegMask() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  return RegMask::Empty;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//------------------------------proj_out---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Get a named projection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
ProjNode* MultiNode::proj_out(uint which_proj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    Node *p = fast_out(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    if( !p->is_Proj() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
      assert(p == this && this->is_Start(), "else must be proj");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
      continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    ProjNode *proj = p->as_Proj();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    if( proj->_con == which_proj ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
      assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
      return proj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//------------------------------ProjNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
uint ProjNode::hash() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // only one input
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
uint ProjNode::size_of() const { return sizeof(ProjNode); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// Test if we propagate interesting control along this projection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
bool ProjNode::is_CFG() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  Node *def = in(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  return (_con == TypeFunc::Control && def->is_CFG());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
const Type *ProjNode::bottom_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  if (in(0) == NULL)  return Type::TOP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  const Type *tb = in(0)->bottom_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  if( tb == Type::TOP ) return Type::TOP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  if( tb == Type::BOTTOM ) return Type::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  const TypeTuple *t = tb->is_tuple();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  return t->field_at(_con);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
const TypePtr *ProjNode::adr_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  if (bottom_type() == Type::MEMORY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    const TypePtr* adr_type = in(0)->adr_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    if (!is_error_reported() && !Node::in_dump())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      assert(adr_type != NULL, "source must have adr_type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    return adr_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  assert(bottom_type()->base() != Type::Memory, "no other memories?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
bool ProjNode::pinned() const { return in(0)->pinned(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
//----------------------------check_con----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
void ProjNode::check_con() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  Node* n = in(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  if (n == NULL)       return;  // should be assert, but NodeHash makes bogons
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  if (n->is_Mach())    return;  // mach. projs. are not type-safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  if (n->is_Start())   return;  // alas, starts can have mach. projs. also
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  if (_con == SCMemProjNode::SCMEMPROJCON ) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  const Type* t = n->bottom_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  if (t == Type::TOP)  return;  // multi is dead
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
//------------------------------Value------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
const Type *ProjNode::Value( PhaseTransform *phase ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  if( !in(0) ) return Type::TOP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  const Type *t = phase->type(in(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  if( t == Type::TOP ) return t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  if( t == Type::BOTTOM ) return t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  return t->is_tuple()->field_at(_con);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
//------------------------------out_RegMask------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// Pass the buck uphill
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
const RegMask &ProjNode::out_RegMask() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  return RegMask::Empty;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
//------------------------------ideal_reg--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
uint ProjNode::ideal_reg() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  return Matcher::base2reg[bottom_type()->base()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}