src/share/vm/opto/cfgnode.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/cfgnode.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,530 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OPTO_CFGNODE_HPP
    1.29 +#define SHARE_VM_OPTO_CFGNODE_HPP
    1.30 +
    1.31 +#include "opto/multnode.hpp"
    1.32 +#include "opto/node.hpp"
    1.33 +#include "opto/opcodes.hpp"
    1.34 +#include "opto/type.hpp"
    1.35 +
    1.36 +// Portions of code courtesy of Clifford Click
    1.37 +
    1.38 +// Optimization - Graph Style
    1.39 +
    1.40 +class Matcher;
    1.41 +class Node;
    1.42 +class   RegionNode;
    1.43 +class   TypeNode;
    1.44 +class     PhiNode;
    1.45 +class   GotoNode;
    1.46 +class   MultiNode;
    1.47 +class     MultiBranchNode;
    1.48 +class       IfNode;
    1.49 +class       PCTableNode;
    1.50 +class         JumpNode;
    1.51 +class         CatchNode;
    1.52 +class       NeverBranchNode;
    1.53 +class   ProjNode;
    1.54 +class     CProjNode;
    1.55 +class       IfTrueNode;
    1.56 +class       IfFalseNode;
    1.57 +class       CatchProjNode;
    1.58 +class     JProjNode;
    1.59 +class       JumpProjNode;
    1.60 +class     SCMemProjNode;
    1.61 +class PhaseIdealLoop;
    1.62 +
    1.63 +//------------------------------RegionNode-------------------------------------
    1.64 +// The class of RegionNodes, which can be mapped to basic blocks in the
    1.65 +// program.  Their inputs point to Control sources.  PhiNodes (described
    1.66 +// below) have an input point to a RegionNode.  Merged data inputs to PhiNodes
    1.67 +// correspond 1-to-1 with RegionNode inputs.  The zero input of a PhiNode is
    1.68 +// the RegionNode, and the zero input of the RegionNode is itself.
    1.69 +class RegionNode : public Node {
    1.70 +public:
    1.71 +  // Node layout (parallels PhiNode):
    1.72 +  enum { Region,                // Generally points to self.
    1.73 +         Control                // Control arcs are [1..len)
    1.74 +  };
    1.75 +
    1.76 +  RegionNode( uint required ) : Node(required) {
    1.77 +    init_class_id(Class_Region);
    1.78 +    init_req(0,this);
    1.79 +  }
    1.80 +
    1.81 +  Node* is_copy() const {
    1.82 +    const Node* r = _in[Region];
    1.83 +    if (r == NULL)
    1.84 +      return nonnull_req();
    1.85 +    return NULL;  // not a copy!
    1.86 +  }
    1.87 +  PhiNode* has_phi() const;        // returns an arbitrary phi user, or NULL
    1.88 +  PhiNode* has_unique_phi() const; // returns the unique phi user, or NULL
    1.89 +  // Is this region node unreachable from root?
    1.90 +  bool is_unreachable_region(PhaseGVN *phase) const;
    1.91 +  virtual int Opcode() const;
    1.92 +  virtual bool pinned() const { return (const Node *)in(0) == this; }
    1.93 +  virtual bool  is_CFG   () const { return true; }
    1.94 +  virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
    1.95 +  virtual bool depends_only_on_test() const { return false; }
    1.96 +  virtual const Type *bottom_type() const { return Type::CONTROL; }
    1.97 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.98 +  virtual Node *Identity( PhaseTransform *phase );
    1.99 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.100 +  virtual const RegMask &out_RegMask() const;
   1.101 +  bool try_clean_mem_phi(PhaseGVN *phase);
   1.102 +};
   1.103 +
   1.104 +//------------------------------JProjNode--------------------------------------
   1.105 +// jump projection for node that produces multiple control-flow paths
   1.106 +class JProjNode : public ProjNode {
   1.107 + public:
   1.108 +  JProjNode( Node* ctrl, uint idx ) : ProjNode(ctrl,idx) {}
   1.109 +  virtual int Opcode() const;
   1.110 +  virtual bool  is_CFG() const { return true; }
   1.111 +  virtual uint  hash() const { return NO_HASH; }  // CFG nodes do not hash
   1.112 +  virtual const Node* is_block_proj() const { return in(0); }
   1.113 +  virtual const RegMask& out_RegMask() const;
   1.114 +  virtual uint  ideal_reg() const { return 0; }
   1.115 +};
   1.116 +
   1.117 +//------------------------------PhiNode----------------------------------------
   1.118 +// PhiNodes merge values from different Control paths.  Slot 0 points to the
   1.119 +// controlling RegionNode.  Other slots map 1-for-1 with incoming control flow
   1.120 +// paths to the RegionNode.  For speed reasons (to avoid another pass) we
   1.121 +// can turn PhiNodes into copys in-place by NULL'ing out their RegionNode
   1.122 +// input in slot 0.
   1.123 +class PhiNode : public TypeNode {
   1.124 +  const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes.
   1.125 +  const int _inst_id;     // Instance id of the memory slice.
   1.126 +  const int _inst_index;  // Alias index of the instance memory slice.
   1.127 +  // Array elements references have the same alias_idx but different offset.
   1.128 +  const int _inst_offset; // Offset of the instance memory slice.
   1.129 +  // Size is bigger to hold the _adr_type field.
   1.130 +  virtual uint hash() const;    // Check the type
   1.131 +  virtual uint cmp( const Node &n ) const;
   1.132 +  virtual uint size_of() const { return sizeof(*this); }
   1.133 +
   1.134 +  // Determine if CMoveNode::is_cmove_id can be used at this join point.
   1.135 +  Node* is_cmove_id(PhaseTransform* phase, int true_path);
   1.136 +
   1.137 +public:
   1.138 +  // Node layout (parallels RegionNode):
   1.139 +  enum { Region,                // Control input is the Phi's region.
   1.140 +         Input                  // Input values are [1..len)
   1.141 +  };
   1.142 +
   1.143 +  PhiNode( Node *r, const Type *t, const TypePtr* at = NULL,
   1.144 +           const int iid = TypeOopPtr::InstanceTop,
   1.145 +           const int iidx = Compile::AliasIdxTop,
   1.146 +           const int ioffs = Type::OffsetTop )
   1.147 +    : TypeNode(t,r->req()),
   1.148 +      _adr_type(at),
   1.149 +      _inst_id(iid),
   1.150 +      _inst_index(iidx),
   1.151 +      _inst_offset(ioffs)
   1.152 +  {
   1.153 +    init_class_id(Class_Phi);
   1.154 +    init_req(0, r);
   1.155 +    verify_adr_type();
   1.156 +  }
   1.157 +  // create a new phi with in edges matching r and set (initially) to x
   1.158 +  static PhiNode* make( Node* r, Node* x );
   1.159 +  // extra type arguments override the new phi's bottom_type and adr_type
   1.160 +  static PhiNode* make( Node* r, Node* x, const Type *t, const TypePtr* at = NULL );
   1.161 +  // create a new phi with narrowed memory type
   1.162 +  PhiNode* slice_memory(const TypePtr* adr_type) const;
   1.163 +  PhiNode* split_out_instance(const TypePtr* at, PhaseIterGVN *igvn) const;
   1.164 +  // like make(r, x), but does not initialize the in edges to x
   1.165 +  static PhiNode* make_blank( Node* r, Node* x );
   1.166 +
   1.167 +  // Accessors
   1.168 +  RegionNode* region() const { Node* r = in(Region); assert(!r || r->is_Region(), ""); return (RegionNode*)r; }
   1.169 +
   1.170 +  Node* is_copy() const {
   1.171 +    // The node is a real phi if _in[0] is a Region node.
   1.172 +    DEBUG_ONLY(const Node* r = _in[Region];)
   1.173 +    assert(r != NULL && r->is_Region(), "Not valid control");
   1.174 +    return NULL;  // not a copy!
   1.175 +  }
   1.176 +
   1.177 +  bool is_tripcount() const;
   1.178 +
   1.179 +  // Determine a unique non-trivial input, if any.
   1.180 +  // Ignore casts if it helps.  Return NULL on failure.
   1.181 +  Node* unique_input(PhaseTransform *phase);
   1.182 +
   1.183 +  // Check for a simple dead loop.
   1.184 +  enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
   1.185 +  LoopSafety simple_data_loop_check(Node *in) const;
   1.186 +  // Is it unsafe data loop? It becomes a dead loop if this phi node removed.
   1.187 +  bool is_unsafe_data_reference(Node *in) const;
   1.188 +  int  is_diamond_phi(bool check_control_only = false) const;
   1.189 +  virtual int Opcode() const;
   1.190 +  virtual bool pinned() const { return in(0) != 0; }
   1.191 +  virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
   1.192 +
   1.193 +  const int inst_id()     const { return _inst_id; }
   1.194 +  const int inst_index()  const { return _inst_index; }
   1.195 +  const int inst_offset() const { return _inst_offset; }
   1.196 +  bool is_same_inst_field(const Type* tp, int id, int index, int offset) {
   1.197 +    return type()->basic_type() == tp->basic_type() &&
   1.198 +           inst_id()     == id     &&
   1.199 +           inst_index()  == index  &&
   1.200 +           inst_offset() == offset &&
   1.201 +           type()->higher_equal(tp);
   1.202 +  }
   1.203 +
   1.204 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.205 +  virtual Node *Identity( PhaseTransform *phase );
   1.206 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.207 +  virtual const RegMask &out_RegMask() const;
   1.208 +  virtual const RegMask &in_RegMask(uint) const;
   1.209 +#ifndef PRODUCT
   1.210 +  virtual void dump_spec(outputStream *st) const;
   1.211 +#endif
   1.212 +#ifdef ASSERT
   1.213 +  void verify_adr_type(VectorSet& visited, const TypePtr* at) const;
   1.214 +  void verify_adr_type(bool recursive = false) const;
   1.215 +#else //ASSERT
   1.216 +  void verify_adr_type(bool recursive = false) const {}
   1.217 +#endif //ASSERT
   1.218 +};
   1.219 +
   1.220 +//------------------------------GotoNode---------------------------------------
   1.221 +// GotoNodes perform direct branches.
   1.222 +class GotoNode : public Node {
   1.223 +public:
   1.224 +  GotoNode( Node *control ) : Node(control) {}
   1.225 +  virtual int Opcode() const;
   1.226 +  virtual bool pinned() const { return true; }
   1.227 +  virtual bool  is_CFG() const { return true; }
   1.228 +  virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
   1.229 +  virtual const Node *is_block_proj() const { return this; }
   1.230 +  virtual bool depends_only_on_test() const { return false; }
   1.231 +  virtual const Type *bottom_type() const { return Type::CONTROL; }
   1.232 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.233 +  virtual Node *Identity( PhaseTransform *phase );
   1.234 +  virtual const RegMask &out_RegMask() const;
   1.235 +};
   1.236 +
   1.237 +//------------------------------CProjNode--------------------------------------
   1.238 +// control projection for node that produces multiple control-flow paths
   1.239 +class CProjNode : public ProjNode {
   1.240 +public:
   1.241 +  CProjNode( Node *ctrl, uint idx ) : ProjNode(ctrl,idx) {}
   1.242 +  virtual int Opcode() const;
   1.243 +  virtual bool  is_CFG() const { return true; }
   1.244 +  virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
   1.245 +  virtual const Node *is_block_proj() const { return in(0); }
   1.246 +  virtual const RegMask &out_RegMask() const;
   1.247 +  virtual uint ideal_reg() const { return 0; }
   1.248 +};
   1.249 +
   1.250 +//---------------------------MultiBranchNode-----------------------------------
   1.251 +// This class defines a MultiBranchNode, a MultiNode which yields multiple
   1.252 +// control values. These are distinguished from other types of MultiNodes
   1.253 +// which yield multiple values, but control is always and only projection #0.
   1.254 +class MultiBranchNode : public MultiNode {
   1.255 +public:
   1.256 +  MultiBranchNode( uint required ) : MultiNode(required) {
   1.257 +    init_class_id(Class_MultiBranch);
   1.258 +  }
   1.259 +  // returns required number of users to be well formed.
   1.260 +  virtual int required_outcnt() const = 0;
   1.261 +};
   1.262 +
   1.263 +//------------------------------IfNode-----------------------------------------
   1.264 +// Output selected Control, based on a boolean test
   1.265 +class IfNode : public MultiBranchNode {
   1.266 +  // Size is bigger to hold the probability field.  However, _prob does not
   1.267 +  // change the semantics so it does not appear in the hash & cmp functions.
   1.268 +  virtual uint size_of() const { return sizeof(*this); }
   1.269 +public:
   1.270 +
   1.271 +  // Degrees of branch prediction probability by order of magnitude:
   1.272 +  // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
   1.273 +  // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
   1.274 +#define PROB_UNLIKELY_MAG(N)    (1e- ## N ## f)
   1.275 +#define PROB_LIKELY_MAG(N)      (1.0f-PROB_UNLIKELY_MAG(N))
   1.276 +
   1.277 +  // Maximum and minimum branch prediction probabilties
   1.278 +  // 1 in 1,000,000 (magnitude 6)
   1.279 +  //
   1.280 +  // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
   1.281 +  // they are used to distinguish different situations:
   1.282 +  //
   1.283 +  // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
   1.284 +  // very likely (unlikely) but with a concrete possibility of a rare
   1.285 +  // contrary case.  These constants would be used for pinning
   1.286 +  // measurements, and as measures for assertions that have high
   1.287 +  // confidence, but some evidence of occasional failure.
   1.288 +  //
   1.289 +  // The name PROB_ALWAYS (PROB_NEVER) is to stand for situations for which
   1.290 +  // there is no evidence at all that the contrary case has ever occurred.
   1.291 +
   1.292 +#define PROB_NEVER              PROB_UNLIKELY_MAG(6)
   1.293 +#define PROB_ALWAYS             PROB_LIKELY_MAG(6)
   1.294 +
   1.295 +#define PROB_MIN                PROB_UNLIKELY_MAG(6)
   1.296 +#define PROB_MAX                PROB_LIKELY_MAG(6)
   1.297 +
   1.298 +  // Static branch prediction probabilities
   1.299 +  // 1 in 10 (magnitude 1)
   1.300 +#define PROB_STATIC_INFREQUENT  PROB_UNLIKELY_MAG(1)
   1.301 +#define PROB_STATIC_FREQUENT    PROB_LIKELY_MAG(1)
   1.302 +
   1.303 +  // Fair probability 50/50
   1.304 +#define PROB_FAIR               (0.5f)
   1.305 +
   1.306 +  // Unknown probability sentinel
   1.307 +#define PROB_UNKNOWN            (-1.0f)
   1.308 +
   1.309 +  // Probability "constructors", to distinguish as a probability any manifest
   1.310 +  // constant without a names
   1.311 +#define PROB_LIKELY(x)          ((float) (x))
   1.312 +#define PROB_UNLIKELY(x)        (1.0f - (float)(x))
   1.313 +
   1.314 +  // Other probabilities in use, but without a unique name, are documented
   1.315 +  // here for lack of a better place:
   1.316 +  //
   1.317 +  // 1 in 1000 probabilities (magnitude 3):
   1.318 +  //     threshold for converting to conditional move
   1.319 +  //     likelihood of null check failure if a null HAS been seen before
   1.320 +  //     likelihood of slow path taken in library calls
   1.321 +  //
   1.322 +  // 1 in 10,000 probabilities (magnitude 4):
   1.323 +  //     threshold for making an uncommon trap probability more extreme
   1.324 +  //     threshold for for making a null check implicit
   1.325 +  //     likelihood of needing a gc if eden top moves during an allocation
   1.326 +  //     likelihood of a predicted call failure
   1.327 +  //
   1.328 +  // 1 in 100,000 probabilities (magnitude 5):
   1.329 +  //     threshold for ignoring counts when estimating path frequency
   1.330 +  //     likelihood of FP clipping failure
   1.331 +  //     likelihood of catching an exception from a try block
   1.332 +  //     likelihood of null check failure if a null has NOT been seen before
   1.333 +  //
   1.334 +  // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
   1.335 +  // gen_subtype_check() and catch_inline_exceptions().
   1.336 +
   1.337 +  float _prob;                  // Probability of true path being taken.
   1.338 +  float _fcnt;                  // Frequency counter
   1.339 +  IfNode( Node *control, Node *b, float p, float fcnt )
   1.340 +    : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
   1.341 +    init_class_id(Class_If);
   1.342 +    init_req(0,control);
   1.343 +    init_req(1,b);
   1.344 +  }
   1.345 +  virtual int Opcode() const;
   1.346 +  virtual bool pinned() const { return true; }
   1.347 +  virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
   1.348 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.349 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.350 +  virtual int required_outcnt() const { return 2; }
   1.351 +  virtual const RegMask &out_RegMask() const;
   1.352 +  void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
   1.353 +  int is_range_check(Node* &range, Node* &index, jint &offset);
   1.354 +  Node* fold_compares(PhaseGVN* phase);
   1.355 +  static Node* up_one_dom(Node* curr, bool linear_only = false);
   1.356 +
   1.357 +  // Takes the type of val and filters it through the test represented
   1.358 +  // by if_proj and returns a more refined type if one is produced.
   1.359 +  // Returns NULL is it couldn't improve the type.
   1.360 +  static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
   1.361 +
   1.362 +#ifndef PRODUCT
   1.363 +  virtual void dump_spec(outputStream *st) const;
   1.364 +#endif
   1.365 +};
   1.366 +
   1.367 +class IfTrueNode : public CProjNode {
   1.368 +public:
   1.369 +  IfTrueNode( IfNode *ifnode ) : CProjNode(ifnode,1) {
   1.370 +    init_class_id(Class_IfTrue);
   1.371 +  }
   1.372 +  virtual int Opcode() const;
   1.373 +  virtual Node *Identity( PhaseTransform *phase );
   1.374 +};
   1.375 +
   1.376 +class IfFalseNode : public CProjNode {
   1.377 +public:
   1.378 +  IfFalseNode( IfNode *ifnode ) : CProjNode(ifnode,0) {
   1.379 +    init_class_id(Class_IfFalse);
   1.380 +  }
   1.381 +  virtual int Opcode() const;
   1.382 +  virtual Node *Identity( PhaseTransform *phase );
   1.383 +};
   1.384 +
   1.385 +
   1.386 +//------------------------------PCTableNode------------------------------------
   1.387 +// Build an indirect branch table.  Given a control and a table index,
   1.388 +// control is passed to the Projection matching the table index.  Used to
   1.389 +// implement switch statements and exception-handling capabilities.
   1.390 +// Undefined behavior if passed-in index is not inside the table.
   1.391 +class PCTableNode : public MultiBranchNode {
   1.392 +  virtual uint hash() const;    // Target count; table size
   1.393 +  virtual uint cmp( const Node &n ) const;
   1.394 +  virtual uint size_of() const { return sizeof(*this); }
   1.395 +
   1.396 +public:
   1.397 +  const uint _size;             // Number of targets
   1.398 +
   1.399 +  PCTableNode( Node *ctrl, Node *idx, uint size ) : MultiBranchNode(2), _size(size) {
   1.400 +    init_class_id(Class_PCTable);
   1.401 +    init_req(0, ctrl);
   1.402 +    init_req(1, idx);
   1.403 +  }
   1.404 +  virtual int Opcode() const;
   1.405 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.406 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.407 +  virtual const Type *bottom_type() const;
   1.408 +  virtual bool pinned() const { return true; }
   1.409 +  virtual int required_outcnt() const { return _size; }
   1.410 +};
   1.411 +
   1.412 +//------------------------------JumpNode---------------------------------------
   1.413 +// Indirect branch.  Uses PCTable above to implement a switch statement.
   1.414 +// It emits as a table load and local branch.
   1.415 +class JumpNode : public PCTableNode {
   1.416 +public:
   1.417 +  JumpNode( Node* control, Node* switch_val, uint size) : PCTableNode(control, switch_val, size) {
   1.418 +    init_class_id(Class_Jump);
   1.419 +  }
   1.420 +  virtual int   Opcode() const;
   1.421 +  virtual const RegMask& out_RegMask() const;
   1.422 +  virtual const Node* is_block_proj() const { return this; }
   1.423 +};
   1.424 +
   1.425 +class JumpProjNode : public JProjNode {
   1.426 +  virtual uint hash() const;
   1.427 +  virtual uint cmp( const Node &n ) const;
   1.428 +  virtual uint size_of() const { return sizeof(*this); }
   1.429 +
   1.430 + private:
   1.431 +  const int  _dest_bci;
   1.432 +  const uint _proj_no;
   1.433 +  const int  _switch_val;
   1.434 + public:
   1.435 +  JumpProjNode(Node* jumpnode, uint proj_no, int dest_bci, int switch_val)
   1.436 +    : JProjNode(jumpnode, proj_no), _dest_bci(dest_bci), _proj_no(proj_no), _switch_val(switch_val) {
   1.437 +    init_class_id(Class_JumpProj);
   1.438 +  }
   1.439 +
   1.440 +  virtual int Opcode() const;
   1.441 +  virtual const Type* bottom_type() const { return Type::CONTROL; }
   1.442 +  int  dest_bci()    const { return _dest_bci; }
   1.443 +  int  switch_val()  const { return _switch_val; }
   1.444 +  uint proj_no()     const { return _proj_no; }
   1.445 +#ifndef PRODUCT
   1.446 +  virtual void dump_spec(outputStream *st) const;
   1.447 +#endif
   1.448 +};
   1.449 +
   1.450 +//------------------------------CatchNode--------------------------------------
   1.451 +// Helper node to fork exceptions.  "Catch" catches any exceptions thrown by
   1.452 +// a just-prior call.  Looks like a PCTableNode but emits no code - just the
   1.453 +// table.  The table lookup and branch is implemented by RethrowNode.
   1.454 +class CatchNode : public PCTableNode {
   1.455 +public:
   1.456 +  CatchNode( Node *ctrl, Node *idx, uint size ) : PCTableNode(ctrl,idx,size){
   1.457 +    init_class_id(Class_Catch);
   1.458 +  }
   1.459 +  virtual int Opcode() const;
   1.460 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.461 +};
   1.462 +
   1.463 +// CatchProjNode controls which exception handler is targetted after a call.
   1.464 +// It is passed in the bci of the target handler, or no_handler_bci in case
   1.465 +// the projection doesn't lead to an exception handler.
   1.466 +class CatchProjNode : public CProjNode {
   1.467 +  virtual uint hash() const;
   1.468 +  virtual uint cmp( const Node &n ) const;
   1.469 +  virtual uint size_of() const { return sizeof(*this); }
   1.470 +
   1.471 +private:
   1.472 +  const int _handler_bci;
   1.473 +
   1.474 +public:
   1.475 +  enum {
   1.476 +    fall_through_index =  0,      // the fall through projection index
   1.477 +    catch_all_index    =  1,      // the projection index for catch-alls
   1.478 +    no_handler_bci     = -1       // the bci for fall through or catch-all projs
   1.479 +  };
   1.480 +
   1.481 +  CatchProjNode(Node* catchnode, uint proj_no, int handler_bci)
   1.482 +    : CProjNode(catchnode, proj_no), _handler_bci(handler_bci) {
   1.483 +    init_class_id(Class_CatchProj);
   1.484 +    assert(proj_no != fall_through_index || handler_bci < 0, "fall through case must have bci < 0");
   1.485 +  }
   1.486 +
   1.487 +  virtual int Opcode() const;
   1.488 +  virtual Node *Identity( PhaseTransform *phase );
   1.489 +  virtual const Type *bottom_type() const { return Type::CONTROL; }
   1.490 +  int  handler_bci() const        { return _handler_bci; }
   1.491 +  bool is_handler_proj() const    { return _handler_bci >= 0; }
   1.492 +#ifndef PRODUCT
   1.493 +  virtual void dump_spec(outputStream *st) const;
   1.494 +#endif
   1.495 +};
   1.496 +
   1.497 +
   1.498 +//---------------------------------CreateExNode--------------------------------
   1.499 +// Helper node to create the exception coming back from a call
   1.500 +class CreateExNode : public TypeNode {
   1.501 +public:
   1.502 +  CreateExNode(const Type* t, Node* control, Node* i_o) : TypeNode(t, 2) {
   1.503 +    init_req(0, control);
   1.504 +    init_req(1, i_o);
   1.505 +  }
   1.506 +  virtual int Opcode() const;
   1.507 +  virtual Node *Identity( PhaseTransform *phase );
   1.508 +  virtual bool pinned() const { return true; }
   1.509 +  uint match_edge(uint idx) const { return 0; }
   1.510 +  virtual uint ideal_reg() const { return Op_RegP; }
   1.511 +};
   1.512 +
   1.513 +//------------------------------NeverBranchNode-------------------------------
   1.514 +// The never-taken branch.  Used to give the appearance of exiting infinite
   1.515 +// loops to those algorithms that like all paths to be reachable.  Encodes
   1.516 +// empty.
   1.517 +class NeverBranchNode : public MultiBranchNode {
   1.518 +public:
   1.519 +  NeverBranchNode( Node *ctrl ) : MultiBranchNode(1) { init_req(0,ctrl); }
   1.520 +  virtual int Opcode() const;
   1.521 +  virtual bool pinned() const { return true; };
   1.522 +  virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
   1.523 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.524 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.525 +  virtual int required_outcnt() const { return 2; }
   1.526 +  virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { }
   1.527 +  virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
   1.528 +#ifndef PRODUCT
   1.529 +  virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   1.530 +#endif
   1.531 +};
   1.532 +
   1.533 +#endif // SHARE_VM_OPTO_CFGNODE_HPP

mercurial