src/share/vm/opto/cfgnode.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial