src/share/vm/opto/cfgnode.hpp

Thu, 24 May 2018 19:26:50 +0800

author
aoqi
date
Thu, 24 May 2018 19:26:50 +0800
changeset 8862
fd13a567f179
parent 8856
ac27a9c85bea
child 9041
95a08233f46c
permissions
-rw-r--r--

#7046 C2 supports long branch
Contributed-by: fujie

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.
poonam@8646 122 // The following fields are only used for data PhiNodes to indicate
poonam@8646 123 // that the PhiNode represents the value of a known instance field.
poonam@8646 124 int _inst_mem_id; // Instance memory id (node index of the memory Phi)
aoqi@0 125 const int _inst_id; // Instance id of the memory slice.
aoqi@0 126 const int _inst_index; // Alias index of the instance memory slice.
aoqi@0 127 // Array elements references have the same alias_idx but different offset.
aoqi@0 128 const int _inst_offset; // Offset of the instance memory slice.
aoqi@0 129 // Size is bigger to hold the _adr_type field.
aoqi@0 130 virtual uint hash() const; // Check the type
aoqi@0 131 virtual uint cmp( const Node &n ) const;
aoqi@0 132 virtual uint size_of() const { return sizeof(*this); }
aoqi@0 133
aoqi@0 134 // Determine if CMoveNode::is_cmove_id can be used at this join point.
aoqi@0 135 Node* is_cmove_id(PhaseTransform* phase, int true_path);
aoqi@0 136
aoqi@0 137 public:
aoqi@0 138 // Node layout (parallels RegionNode):
aoqi@0 139 enum { Region, // Control input is the Phi's region.
aoqi@0 140 Input // Input values are [1..len)
aoqi@0 141 };
aoqi@0 142
aoqi@0 143 PhiNode( Node *r, const Type *t, const TypePtr* at = NULL,
poonam@8646 144 const int imid = -1,
aoqi@0 145 const int iid = TypeOopPtr::InstanceTop,
aoqi@0 146 const int iidx = Compile::AliasIdxTop,
aoqi@0 147 const int ioffs = Type::OffsetTop )
aoqi@0 148 : TypeNode(t,r->req()),
aoqi@0 149 _adr_type(at),
poonam@8646 150 _inst_mem_id(imid),
aoqi@0 151 _inst_id(iid),
aoqi@0 152 _inst_index(iidx),
aoqi@0 153 _inst_offset(ioffs)
aoqi@0 154 {
aoqi@0 155 init_class_id(Class_Phi);
aoqi@0 156 init_req(0, r);
aoqi@0 157 verify_adr_type();
aoqi@0 158 }
aoqi@0 159 // create a new phi with in edges matching r and set (initially) to x
aoqi@0 160 static PhiNode* make( Node* r, Node* x );
aoqi@0 161 // extra type arguments override the new phi's bottom_type and adr_type
aoqi@0 162 static PhiNode* make( Node* r, Node* x, const Type *t, const TypePtr* at = NULL );
aoqi@0 163 // create a new phi with narrowed memory type
aoqi@0 164 PhiNode* slice_memory(const TypePtr* adr_type) const;
aoqi@0 165 PhiNode* split_out_instance(const TypePtr* at, PhaseIterGVN *igvn) const;
aoqi@0 166 // like make(r, x), but does not initialize the in edges to x
aoqi@0 167 static PhiNode* make_blank( Node* r, Node* x );
aoqi@0 168
aoqi@0 169 // Accessors
aoqi@0 170 RegionNode* region() const { Node* r = in(Region); assert(!r || r->is_Region(), ""); return (RegionNode*)r; }
aoqi@0 171
aoqi@0 172 Node* is_copy() const {
aoqi@0 173 // The node is a real phi if _in[0] is a Region node.
aoqi@0 174 DEBUG_ONLY(const Node* r = _in[Region];)
aoqi@0 175 assert(r != NULL && r->is_Region(), "Not valid control");
aoqi@0 176 return NULL; // not a copy!
aoqi@0 177 }
aoqi@0 178
aoqi@0 179 bool is_tripcount() const;
aoqi@0 180
aoqi@0 181 // Determine a unique non-trivial input, if any.
aoqi@0 182 // Ignore casts if it helps. Return NULL on failure.
aoqi@0 183 Node* unique_input(PhaseTransform *phase);
aoqi@0 184
aoqi@0 185 // Check for a simple dead loop.
aoqi@0 186 enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
aoqi@0 187 LoopSafety simple_data_loop_check(Node *in) const;
aoqi@0 188 // Is it unsafe data loop? It becomes a dead loop if this phi node removed.
aoqi@0 189 bool is_unsafe_data_reference(Node *in) const;
aoqi@0 190 int is_diamond_phi(bool check_control_only = false) const;
aoqi@0 191 virtual int Opcode() const;
aoqi@0 192 virtual bool pinned() const { return in(0) != 0; }
aoqi@0 193 virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
aoqi@0 194
poonam@8646 195 void set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; }
poonam@8646 196 const int inst_mem_id() const { return _inst_mem_id; }
aoqi@0 197 const int inst_id() const { return _inst_id; }
aoqi@0 198 const int inst_index() const { return _inst_index; }
aoqi@0 199 const int inst_offset() const { return _inst_offset; }
poonam@8646 200 bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) {
aoqi@0 201 return type()->basic_type() == tp->basic_type() &&
poonam@8646 202 inst_mem_id() == mem_id &&
aoqi@0 203 inst_id() == id &&
aoqi@0 204 inst_index() == index &&
aoqi@0 205 inst_offset() == offset &&
aoqi@0 206 type()->higher_equal(tp);
aoqi@0 207 }
aoqi@0 208
aoqi@0 209 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 210 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 211 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 212 virtual const RegMask &out_RegMask() const;
aoqi@0 213 virtual const RegMask &in_RegMask(uint) const;
aoqi@0 214 #ifndef PRODUCT
aoqi@0 215 virtual void dump_spec(outputStream *st) const;
aoqi@0 216 #endif
aoqi@0 217 #ifdef ASSERT
aoqi@0 218 void verify_adr_type(VectorSet& visited, const TypePtr* at) const;
aoqi@0 219 void verify_adr_type(bool recursive = false) const;
aoqi@0 220 #else //ASSERT
aoqi@0 221 void verify_adr_type(bool recursive = false) const {}
aoqi@0 222 #endif //ASSERT
aoqi@0 223 };
aoqi@0 224
aoqi@0 225 //------------------------------GotoNode---------------------------------------
aoqi@0 226 // GotoNodes perform direct branches.
aoqi@0 227 class GotoNode : public Node {
aoqi@0 228 public:
aoqi@0 229 GotoNode( Node *control ) : Node(control) {}
aoqi@0 230 virtual int Opcode() const;
aoqi@0 231 virtual bool pinned() const { return true; }
aoqi@0 232 virtual bool is_CFG() const { return true; }
aoqi@0 233 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
aoqi@0 234 virtual const Node *is_block_proj() const { return this; }
aoqi@0 235 virtual bool depends_only_on_test() const { return false; }
aoqi@0 236 virtual const Type *bottom_type() const { return Type::CONTROL; }
aoqi@0 237 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 238 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 239 virtual const RegMask &out_RegMask() const;
aoqi@0 240 };
aoqi@0 241
aoqi@0 242 //------------------------------CProjNode--------------------------------------
aoqi@0 243 // control projection for node that produces multiple control-flow paths
aoqi@0 244 class CProjNode : public ProjNode {
aoqi@0 245 public:
aoqi@0 246 CProjNode( Node *ctrl, uint idx ) : ProjNode(ctrl,idx) {}
aoqi@0 247 virtual int Opcode() const;
aoqi@0 248 virtual bool is_CFG() const { return true; }
aoqi@0 249 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
aoqi@0 250 virtual const Node *is_block_proj() const { return in(0); }
aoqi@0 251 virtual const RegMask &out_RegMask() const;
aoqi@0 252 virtual uint ideal_reg() const { return 0; }
aoqi@0 253 };
aoqi@0 254
aoqi@0 255 //---------------------------MultiBranchNode-----------------------------------
aoqi@0 256 // This class defines a MultiBranchNode, a MultiNode which yields multiple
aoqi@0 257 // control values. These are distinguished from other types of MultiNodes
aoqi@0 258 // which yield multiple values, but control is always and only projection #0.
aoqi@0 259 class MultiBranchNode : public MultiNode {
aoqi@0 260 public:
aoqi@0 261 MultiBranchNode( uint required ) : MultiNode(required) {
aoqi@0 262 init_class_id(Class_MultiBranch);
aoqi@0 263 }
aoqi@0 264 // returns required number of users to be well formed.
aoqi@0 265 virtual int required_outcnt() const = 0;
aoqi@0 266 };
aoqi@0 267
aoqi@0 268 //------------------------------IfNode-----------------------------------------
aoqi@0 269 // Output selected Control, based on a boolean test
aoqi@0 270 class IfNode : public MultiBranchNode {
aoqi@0 271 // Size is bigger to hold the probability field. However, _prob does not
aoqi@0 272 // change the semantics so it does not appear in the hash & cmp functions.
aoqi@0 273 virtual uint size_of() const { return sizeof(*this); }
aoqi@0 274 public:
aoqi@0 275
aoqi@0 276 // Degrees of branch prediction probability by order of magnitude:
aoqi@0 277 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
aoqi@0 278 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
aoqi@0 279 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
aoqi@0 280 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
aoqi@0 281
aoqi@0 282 // Maximum and minimum branch prediction probabilties
aoqi@0 283 // 1 in 1,000,000 (magnitude 6)
aoqi@0 284 //
aoqi@0 285 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
aoqi@0 286 // they are used to distinguish different situations:
aoqi@0 287 //
aoqi@0 288 // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
aoqi@0 289 // very likely (unlikely) but with a concrete possibility of a rare
aoqi@0 290 // contrary case. These constants would be used for pinning
aoqi@0 291 // measurements, and as measures for assertions that have high
aoqi@0 292 // confidence, but some evidence of occasional failure.
aoqi@0 293 //
aoqi@0 294 // The name PROB_ALWAYS (PROB_NEVER) is to stand for situations for which
aoqi@0 295 // there is no evidence at all that the contrary case has ever occurred.
aoqi@0 296
aoqi@0 297 #define PROB_NEVER PROB_UNLIKELY_MAG(6)
aoqi@0 298 #define PROB_ALWAYS PROB_LIKELY_MAG(6)
aoqi@0 299
aoqi@0 300 #define PROB_MIN PROB_UNLIKELY_MAG(6)
aoqi@0 301 #define PROB_MAX PROB_LIKELY_MAG(6)
aoqi@0 302
aoqi@0 303 // Static branch prediction probabilities
aoqi@0 304 // 1 in 10 (magnitude 1)
aoqi@0 305 #define PROB_STATIC_INFREQUENT PROB_UNLIKELY_MAG(1)
aoqi@0 306 #define PROB_STATIC_FREQUENT PROB_LIKELY_MAG(1)
aoqi@0 307
aoqi@0 308 // Fair probability 50/50
aoqi@0 309 #define PROB_FAIR (0.5f)
aoqi@0 310
aoqi@0 311 // Unknown probability sentinel
aoqi@0 312 #define PROB_UNKNOWN (-1.0f)
aoqi@0 313
aoqi@0 314 // Probability "constructors", to distinguish as a probability any manifest
aoqi@0 315 // constant without a names
aoqi@0 316 #define PROB_LIKELY(x) ((float) (x))
aoqi@0 317 #define PROB_UNLIKELY(x) (1.0f - (float)(x))
aoqi@0 318
aoqi@0 319 // Other probabilities in use, but without a unique name, are documented
aoqi@0 320 // here for lack of a better place:
aoqi@0 321 //
aoqi@0 322 // 1 in 1000 probabilities (magnitude 3):
aoqi@0 323 // threshold for converting to conditional move
aoqi@0 324 // likelihood of null check failure if a null HAS been seen before
aoqi@0 325 // likelihood of slow path taken in library calls
aoqi@0 326 //
aoqi@0 327 // 1 in 10,000 probabilities (magnitude 4):
aoqi@0 328 // threshold for making an uncommon trap probability more extreme
aoqi@0 329 // threshold for for making a null check implicit
aoqi@0 330 // likelihood of needing a gc if eden top moves during an allocation
aoqi@0 331 // likelihood of a predicted call failure
aoqi@0 332 //
aoqi@0 333 // 1 in 100,000 probabilities (magnitude 5):
aoqi@0 334 // threshold for ignoring counts when estimating path frequency
aoqi@0 335 // likelihood of FP clipping failure
aoqi@0 336 // likelihood of catching an exception from a try block
aoqi@0 337 // likelihood of null check failure if a null has NOT been seen before
aoqi@0 338 //
aoqi@0 339 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
aoqi@0 340 // gen_subtype_check() and catch_inline_exceptions().
aoqi@0 341
aoqi@0 342 float _prob; // Probability of true path being taken.
aoqi@0 343 float _fcnt; // Frequency counter
aoqi@0 344 IfNode( Node *control, Node *b, float p, float fcnt )
aoqi@0 345 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
aoqi@0 346 init_class_id(Class_If);
aoqi@0 347 init_req(0,control);
aoqi@0 348 init_req(1,b);
aoqi@0 349 }
aoqi@0 350 virtual int Opcode() const;
aoqi@0 351 virtual bool pinned() const { return true; }
aoqi@0 352 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
aoqi@0 353 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 354 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 355 virtual int required_outcnt() const { return 2; }
aoqi@0 356 virtual const RegMask &out_RegMask() const;
aoqi@0 357 void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
aoqi@0 358 int is_range_check(Node* &range, Node* &index, jint &offset);
aoqi@0 359 Node* fold_compares(PhaseGVN* phase);
aoqi@0 360 static Node* up_one_dom(Node* curr, bool linear_only = false);
aoqi@0 361
aoqi@0 362 // Takes the type of val and filters it through the test represented
aoqi@0 363 // by if_proj and returns a more refined type if one is produced.
aoqi@0 364 // Returns NULL is it couldn't improve the type.
aoqi@0 365 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
aoqi@0 366
aoqi@0 367 #ifndef PRODUCT
aoqi@0 368 virtual void dump_spec(outputStream *st) const;
aoqi@0 369 #endif
aoqi@0 370 };
aoqi@0 371
aoqi@0 372 class IfTrueNode : public CProjNode {
aoqi@0 373 public:
aoqi@0 374 IfTrueNode( IfNode *ifnode ) : CProjNode(ifnode,1) {
aoqi@0 375 init_class_id(Class_IfTrue);
aoqi@0 376 }
aoqi@0 377 virtual int Opcode() const;
aoqi@0 378 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 379 };
aoqi@0 380
aoqi@0 381 class IfFalseNode : public CProjNode {
aoqi@0 382 public:
aoqi@0 383 IfFalseNode( IfNode *ifnode ) : CProjNode(ifnode,0) {
aoqi@0 384 init_class_id(Class_IfFalse);
aoqi@0 385 }
aoqi@0 386 virtual int Opcode() const;
aoqi@0 387 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 388 };
aoqi@0 389
aoqi@0 390
aoqi@0 391 //------------------------------PCTableNode------------------------------------
aoqi@0 392 // Build an indirect branch table. Given a control and a table index,
aoqi@0 393 // control is passed to the Projection matching the table index. Used to
aoqi@0 394 // implement switch statements and exception-handling capabilities.
aoqi@0 395 // Undefined behavior if passed-in index is not inside the table.
aoqi@0 396 class PCTableNode : public MultiBranchNode {
aoqi@0 397 virtual uint hash() const; // Target count; table size
aoqi@0 398 virtual uint cmp( const Node &n ) const;
aoqi@0 399 virtual uint size_of() const { return sizeof(*this); }
aoqi@0 400
aoqi@0 401 public:
aoqi@0 402 const uint _size; // Number of targets
aoqi@0 403
aoqi@0 404 PCTableNode( Node *ctrl, Node *idx, uint size ) : MultiBranchNode(2), _size(size) {
aoqi@0 405 init_class_id(Class_PCTable);
aoqi@0 406 init_req(0, ctrl);
aoqi@0 407 init_req(1, idx);
aoqi@0 408 }
aoqi@0 409 virtual int Opcode() const;
aoqi@0 410 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 411 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 412 virtual const Type *bottom_type() const;
aoqi@0 413 virtual bool pinned() const { return true; }
aoqi@0 414 virtual int required_outcnt() const { return _size; }
aoqi@0 415 };
aoqi@0 416
aoqi@0 417 //------------------------------JumpNode---------------------------------------
aoqi@0 418 // Indirect branch. Uses PCTable above to implement a switch statement.
aoqi@0 419 // It emits as a table load and local branch.
aoqi@0 420 class JumpNode : public PCTableNode {
aoqi@0 421 public:
aoqi@0 422 JumpNode( Node* control, Node* switch_val, uint size) : PCTableNode(control, switch_val, size) {
aoqi@0 423 init_class_id(Class_Jump);
aoqi@0 424 }
aoqi@0 425 virtual int Opcode() const;
aoqi@0 426 virtual const RegMask& out_RegMask() const;
aoqi@0 427 virtual const Node* is_block_proj() const { return this; }
aoqi@0 428 };
aoqi@0 429
aoqi@0 430 class JumpProjNode : public JProjNode {
aoqi@0 431 virtual uint hash() const;
aoqi@0 432 virtual uint cmp( const Node &n ) const;
aoqi@0 433 virtual uint size_of() const { return sizeof(*this); }
aoqi@0 434
aoqi@0 435 private:
aoqi@0 436 const int _dest_bci;
aoqi@0 437 const uint _proj_no;
aoqi@0 438 const int _switch_val;
aoqi@0 439 public:
aoqi@0 440 JumpProjNode(Node* jumpnode, uint proj_no, int dest_bci, int switch_val)
aoqi@0 441 : JProjNode(jumpnode, proj_no), _dest_bci(dest_bci), _proj_no(proj_no), _switch_val(switch_val) {
aoqi@0 442 init_class_id(Class_JumpProj);
aoqi@0 443 }
aoqi@0 444
aoqi@0 445 virtual int Opcode() const;
aoqi@0 446 virtual const Type* bottom_type() const { return Type::CONTROL; }
aoqi@0 447 int dest_bci() const { return _dest_bci; }
aoqi@0 448 int switch_val() const { return _switch_val; }
aoqi@0 449 uint proj_no() const { return _proj_no; }
aoqi@0 450 #ifndef PRODUCT
aoqi@0 451 virtual void dump_spec(outputStream *st) const;
aoqi@0 452 #endif
aoqi@0 453 };
aoqi@0 454
aoqi@0 455 //------------------------------CatchNode--------------------------------------
aoqi@0 456 // Helper node to fork exceptions. "Catch" catches any exceptions thrown by
aoqi@0 457 // a just-prior call. Looks like a PCTableNode but emits no code - just the
aoqi@0 458 // table. The table lookup and branch is implemented by RethrowNode.
aoqi@0 459 class CatchNode : public PCTableNode {
aoqi@0 460 public:
aoqi@0 461 CatchNode( Node *ctrl, Node *idx, uint size ) : PCTableNode(ctrl,idx,size){
aoqi@0 462 init_class_id(Class_Catch);
aoqi@0 463 }
aoqi@0 464 virtual int Opcode() const;
aoqi@0 465 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 466 };
aoqi@0 467
aoqi@0 468 // CatchProjNode controls which exception handler is targetted after a call.
aoqi@0 469 // It is passed in the bci of the target handler, or no_handler_bci in case
aoqi@0 470 // the projection doesn't lead to an exception handler.
aoqi@0 471 class CatchProjNode : public CProjNode {
aoqi@0 472 virtual uint hash() const;
aoqi@0 473 virtual uint cmp( const Node &n ) const;
aoqi@0 474 virtual uint size_of() const { return sizeof(*this); }
aoqi@0 475
aoqi@0 476 private:
aoqi@0 477 const int _handler_bci;
aoqi@0 478
aoqi@0 479 public:
aoqi@0 480 enum {
aoqi@0 481 fall_through_index = 0, // the fall through projection index
aoqi@0 482 catch_all_index = 1, // the projection index for catch-alls
aoqi@0 483 no_handler_bci = -1 // the bci for fall through or catch-all projs
aoqi@0 484 };
aoqi@0 485
aoqi@0 486 CatchProjNode(Node* catchnode, uint proj_no, int handler_bci)
aoqi@0 487 : CProjNode(catchnode, proj_no), _handler_bci(handler_bci) {
aoqi@0 488 init_class_id(Class_CatchProj);
aoqi@0 489 assert(proj_no != fall_through_index || handler_bci < 0, "fall through case must have bci < 0");
aoqi@0 490 }
aoqi@0 491
aoqi@0 492 virtual int Opcode() const;
aoqi@0 493 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 494 virtual const Type *bottom_type() const { return Type::CONTROL; }
aoqi@0 495 int handler_bci() const { return _handler_bci; }
aoqi@0 496 bool is_handler_proj() const { return _handler_bci >= 0; }
aoqi@0 497 #ifndef PRODUCT
aoqi@0 498 virtual void dump_spec(outputStream *st) const;
aoqi@0 499 #endif
aoqi@0 500 };
aoqi@0 501
aoqi@0 502
aoqi@0 503 //---------------------------------CreateExNode--------------------------------
aoqi@0 504 // Helper node to create the exception coming back from a call
aoqi@0 505 class CreateExNode : public TypeNode {
aoqi@0 506 public:
aoqi@0 507 CreateExNode(const Type* t, Node* control, Node* i_o) : TypeNode(t, 2) {
aoqi@0 508 init_req(0, control);
aoqi@0 509 init_req(1, i_o);
aoqi@0 510 }
aoqi@0 511 virtual int Opcode() const;
aoqi@0 512 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 513 virtual bool pinned() const { return true; }
aoqi@0 514 uint match_edge(uint idx) const { return 0; }
aoqi@0 515 virtual uint ideal_reg() const { return Op_RegP; }
aoqi@0 516 };
aoqi@0 517
aoqi@0 518 //------------------------------NeverBranchNode-------------------------------
aoqi@0 519 // The never-taken branch. Used to give the appearance of exiting infinite
aoqi@0 520 // loops to those algorithms that like all paths to be reachable. Encodes
aoqi@0 521 // empty.
aoqi@0 522 class NeverBranchNode : public MultiBranchNode {
aoqi@0 523 public:
aoqi@0 524 NeverBranchNode( Node *ctrl ) : MultiBranchNode(1) { init_req(0,ctrl); }
aoqi@0 525 virtual int Opcode() const;
aoqi@0 526 virtual bool pinned() const { return true; };
aoqi@0 527 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
aoqi@0 528 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 529 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 530 virtual int required_outcnt() const { return 2; }
aoqi@0 531 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { }
aoqi@0 532 virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
aoqi@0 533 #ifndef PRODUCT
aoqi@0 534 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
aoqi@0 535 #endif
aoqi@0 536 };
aoqi@0 537
aoqi@0 538 #endif // SHARE_VM_OPTO_CFGNODE_HPP

mercurial