hotspot/src/share/vm/opto/cfgnode.hpp
author kvn
Thu, 13 Mar 2008 16:31:32 -0700
changeset 237 fba97e902303
parent 190 e9a0a9dcd4f6
child 247 2aeab9ac7fea
permissions -rw-r--r--
6673473: (Escape Analysis) Add the instance's field information to PhiNode Summary: Avoid an infinite generation of instance's field values Phi nodes. Reviewed-by: 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
// Portions of code courtesy of Clifford Click
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// Optimization - Graph Style
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class Matcher;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class Node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class   RegionNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class   TypeNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class     PhiNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class   GotoNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class   MultiNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class     MultiBranchNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class       IfNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class       PCTableNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class         JumpNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class         CatchNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class       NeverBranchNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class   ProjNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class     CProjNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class       IfTrueNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class       IfFalseNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class       CatchProjNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class     JProjNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class       JumpProjNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class     SCMemProjNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class PhaseIdealLoop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//------------------------------RegionNode-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// The class of RegionNodes, which can be mapped to basic blocks in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// program.  Their inputs point to Control sources.  PhiNodes (described
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// below) have an input point to a RegionNode.  Merged data inputs to PhiNodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// correspond 1-to-1 with RegionNode inputs.  The zero input of a PhiNode is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// the RegionNode, and the zero input of the RegionNode is itself.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class RegionNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Node layout (parallels PhiNode):
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  enum { Region,                // Generally points to self.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
         Control                // Control arcs are [1..len)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  RegionNode( uint required ) : Node(required) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    init_class_id(Class_Region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    init_req(0,this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  Node* is_copy() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    const Node* r = _in[Region];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    if (r == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
      return nonnull_req();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    return NULL;  // not a copy!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  PhiNode* has_phi() const;        // returns an arbitrary phi user, or NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  PhiNode* has_unique_phi() const; // returns the unique phi user, or NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // Is this region node unreachable from root?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  bool is_unreachable_region(PhaseGVN *phase) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  virtual bool pinned() const { return (const Node *)in(0) == this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  virtual bool  is_CFG   () const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  virtual bool depends_only_on_test() const { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  virtual const Type *bottom_type() const { return Type::CONTROL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  virtual const Type *Value( PhaseTransform *phase ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  virtual const RegMask &out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
//------------------------------JProjNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// jump projection for node that produces multiple control-flow paths
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
class JProjNode : public ProjNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  JProjNode( Node* ctrl, uint idx ) : ProjNode(ctrl,idx) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  virtual bool  is_CFG() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  virtual uint  hash() const { return NO_HASH; }  // CFG nodes do not hash
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  virtual const Node* is_block_proj() const { return in(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  virtual const RegMask& out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  virtual uint  ideal_reg() const { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//------------------------------PhiNode----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// PhiNodes merge values from different Control paths.  Slot 0 points to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// controlling RegionNode.  Other slots map 1-for-1 with incoming control flow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// paths to the RegionNode.  For speed reasons (to avoid another pass) we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
// can turn PhiNodes into copys in-place by NULL'ing out their RegionNode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// input in slot 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
class PhiNode : public TypeNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes.
237
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   113
  const int _inst_id;     // Instance id of the memory slice.
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   114
  const int _inst_index;  // Alias index of the instance memory slice.
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   115
  // Array elements references have the same alias_idx but different offset.
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   116
  const int _inst_offset; // Offset of the instance memory slice.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // Size is bigger to hold the _adr_type field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  virtual uint hash() const;    // Check the type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  virtual uint cmp( const Node &n ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  virtual uint size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // Determine if CMoveNode::is_cmove_id can be used at this join point.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  Node* is_cmove_id(PhaseTransform* phase, int true_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // Node layout (parallels RegionNode):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  enum { Region,                // Control input is the Phi's region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
         Input                  // Input values are [1..len)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
237
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   131
  PhiNode( Node *r, const Type *t, const TypePtr* at = NULL,
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   132
           const int iid = TypeOopPtr::UNKNOWN_INSTANCE,
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   133
           const int iidx = Compile::AliasIdxTop,
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   134
           const int ioffs = Type::OffsetTop )
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   135
    : TypeNode(t,r->req()),
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   136
      _adr_type(at),
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   137
      _inst_id(iid),
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   138
      _inst_index(iidx),
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   139
      _inst_offset(ioffs)
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   140
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    init_class_id(Class_Phi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    init_req(0, r);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    verify_adr_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // create a new phi with in edges matching r and set (initially) to x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  static PhiNode* make( Node* r, Node* x );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // extra type arguments override the new phi's bottom_type and adr_type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  static PhiNode* make( Node* r, Node* x, const Type *t, const TypePtr* at = NULL );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // create a new phi with narrowed memory type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  PhiNode* slice_memory(const TypePtr* adr_type) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // like make(r, x), but does not initialize the in edges to x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  static PhiNode* make_blank( Node* r, Node* x );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  RegionNode* region() const { Node* r = in(Region); assert(!r || r->is_Region(), ""); return (RegionNode*)r; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  Node* is_copy() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    // The node is a real phi if _in[0] is a Region node.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    DEBUG_ONLY(const Node* r = _in[Region];)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    assert(r != NULL && r->is_Region(), "Not valid control");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    return NULL;  // not a copy!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
237
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   164
  // Determine a unique non-trivial input, if any.
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   165
  // Ignore casts if it helps.  Return NULL on failure.
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   166
  Node* unique_input(PhaseTransform *phase);
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   167
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Check for a simple dead loop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  LoopSafety simple_data_loop_check(Node *in) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Is it unsafe data loop? It becomes a dead loop if this phi node removed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  bool is_unsafe_data_reference(Node *in) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  int  is_diamond_phi() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual bool pinned() const { return in(0) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
237
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   177
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   178
  const int inst_id()     const { return _inst_id; }
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   179
  const int inst_index()  const { return _inst_index; }
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   180
  const int inst_offset() const { return _inst_offset; }
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   181
  bool is_same_inst_field(const Type* tp, int id, int index, int offset) {
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   182
    return type()->basic_type() == tp->basic_type() &&
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   183
           inst_id()     == id     &&
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   184
           inst_index()  == index  &&
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   185
           inst_offset() == offset &&
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   186
           type()->higher_equal(tp);
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   187
  }
fba97e902303 6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents: 190
diff changeset
   188
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  virtual const Type *Value( PhaseTransform *phase ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  virtual const RegMask &out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  virtual const RegMask &in_RegMask(uint) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  virtual void dump_spec(outputStream *st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  void verify_adr_type(VectorSet& visited, const TypePtr* at) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  void verify_adr_type(bool recursive = false) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
#else //ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  void verify_adr_type(bool recursive = false) const {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
#endif //ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
//------------------------------GotoNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
// GotoNodes perform direct branches.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
class GotoNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  GotoNode( Node *control ) : Node(control) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    init_flags(Flag_is_Goto);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  virtual bool pinned() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  virtual bool  is_CFG() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  virtual const Node *is_block_proj() const { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  virtual bool depends_only_on_test() const { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  virtual const Type *bottom_type() const { return Type::CONTROL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  virtual const Type *Value( PhaseTransform *phase ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  virtual const RegMask &out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
//------------------------------CProjNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
// control projection for node that produces multiple control-flow paths
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
class CProjNode : public ProjNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  CProjNode( Node *ctrl, uint idx ) : ProjNode(ctrl,idx) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  virtual bool  is_CFG() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  virtual const Node *is_block_proj() const { return in(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  virtual const RegMask &out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  virtual uint ideal_reg() const { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
//---------------------------MultiBranchNode-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
// This class defines a MultiBranchNode, a MultiNode which yields multiple
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
// control values. These are distinguished from other types of MultiNodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
// which yield multiple values, but control is always and only projection #0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
class MultiBranchNode : public MultiNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  MultiBranchNode( uint required ) : MultiNode(required) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    init_class_id(Class_MultiBranch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
//------------------------------IfNode-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
// Output selected Control, based on a boolean test
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
class IfNode : public MultiBranchNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // Size is bigger to hold the probability field.  However, _prob does not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  // change the semantics so it does not appear in the hash & cmp functions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  virtual uint size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // Degrees of branch prediction probability by order of magnitude:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
#define PROB_UNLIKELY_MAG(N)    (1e- ## N ## f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#define PROB_LIKELY_MAG(N)      (1.0f-PROB_UNLIKELY_MAG(N))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  // Maximum and minimum branch prediction probabilties
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // 1 in 1,000,000 (magnitude 6)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // they are used to distinguish different situations:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // very likely (unlikely) but with a concrete possibility of a rare
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  // contrary case.  These constants would be used for pinning
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  // measurements, and as measures for assertions that have high
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  // confidence, but some evidence of occasional failure.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // The name PROB_ALWAYS (PROB_NEVER) is to stand for situations for which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // there is no evidence at all that the contrary case has ever occurred.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
#define PROB_NEVER              PROB_UNLIKELY_MAG(6)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
#define PROB_ALWAYS             PROB_LIKELY_MAG(6)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
#define PROB_MIN                PROB_UNLIKELY_MAG(6)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
#define PROB_MAX                PROB_LIKELY_MAG(6)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // Static branch prediction probabilities
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // 1 in 10 (magnitude 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
#define PROB_STATIC_INFREQUENT  PROB_UNLIKELY_MAG(1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
#define PROB_STATIC_FREQUENT    PROB_LIKELY_MAG(1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // Fair probability 50/50
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
#define PROB_FAIR               (0.5f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  // Unknown probability sentinel
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
#define PROB_UNKNOWN            (-1.0f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // Probability "constructors", to distinguish as a probability any manifest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // constant without a names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
#define PROB_LIKELY(x)          ((float) (x))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#define PROB_UNLIKELY(x)        (1.0f - (float)(x))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // Other probabilities in use, but without a unique name, are documented
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // here for lack of a better place:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // 1 in 1000 probabilities (magnitude 3):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  //     threshold for converting to conditional move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  //     likelihood of null check failure if a null HAS been seen before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  //     likelihood of slow path taken in library calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  // 1 in 10,000 probabilities (magnitude 4):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  //     threshold for making an uncommon trap probability more extreme
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  //     threshold for for making a null check implicit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  //     likelihood of needing a gc if eden top moves during an allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  //     likelihood of a predicted call failure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // 1 in 100,000 probabilities (magnitude 5):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  //     threshold for ignoring counts when estimating path frequency
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  //     likelihood of FP clipping failure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  //     likelihood of catching an exception from a try block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  //     likelihood of null check failure if a null has NOT been seen before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  // gen_subtype_check() and catch_inline_exceptions().
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  float _prob;                  // Probability of true path being taken.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  float _fcnt;                  // Frequency counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  IfNode( Node *control, Node *b, float p, float fcnt )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    init_class_id(Class_If);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    init_req(0,control);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    init_req(1,b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  virtual bool pinned() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  virtual const Type *Value( PhaseTransform *phase ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  virtual const RegMask &out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  int is_range_check(Node* &range, Node* &index, jint &offset);
190
e9a0a9dcd4f6 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 1
diff changeset
   338
  Node* fold_compares(PhaseGVN* phase);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  static Node* up_one_dom(Node* curr, bool linear_only = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
190
e9a0a9dcd4f6 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 1
diff changeset
   341
  // Takes the type of val and filters it through the test represented
e9a0a9dcd4f6 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 1
diff changeset
   342
  // by if_proj and returns a more refined type if one is produced.
e9a0a9dcd4f6 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 1
diff changeset
   343
  // Returns NULL is it couldn't improve the type.
e9a0a9dcd4f6 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 1
diff changeset
   344
  static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
e9a0a9dcd4f6 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 1
diff changeset
   345
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  virtual void dump_spec(outputStream *st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
class IfTrueNode : public CProjNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  IfTrueNode( IfNode *ifnode ) : CProjNode(ifnode,1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    init_class_id(Class_IfTrue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
class IfFalseNode : public CProjNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  IfFalseNode( IfNode *ifnode ) : CProjNode(ifnode,0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    init_class_id(Class_IfFalse);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
//------------------------------PCTableNode------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
// Build an indirect branch table.  Given a control and a table index,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
// control is passed to the Projection matching the table index.  Used to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
// implement switch statements and exception-handling capabilities.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
// Undefined behavior if passed-in index is not inside the table.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
class PCTableNode : public MultiBranchNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  virtual uint hash() const;    // Target count; table size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  virtual uint cmp( const Node &n ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  virtual uint size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  const uint _size;             // Number of targets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  PCTableNode( Node *ctrl, Node *idx, uint size ) : MultiBranchNode(2), _size(size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    init_class_id(Class_PCTable);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    init_req(0, ctrl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    init_req(1, idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  virtual const Type *Value( PhaseTransform *phase ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  virtual const Type *bottom_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  virtual bool pinned() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
//------------------------------JumpNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
// Indirect branch.  Uses PCTable above to implement a switch statement.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// It emits as a table load and local branch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
class JumpNode : public PCTableNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  JumpNode( Node* control, Node* switch_val, uint size) : PCTableNode(control, switch_val, size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    init_class_id(Class_Jump);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  virtual int   Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  virtual const RegMask& out_RegMask() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  virtual const Node* is_block_proj() const { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
class JumpProjNode : public JProjNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  virtual uint hash() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  virtual uint cmp( const Node &n ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  virtual uint size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  const int  _dest_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  const uint _proj_no;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  const int  _switch_val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  JumpProjNode(Node* jumpnode, uint proj_no, int dest_bci, int switch_val)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    : JProjNode(jumpnode, proj_no), _dest_bci(dest_bci), _proj_no(proj_no), _switch_val(switch_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    init_class_id(Class_JumpProj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  virtual const Type* bottom_type() const { return Type::CONTROL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  int  dest_bci()    const { return _dest_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  int  switch_val()  const { return _switch_val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  uint proj_no()     const { return _proj_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  virtual void dump_spec(outputStream *st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
//------------------------------CatchNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
// Helper node to fork exceptions.  "Catch" catches any exceptions thrown by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
// a just-prior call.  Looks like a PCTableNode but emits no code - just the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
// table.  The table lookup and branch is implemented by RethrowNode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
class CatchNode : public PCTableNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  CatchNode( Node *ctrl, Node *idx, uint size ) : PCTableNode(ctrl,idx,size){
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    init_class_id(Class_Catch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  virtual const Type *Value( PhaseTransform *phase ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
// CatchProjNode controls which exception handler is targetted after a call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
// It is passed in the bci of the target handler, or no_handler_bci in case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
// the projection doesn't lead to an exception handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
class CatchProjNode : public CProjNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  virtual uint hash() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  virtual uint cmp( const Node &n ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  virtual uint size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  const int _handler_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    fall_through_index =  0,      // the fall through projection index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    catch_all_index    =  1,      // the projection index for catch-alls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    no_handler_bci     = -1       // the bci for fall through or catch-all projs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  CatchProjNode(Node* catchnode, uint proj_no, int handler_bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    : CProjNode(catchnode, proj_no), _handler_bci(handler_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    init_class_id(Class_CatchProj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    assert(proj_no != fall_through_index || handler_bci < 0, "fall through case must have bci < 0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  virtual const Type *bottom_type() const { return Type::CONTROL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  int  handler_bci() const        { return _handler_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  bool is_handler_proj() const    { return _handler_bci >= 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  virtual void dump_spec(outputStream *st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
//---------------------------------CreateExNode--------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
// Helper node to create the exception coming back from a call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
class CreateExNode : public TypeNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  CreateExNode(const Type* t, Node* control, Node* i_o) : TypeNode(t, 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    init_req(0, control);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    init_req(1, i_o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  virtual Node *Identity( PhaseTransform *phase );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  virtual bool pinned() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  uint match_edge(uint idx) const { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  virtual uint ideal_reg() const { return Op_RegP; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
//------------------------------NeverBranchNode-------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
// The never-taken branch.  Used to give the appearance of exiting infinite
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
// loops to those algorithms that like all paths to be reachable.  Encodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
// empty.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
class NeverBranchNode : public MultiBranchNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  NeverBranchNode( Node *ctrl ) : MultiBranchNode(1) { init_req(0,ctrl); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  virtual bool pinned() const { return true; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  virtual void format( PhaseRegAlloc *, outputStream *st ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
};