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