annotate src/share/vm/opto/memnode.hpp @ 5121:2a667d6ef59e

8027840: C2 allows safepoint checks to leak into G1 pre-barriers Summary: Make all raw loads strictly respect control dependencies, make sure RCE doesn't move raw loads, add verification of G1 pre-barriers. Reviewed-by: kvn, roland
author iveresov
date Tue, 05 Nov 2013 01:57:18 -0800
parents be30099fbdec
children de5e8c8a9b87
rev   line source
duke@0 1 /*
trims@2410 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1563 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1563 20 * or visit www.oracle.com if you need additional information or have any
trims@1563 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1992 25 #ifndef SHARE_VM_OPTO_MEMNODE_HPP
stefank@1992 26 #define SHARE_VM_OPTO_MEMNODE_HPP
stefank@1992 27
stefank@1992 28 #include "opto/multnode.hpp"
stefank@1992 29 #include "opto/node.hpp"
stefank@1992 30 #include "opto/opcodes.hpp"
stefank@1992 31 #include "opto/type.hpp"
stefank@1992 32
duke@0 33 // Portions of code courtesy of Clifford Click
duke@0 34
duke@0 35 class MultiNode;
duke@0 36 class PhaseCCP;
duke@0 37 class PhaseTransform;
duke@0 38
duke@0 39 //------------------------------MemNode----------------------------------------
duke@0 40 // Load or Store, possibly throwing a NULL pointer exception
duke@0 41 class MemNode : public Node {
duke@0 42 protected:
duke@0 43 #ifdef ASSERT
duke@0 44 const TypePtr* _adr_type; // What kind of memory is being addressed?
duke@0 45 #endif
duke@0 46 virtual uint size_of() const; // Size is bigger (ASSERT only)
duke@0 47 public:
duke@0 48 enum { Control, // When is it safe to do this load?
duke@0 49 Memory, // Chunk of memory is being loaded from
duke@0 50 Address, // Actually address, derived from base
duke@0 51 ValueIn, // Value to store
duke@0 52 OopStore // Preceeding oop store, only in StoreCM
duke@0 53 };
duke@0 54 protected:
duke@0 55 MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at )
duke@0 56 : Node(c0,c1,c2 ) {
duke@0 57 init_class_id(Class_Mem);
duke@0 58 debug_only(_adr_type=at; adr_type();)
duke@0 59 }
duke@0 60 MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3 )
duke@0 61 : Node(c0,c1,c2,c3) {
duke@0 62 init_class_id(Class_Mem);
duke@0 63 debug_only(_adr_type=at; adr_type();)
duke@0 64 }
duke@0 65 MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3, Node *c4)
duke@0 66 : Node(c0,c1,c2,c3,c4) {
duke@0 67 init_class_id(Class_Mem);
duke@0 68 debug_only(_adr_type=at; adr_type();)
duke@0 69 }
duke@0 70
kvn@33 71 public:
duke@0 72 // Helpers for the optimizer. Documented in memnode.cpp.
duke@0 73 static bool detect_ptr_independence(Node* p1, AllocateNode* a1,
duke@0 74 Node* p2, AllocateNode* a2,
duke@0 75 PhaseTransform* phase);
duke@0 76 static bool adr_phi_is_loop_invariant(Node* adr_phi, Node* cast);
duke@0 77
kvn@74 78 static Node *optimize_simple_memory_chain(Node *mchain, const TypePtr *t_adr, PhaseGVN *phase);
kvn@74 79 static Node *optimize_memory_chain(Node *mchain, const TypePtr *t_adr, PhaseGVN *phase);
duke@0 80 // This one should probably be a phase-specific function:
kvn@85 81 static bool all_controls_dominate(Node* dom, Node* sub);
duke@0 82
kvn@163 83 // Find any cast-away of null-ness and keep its control.
kvn@163 84 static Node *Ideal_common_DU_postCCP( PhaseCCP *ccp, Node* n, Node* adr );
duke@0 85 virtual Node *Ideal_DU_postCCP( PhaseCCP *ccp );
duke@0 86
duke@0 87 virtual const class TypePtr *adr_type() const; // returns bottom_type of address
duke@0 88
duke@0 89 // Shared code for Ideal methods:
duke@0 90 Node *Ideal_common(PhaseGVN *phase, bool can_reshape); // Return -1 for short-circuit NULL.
duke@0 91
duke@0 92 // Helper function for adr_type() implementations.
duke@0 93 static const TypePtr* calculate_adr_type(const Type* t, const TypePtr* cross_check = NULL);
duke@0 94
duke@0 95 // Raw access function, to allow copying of adr_type efficiently in
duke@0 96 // product builds and retain the debug info for debug builds.
duke@0 97 const TypePtr *raw_adr_type() const {
duke@0 98 #ifdef ASSERT
duke@0 99 return _adr_type;
duke@0 100 #else
duke@0 101 return 0;
duke@0 102 #endif
duke@0 103 }
duke@0 104
duke@0 105 // Map a load or store opcode to its corresponding store opcode.
duke@0 106 // (Return -1 if unknown.)
duke@0 107 virtual int store_Opcode() const { return -1; }
duke@0 108
duke@0 109 // What is the type of the value in memory? (T_VOID mean "unspecified".)
duke@0 110 virtual BasicType memory_type() const = 0;
kvn@29 111 virtual int memory_size() const {
kvn@29 112 #ifdef ASSERT
kvn@29 113 return type2aelembytes(memory_type(), true);
kvn@29 114 #else
kvn@29 115 return type2aelembytes(memory_type());
kvn@29 116 #endif
kvn@29 117 }
duke@0 118
duke@0 119 // Search through memory states which precede this node (load or store).
duke@0 120 // Look for an exact match for the address, with no intervening
duke@0 121 // aliased stores.
duke@0 122 Node* find_previous_store(PhaseTransform* phase);
duke@0 123
duke@0 124 // Can this node (load or store) accurately see a stored value in
duke@0 125 // the given memory state? (The state may or may not be in(Memory).)
duke@0 126 Node* can_see_stored_value(Node* st, PhaseTransform* phase) const;
duke@0 127
duke@0 128 #ifndef PRODUCT
duke@0 129 static void dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st);
duke@0 130 virtual void dump_spec(outputStream *st) const;
duke@0 131 #endif
duke@0 132 };
duke@0 133
duke@0 134 //------------------------------LoadNode---------------------------------------
duke@0 135 // Load value; requires Memory and Address
duke@0 136 class LoadNode : public MemNode {
duke@0 137 protected:
duke@0 138 virtual uint cmp( const Node &n ) const;
duke@0 139 virtual uint size_of() const; // Size is bigger
duke@0 140 const Type* const _type; // What kind of value is loaded?
duke@0 141 public:
duke@0 142
duke@0 143 LoadNode( Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *rt )
duke@0 144 : MemNode(c,mem,adr,at), _type(rt) {
duke@0 145 init_class_id(Class_Load);
duke@0 146 }
duke@0 147
duke@0 148 // Polymorphic factory method:
coleenp@113 149 static Node* make( PhaseGVN& gvn, Node *c, Node *mem, Node *adr,
coleenp@113 150 const TypePtr* at, const Type *rt, BasicType bt );
duke@0 151
duke@0 152 virtual uint hash() const; // Check the type
duke@0 153
duke@0 154 // Handle algebraic identities here. If we have an identity, return the Node
duke@0 155 // we are equivalent to. We look for Load of a Store.
duke@0 156 virtual Node *Identity( PhaseTransform *phase );
duke@0 157
duke@0 158 // If the load is from Field memory and the pointer is non-null, we can
duke@0 159 // zero out the control input.
duke@0 160 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 161
kvn@163 162 // Split instance field load through Phi.
kvn@163 163 Node* split_through_phi(PhaseGVN *phase);
kvn@163 164
never@17 165 // Recover original value from boxed values
never@17 166 Node *eliminate_autobox(PhaseGVN *phase);
never@17 167
duke@0 168 // Compute a new Type for this node. Basically we just do the pre-check,
duke@0 169 // then call the virtual add() to set the type.
duke@0 170 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 171
kvn@164 172 // Common methods for LoadKlass and LoadNKlass nodes.
kvn@164 173 const Type *klass_value_common( PhaseTransform *phase ) const;
kvn@164 174 Node *klass_identity_common( PhaseTransform *phase );
kvn@164 175
duke@0 176 virtual uint ideal_reg() const;
duke@0 177 virtual const Type *bottom_type() const;
duke@0 178 // Following method is copied from TypeNode:
duke@0 179 void set_type(const Type* t) {
duke@0 180 assert(t != NULL, "sanity");
duke@0 181 debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH);
duke@0 182 *(const Type**)&_type = t; // cast away const-ness
duke@0 183 // If this node is in the hash table, make sure it doesn't need a rehash.
duke@0 184 assert(check_hash == NO_HASH || check_hash == hash(), "type change must preserve hash code");
duke@0 185 }
duke@0 186 const Type* type() const { assert(_type != NULL, "sanity"); return _type; };
duke@0 187
duke@0 188 // Do not match memory edge
duke@0 189 virtual uint match_edge(uint idx) const;
duke@0 190
duke@0 191 // Map a load opcode to its corresponding store opcode.
duke@0 192 virtual int store_Opcode() const = 0;
duke@0 193
kvn@64 194 // Check if the load's memory input is a Phi node with the same control.
kvn@64 195 bool is_instance_field_load_with_local_phi(Node* ctrl);
kvn@64 196
duke@0 197 #ifndef PRODUCT
duke@0 198 virtual void dump_spec(outputStream *st) const;
duke@0 199 #endif
kvn@1624 200 #ifdef ASSERT
kvn@1624 201 // Helper function to allow a raw load without control edge for some cases
kvn@1624 202 static bool is_immutable_value(Node* adr);
kvn@1624 203 #endif
duke@0 204 protected:
duke@0 205 const Type* load_array_final_field(const TypeKlassPtr *tkls,
duke@0 206 ciKlass* klass) const;
iveresov@5121 207 // depends_only_on_test is almost always true, and needs to be almost always
iveresov@5121 208 // true to enable key hoisting & commoning optimizations. However, for the
iveresov@5121 209 // special case of RawPtr loads from TLS top & end, and other loads performed by
iveresov@5121 210 // GC barriers, the control edge carries the dependence preventing hoisting past
iveresov@5121 211 // a Safepoint instead of the memory edge. (An unfortunate consequence of having
iveresov@5121 212 // Safepoints not set Raw Memory; itself an unfortunate consequence of having Nodes
iveresov@5121 213 // which produce results (new raw memory state) inside of loops preventing all
iveresov@5121 214 // manner of other optimizations). Basically, it's ugly but so is the alternative.
iveresov@5121 215 // See comment in macro.cpp, around line 125 expand_allocate_common().
iveresov@5121 216 virtual bool depends_only_on_test() const { return adr_type() != TypeRawPtr::BOTTOM; }
iveresov@5121 217
duke@0 218 };
duke@0 219
duke@0 220 //------------------------------LoadBNode--------------------------------------
duke@0 221 // Load a byte (8bits signed) from memory
duke@0 222 class LoadBNode : public LoadNode {
duke@0 223 public:
duke@0 224 LoadBNode( Node *c, Node *mem, Node *adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE )
duke@0 225 : LoadNode(c,mem,adr,at,ti) {}
duke@0 226 virtual int Opcode() const;
duke@0 227 virtual uint ideal_reg() const { return Op_RegI; }
duke@0 228 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
kvn@3311 229 virtual const Type *Value(PhaseTransform *phase) const;
duke@0 230 virtual int store_Opcode() const { return Op_StoreB; }
duke@0 231 virtual BasicType memory_type() const { return T_BYTE; }
duke@0 232 };
duke@0 233
twisti@662 234 //------------------------------LoadUBNode-------------------------------------
twisti@662 235 // Load a unsigned byte (8bits unsigned) from memory
twisti@662 236 class LoadUBNode : public LoadNode {
twisti@662 237 public:
twisti@662 238 LoadUBNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt* ti = TypeInt::UBYTE )
twisti@662 239 : LoadNode(c, mem, adr, at, ti) {}
twisti@662 240 virtual int Opcode() const;
twisti@662 241 virtual uint ideal_reg() const { return Op_RegI; }
twisti@662 242 virtual Node* Ideal(PhaseGVN *phase, bool can_reshape);
kvn@3311 243 virtual const Type *Value(PhaseTransform *phase) const;
twisti@662 244 virtual int store_Opcode() const { return Op_StoreB; }
twisti@662 245 virtual BasicType memory_type() const { return T_BYTE; }
twisti@662 246 };
twisti@662 247
twisti@590 248 //------------------------------LoadUSNode-------------------------------------
twisti@590 249 // Load an unsigned short/char (16bits unsigned) from memory
twisti@590 250 class LoadUSNode : public LoadNode {
duke@0 251 public:
twisti@590 252 LoadUSNode( Node *c, Node *mem, Node *adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR )
duke@0 253 : LoadNode(c,mem,adr,at,ti) {}
duke@0 254 virtual int Opcode() const;
duke@0 255 virtual uint ideal_reg() const { return Op_RegI; }
duke@0 256 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
kvn@3311 257 virtual const Type *Value(PhaseTransform *phase) const;
duke@0 258 virtual int store_Opcode() const { return Op_StoreC; }
duke@0 259 virtual BasicType memory_type() const { return T_CHAR; }
duke@0 260 };
duke@0 261
kvn@3311 262 //------------------------------LoadSNode--------------------------------------
kvn@3311 263 // Load a short (16bits signed) from memory
kvn@3311 264 class LoadSNode : public LoadNode {
kvn@3311 265 public:
kvn@3311 266 LoadSNode( Node *c, Node *mem, Node *adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT )
kvn@3311 267 : LoadNode(c,mem,adr,at,ti) {}
kvn@3311 268 virtual int Opcode() const;
kvn@3311 269 virtual uint ideal_reg() const { return Op_RegI; }
kvn@3311 270 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
kvn@3311 271 virtual const Type *Value(PhaseTransform *phase) const;
kvn@3311 272 virtual int store_Opcode() const { return Op_StoreC; }
kvn@3311 273 virtual BasicType memory_type() const { return T_SHORT; }
kvn@3311 274 };
kvn@3311 275
duke@0 276 //------------------------------LoadINode--------------------------------------
duke@0 277 // Load an integer from memory
duke@0 278 class LoadINode : public LoadNode {
duke@0 279 public:
duke@0 280 LoadINode( Node *c, Node *mem, Node *adr, const TypePtr* at, const TypeInt *ti = TypeInt::INT )
duke@0 281 : LoadNode(c,mem,adr,at,ti) {}
duke@0 282 virtual int Opcode() const;
duke@0 283 virtual uint ideal_reg() const { return Op_RegI; }
duke@0 284 virtual int store_Opcode() const { return Op_StoreI; }
duke@0 285 virtual BasicType memory_type() const { return T_INT; }
duke@0 286 };
duke@0 287
duke@0 288 //------------------------------LoadRangeNode----------------------------------
duke@0 289 // Load an array length from the array
duke@0 290 class LoadRangeNode : public LoadINode {
duke@0 291 public:
duke@0 292 LoadRangeNode( Node *c, Node *mem, Node *adr, const TypeInt *ti = TypeInt::POS )
duke@0 293 : LoadINode(c,mem,adr,TypeAryPtr::RANGE,ti) {}
duke@0 294 virtual int Opcode() const;
duke@0 295 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 296 virtual Node *Identity( PhaseTransform *phase );
rasbold@369 297 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 298 };
duke@0 299
duke@0 300 //------------------------------LoadLNode--------------------------------------
duke@0 301 // Load a long from memory
duke@0 302 class LoadLNode : public LoadNode {
duke@0 303 virtual uint hash() const { return LoadNode::hash() + _require_atomic_access; }
duke@0 304 virtual uint cmp( const Node &n ) const {
duke@0 305 return _require_atomic_access == ((LoadLNode&)n)._require_atomic_access
duke@0 306 && LoadNode::cmp(n);
duke@0 307 }
duke@0 308 virtual uint size_of() const { return sizeof(*this); }
duke@0 309 const bool _require_atomic_access; // is piecewise load forbidden?
duke@0 310
duke@0 311 public:
duke@0 312 LoadLNode( Node *c, Node *mem, Node *adr, const TypePtr* at,
duke@0 313 const TypeLong *tl = TypeLong::LONG,
duke@0 314 bool require_atomic_access = false )
duke@0 315 : LoadNode(c,mem,adr,at,tl)
duke@0 316 , _require_atomic_access(require_atomic_access)
duke@0 317 {}
duke@0 318 virtual int Opcode() const;
duke@0 319 virtual uint ideal_reg() const { return Op_RegL; }
duke@0 320 virtual int store_Opcode() const { return Op_StoreL; }
duke@0 321 virtual BasicType memory_type() const { return T_LONG; }
duke@0 322 bool require_atomic_access() { return _require_atomic_access; }
duke@0 323 static LoadLNode* make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt);
duke@0 324 #ifndef PRODUCT
duke@0 325 virtual void dump_spec(outputStream *st) const {
duke@0 326 LoadNode::dump_spec(st);
duke@0 327 if (_require_atomic_access) st->print(" Atomic!");
duke@0 328 }
duke@0 329 #endif
duke@0 330 };
duke@0 331
duke@0 332 //------------------------------LoadL_unalignedNode----------------------------
duke@0 333 // Load a long from unaligned memory
duke@0 334 class LoadL_unalignedNode : public LoadLNode {
duke@0 335 public:
duke@0 336 LoadL_unalignedNode( Node *c, Node *mem, Node *adr, const TypePtr* at )
duke@0 337 : LoadLNode(c,mem,adr,at) {}
duke@0 338 virtual int Opcode() const;
duke@0 339 };
duke@0 340
duke@0 341 //------------------------------LoadFNode--------------------------------------
duke@0 342 // Load a float (64 bits) from memory
duke@0 343 class LoadFNode : public LoadNode {
duke@0 344 public:
duke@0 345 LoadFNode( Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *t = Type::FLOAT )
duke@0 346 : LoadNode(c,mem,adr,at,t) {}
duke@0 347 virtual int Opcode() const;
duke@0 348 virtual uint ideal_reg() const { return Op_RegF; }
duke@0 349 virtual int store_Opcode() const { return Op_StoreF; }
duke@0 350 virtual BasicType memory_type() const { return T_FLOAT; }
duke@0 351 };
duke@0 352
duke@0 353 //------------------------------LoadDNode--------------------------------------
duke@0 354 // Load a double (64 bits) from memory
duke@0 355 class LoadDNode : public LoadNode {
duke@0 356 public:
duke@0 357 LoadDNode( Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *t = Type::DOUBLE )
duke@0 358 : LoadNode(c,mem,adr,at,t) {}
duke@0 359 virtual int Opcode() const;
duke@0 360 virtual uint ideal_reg() const { return Op_RegD; }
duke@0 361 virtual int store_Opcode() const { return Op_StoreD; }
duke@0 362 virtual BasicType memory_type() const { return T_DOUBLE; }
duke@0 363 };
duke@0 364
duke@0 365 //------------------------------LoadD_unalignedNode----------------------------
duke@0 366 // Load a double from unaligned memory
duke@0 367 class LoadD_unalignedNode : public LoadDNode {
duke@0 368 public:
duke@0 369 LoadD_unalignedNode( Node *c, Node *mem, Node *adr, const TypePtr* at )
duke@0 370 : LoadDNode(c,mem,adr,at) {}
duke@0 371 virtual int Opcode() const;
duke@0 372 };
duke@0 373
duke@0 374 //------------------------------LoadPNode--------------------------------------
duke@0 375 // Load a pointer from memory (either object or array)
duke@0 376 class LoadPNode : public LoadNode {
duke@0 377 public:
duke@0 378 LoadPNode( Node *c, Node *mem, Node *adr, const TypePtr *at, const TypePtr* t )
duke@0 379 : LoadNode(c,mem,adr,at,t) {}
duke@0 380 virtual int Opcode() const;
duke@0 381 virtual uint ideal_reg() const { return Op_RegP; }
duke@0 382 virtual int store_Opcode() const { return Op_StoreP; }
duke@0 383 virtual BasicType memory_type() const { return T_ADDRESS; }
duke@0 384 };
duke@0 385
coleenp@113 386
coleenp@113 387 //------------------------------LoadNNode--------------------------------------
coleenp@113 388 // Load a narrow oop from memory (either object or array)
coleenp@113 389 class LoadNNode : public LoadNode {
coleenp@113 390 public:
coleenp@113 391 LoadNNode( Node *c, Node *mem, Node *adr, const TypePtr *at, const Type* t )
coleenp@113 392 : LoadNode(c,mem,adr,at,t) {}
coleenp@113 393 virtual int Opcode() const;
coleenp@113 394 virtual uint ideal_reg() const { return Op_RegN; }
coleenp@113 395 virtual int store_Opcode() const { return Op_StoreN; }
coleenp@113 396 virtual BasicType memory_type() const { return T_NARROWOOP; }
coleenp@113 397 };
coleenp@113 398
duke@0 399 //------------------------------LoadKlassNode----------------------------------
duke@0 400 // Load a Klass from an object
duke@0 401 class LoadKlassNode : public LoadPNode {
duke@0 402 public:
kvn@164 403 LoadKlassNode( Node *c, Node *mem, Node *adr, const TypePtr *at, const TypeKlassPtr *tk )
duke@0 404 : LoadPNode(c,mem,adr,at,tk) {}
duke@0 405 virtual int Opcode() const;
duke@0 406 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 407 virtual Node *Identity( PhaseTransform *phase );
duke@0 408 virtual bool depends_only_on_test() const { return true; }
kvn@164 409
kvn@164 410 // Polymorphic factory method:
kvn@164 411 static Node* make( PhaseGVN& gvn, Node *mem, Node *adr, const TypePtr* at,
kvn@164 412 const TypeKlassPtr *tk = TypeKlassPtr::OBJECT );
duke@0 413 };
duke@0 414
kvn@164 415 //------------------------------LoadNKlassNode---------------------------------
kvn@164 416 // Load a narrow Klass from an object.
kvn@164 417 class LoadNKlassNode : public LoadNNode {
kvn@164 418 public:
kvn@164 419 LoadNKlassNode( Node *c, Node *mem, Node *adr, const TypePtr *at, const TypeNarrowOop *tk )
kvn@164 420 : LoadNNode(c,mem,adr,at,tk) {}
kvn@164 421 virtual int Opcode() const;
kvn@164 422 virtual uint ideal_reg() const { return Op_RegN; }
kvn@164 423 virtual int store_Opcode() const { return Op_StoreN; }
kvn@164 424 virtual BasicType memory_type() const { return T_NARROWOOP; }
kvn@164 425
kvn@164 426 virtual const Type *Value( PhaseTransform *phase ) const;
kvn@164 427 virtual Node *Identity( PhaseTransform *phase );
kvn@164 428 virtual bool depends_only_on_test() const { return true; }
kvn@164 429 };
kvn@164 430
kvn@164 431
duke@0 432 //------------------------------StoreNode--------------------------------------
duke@0 433 // Store value; requires Store, Address and Value
duke@0 434 class StoreNode : public MemNode {
duke@0 435 protected:
duke@0 436 virtual uint cmp( const Node &n ) const;
duke@0 437 virtual bool depends_only_on_test() const { return false; }
duke@0 438
duke@0 439 Node *Ideal_masked_input (PhaseGVN *phase, uint mask);
duke@0 440 Node *Ideal_sign_extended_input(PhaseGVN *phase, int num_bits);
duke@0 441
duke@0 442 public:
duke@0 443 StoreNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val )
duke@0 444 : MemNode(c,mem,adr,at,val) {
duke@0 445 init_class_id(Class_Store);
duke@0 446 }
duke@0 447 StoreNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val, Node *oop_store )
duke@0 448 : MemNode(c,mem,adr,at,val,oop_store) {
duke@0 449 init_class_id(Class_Store);
duke@0 450 }
duke@0 451
duke@0 452 // Polymorphic factory method:
coleenp@113 453 static StoreNode* make( PhaseGVN& gvn, Node *c, Node *mem, Node *adr,
coleenp@113 454 const TypePtr* at, Node *val, BasicType bt );
duke@0 455
duke@0 456 virtual uint hash() const; // Check the type
duke@0 457
duke@0 458 // If the store is to Field memory and the pointer is non-null, we can
duke@0 459 // zero out the control input.
duke@0 460 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 461
duke@0 462 // Compute a new Type for this node. Basically we just do the pre-check,
duke@0 463 // then call the virtual add() to set the type.
duke@0 464 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 465
duke@0 466 // Check for identity function on memory (Load then Store at same address)
duke@0 467 virtual Node *Identity( PhaseTransform *phase );
duke@0 468
duke@0 469 // Do not match memory edge
duke@0 470 virtual uint match_edge(uint idx) const;
duke@0 471
duke@0 472 virtual const Type *bottom_type() const; // returns Type::MEMORY
duke@0 473
duke@0 474 // Map a store opcode to its corresponding own opcode, trivially.
duke@0 475 virtual int store_Opcode() const { return Opcode(); }
duke@0 476
duke@0 477 // have all possible loads of the value stored been optimized away?
duke@0 478 bool value_never_loaded(PhaseTransform *phase) const;
duke@0 479 };
duke@0 480
duke@0 481 //------------------------------StoreBNode-------------------------------------
duke@0 482 // Store byte to memory
duke@0 483 class StoreBNode : public StoreNode {
duke@0 484 public:
duke@0 485 StoreBNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
duke@0 486 virtual int Opcode() const;
duke@0 487 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 488 virtual BasicType memory_type() const { return T_BYTE; }
duke@0 489 };
duke@0 490
duke@0 491 //------------------------------StoreCNode-------------------------------------
duke@0 492 // Store char/short to memory
duke@0 493 class StoreCNode : public StoreNode {
duke@0 494 public:
duke@0 495 StoreCNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
duke@0 496 virtual int Opcode() const;
duke@0 497 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 498 virtual BasicType memory_type() const { return T_CHAR; }
duke@0 499 };
duke@0 500
duke@0 501 //------------------------------StoreINode-------------------------------------
duke@0 502 // Store int to memory
duke@0 503 class StoreINode : public StoreNode {
duke@0 504 public:
duke@0 505 StoreINode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
duke@0 506 virtual int Opcode() const;
duke@0 507 virtual BasicType memory_type() const { return T_INT; }
duke@0 508 };
duke@0 509
duke@0 510 //------------------------------StoreLNode-------------------------------------
duke@0 511 // Store long to memory
duke@0 512 class StoreLNode : public StoreNode {
duke@0 513 virtual uint hash() const { return StoreNode::hash() + _require_atomic_access; }
duke@0 514 virtual uint cmp( const Node &n ) const {
duke@0 515 return _require_atomic_access == ((StoreLNode&)n)._require_atomic_access
duke@0 516 && StoreNode::cmp(n);
duke@0 517 }
duke@0 518 virtual uint size_of() const { return sizeof(*this); }
duke@0 519 const bool _require_atomic_access; // is piecewise store forbidden?
duke@0 520
duke@0 521 public:
duke@0 522 StoreLNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val,
duke@0 523 bool require_atomic_access = false )
duke@0 524 : StoreNode(c,mem,adr,at,val)
duke@0 525 , _require_atomic_access(require_atomic_access)
duke@0 526 {}
duke@0 527 virtual int Opcode() const;
duke@0 528 virtual BasicType memory_type() const { return T_LONG; }
duke@0 529 bool require_atomic_access() { return _require_atomic_access; }
duke@0 530 static StoreLNode* make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val);
duke@0 531 #ifndef PRODUCT
duke@0 532 virtual void dump_spec(outputStream *st) const {
duke@0 533 StoreNode::dump_spec(st);
duke@0 534 if (_require_atomic_access) st->print(" Atomic!");
duke@0 535 }
duke@0 536 #endif
duke@0 537 };
duke@0 538
duke@0 539 //------------------------------StoreFNode-------------------------------------
duke@0 540 // Store float to memory
duke@0 541 class StoreFNode : public StoreNode {
duke@0 542 public:
duke@0 543 StoreFNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
duke@0 544 virtual int Opcode() const;
duke@0 545 virtual BasicType memory_type() const { return T_FLOAT; }
duke@0 546 };
duke@0 547
duke@0 548 //------------------------------StoreDNode-------------------------------------
duke@0 549 // Store double to memory
duke@0 550 class StoreDNode : public StoreNode {
duke@0 551 public:
duke@0 552 StoreDNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
duke@0 553 virtual int Opcode() const;
duke@0 554 virtual BasicType memory_type() const { return T_DOUBLE; }
duke@0 555 };
duke@0 556
duke@0 557 //------------------------------StorePNode-------------------------------------
duke@0 558 // Store pointer to memory
duke@0 559 class StorePNode : public StoreNode {
duke@0 560 public:
duke@0 561 StorePNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
duke@0 562 virtual int Opcode() const;
duke@0 563 virtual BasicType memory_type() const { return T_ADDRESS; }
duke@0 564 };
duke@0 565
coleenp@113 566 //------------------------------StoreNNode-------------------------------------
coleenp@113 567 // Store narrow oop to memory
coleenp@113 568 class StoreNNode : public StoreNode {
coleenp@113 569 public:
coleenp@113 570 StoreNNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val ) : StoreNode(c,mem,adr,at,val) {}
coleenp@113 571 virtual int Opcode() const;
coleenp@113 572 virtual BasicType memory_type() const { return T_NARROWOOP; }
coleenp@113 573 };
coleenp@113 574
duke@0 575 //------------------------------StoreCMNode-----------------------------------
duke@0 576 // Store card-mark byte to memory for CM
duke@0 577 // The last StoreCM before a SafePoint must be preserved and occur after its "oop" store
duke@0 578 // Preceeding equivalent StoreCMs may be eliminated.
duke@0 579 class StoreCMNode : public StoreNode {
cfang@1043 580 private:
never@1280 581 virtual uint hash() const { return StoreNode::hash() + _oop_alias_idx; }
never@1280 582 virtual uint cmp( const Node &n ) const {
never@1280 583 return _oop_alias_idx == ((StoreCMNode&)n)._oop_alias_idx
never@1280 584 && StoreNode::cmp(n);
never@1280 585 }
never@1280 586 virtual uint size_of() const { return sizeof(*this); }
cfang@1043 587 int _oop_alias_idx; // The alias_idx of OopStore
never@1280 588
duke@0 589 public:
never@1280 590 StoreCMNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val, Node *oop_store, int oop_alias_idx ) :
never@1280 591 StoreNode(c,mem,adr,at,val,oop_store),
never@1280 592 _oop_alias_idx(oop_alias_idx) {
never@1280 593 assert(_oop_alias_idx >= Compile::AliasIdxRaw ||
never@1280 594 _oop_alias_idx == Compile::AliasIdxBot && Compile::current()->AliasLevel() == 0,
never@1280 595 "bad oop alias idx");
never@1280 596 }
duke@0 597 virtual int Opcode() const;
duke@0 598 virtual Node *Identity( PhaseTransform *phase );
cfang@1043 599 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 600 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 601 virtual BasicType memory_type() const { return T_VOID; } // unspecific
cfang@1043 602 int oop_alias_idx() const { return _oop_alias_idx; }
duke@0 603 };
duke@0 604
duke@0 605 //------------------------------LoadPLockedNode---------------------------------
duke@0 606 // Load-locked a pointer from memory (either object or array).
duke@0 607 // On Sparc & Intel this is implemented as a normal pointer load.
duke@0 608 // On PowerPC and friends it's a real load-locked.
duke@0 609 class LoadPLockedNode : public LoadPNode {
duke@0 610 public:
duke@0 611 LoadPLockedNode( Node *c, Node *mem, Node *adr )
duke@0 612 : LoadPNode(c,mem,adr,TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM) {}
duke@0 613 virtual int Opcode() const;
duke@0 614 virtual int store_Opcode() const { return Op_StorePConditional; }
duke@0 615 virtual bool depends_only_on_test() const { return true; }
duke@0 616 };
duke@0 617
duke@0 618 //------------------------------SCMemProjNode---------------------------------------
duke@0 619 // This class defines a projection of the memory state of a store conditional node.
duke@0 620 // These nodes return a value, but also update memory.
duke@0 621 class SCMemProjNode : public ProjNode {
duke@0 622 public:
duke@0 623 enum {SCMEMPROJCON = (uint)-2};
duke@0 624 SCMemProjNode( Node *src) : ProjNode( src, SCMEMPROJCON) { }
duke@0 625 virtual int Opcode() const;
duke@0 626 virtual bool is_CFG() const { return false; }
duke@0 627 virtual const Type *bottom_type() const {return Type::MEMORY;}
duke@0 628 virtual const TypePtr *adr_type() const { return in(0)->in(MemNode::Memory)->adr_type();}
duke@0 629 virtual uint ideal_reg() const { return 0;} // memory projections don't have a register
duke@0 630 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 631 #ifndef PRODUCT
duke@0 632 virtual void dump_spec(outputStream *st) const {};
duke@0 633 #endif
duke@0 634 };
duke@0 635
duke@0 636 //------------------------------LoadStoreNode---------------------------
kvn@256 637 // Note: is_Mem() method returns 'true' for this class.
duke@0 638 class LoadStoreNode : public Node {
roland@4287 639 private:
roland@4287 640 const Type* const _type; // What kind of value is loaded?
roland@4287 641 const TypePtr* _adr_type; // What kind of memory is being addressed?
roland@4287 642 virtual uint size_of() const; // Size is bigger
roland@4287 643 public:
roland@4287 644 LoadStoreNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at, const Type* rt, uint required );
roland@4287 645 virtual bool depends_only_on_test() const { return false; }
roland@4287 646 virtual uint match_edge(uint idx) const { return idx == MemNode::Address || idx == MemNode::ValueIn; }
roland@4287 647
roland@4287 648 virtual const Type *bottom_type() const { return _type; }
roland@4287 649 virtual uint ideal_reg() const;
roland@4287 650 virtual const class TypePtr *adr_type() const { return _adr_type; } // returns bottom_type of address
roland@4287 651
roland@4287 652 bool result_not_used() const;
roland@4287 653 };
roland@4287 654
roland@4287 655 class LoadStoreConditionalNode : public LoadStoreNode {
duke@0 656 public:
duke@0 657 enum {
duke@0 658 ExpectedIn = MemNode::ValueIn+1 // One more input than MemNode
duke@0 659 };
roland@4287 660 LoadStoreConditionalNode(Node *c, Node *mem, Node *adr, Node *val, Node *ex);
duke@0 661 };
duke@0 662
duke@0 663 //------------------------------StorePConditionalNode---------------------------
duke@0 664 // Conditionally store pointer to memory, if no change since prior
duke@0 665 // load-locked. Sets flags for success or failure of the store.
roland@4287 666 class StorePConditionalNode : public LoadStoreConditionalNode {
duke@0 667 public:
roland@4287 668 StorePConditionalNode( Node *c, Node *mem, Node *adr, Node *val, Node *ll ) : LoadStoreConditionalNode(c, mem, adr, val, ll) { }
duke@0 669 virtual int Opcode() const;
duke@0 670 // Produces flags
duke@0 671 virtual uint ideal_reg() const { return Op_RegFlags; }
duke@0 672 };
duke@0 673
kvn@423 674 //------------------------------StoreIConditionalNode---------------------------
kvn@423 675 // Conditionally store int to memory, if no change since prior
kvn@423 676 // load-locked. Sets flags for success or failure of the store.
roland@4287 677 class StoreIConditionalNode : public LoadStoreConditionalNode {
kvn@423 678 public:
roland@4287 679 StoreIConditionalNode( Node *c, Node *mem, Node *adr, Node *val, Node *ii ) : LoadStoreConditionalNode(c, mem, adr, val, ii) { }
kvn@423 680 virtual int Opcode() const;
kvn@423 681 // Produces flags
kvn@423 682 virtual uint ideal_reg() const { return Op_RegFlags; }
kvn@423 683 };
kvn@423 684
duke@0 685 //------------------------------StoreLConditionalNode---------------------------
duke@0 686 // Conditionally store long to memory, if no change since prior
duke@0 687 // load-locked. Sets flags for success or failure of the store.
roland@4287 688 class StoreLConditionalNode : public LoadStoreConditionalNode {
duke@0 689 public:
roland@4287 690 StoreLConditionalNode( Node *c, Node *mem, Node *adr, Node *val, Node *ll ) : LoadStoreConditionalNode(c, mem, adr, val, ll) { }
duke@0 691 virtual int Opcode() const;
kvn@423 692 // Produces flags
kvn@423 693 virtual uint ideal_reg() const { return Op_RegFlags; }
duke@0 694 };
duke@0 695
duke@0 696
duke@0 697 //------------------------------CompareAndSwapLNode---------------------------
roland@4287 698 class CompareAndSwapLNode : public LoadStoreConditionalNode {
duke@0 699 public:
roland@4287 700 CompareAndSwapLNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex) : LoadStoreConditionalNode(c, mem, adr, val, ex) { }
duke@0 701 virtual int Opcode() const;
duke@0 702 };
duke@0 703
duke@0 704
duke@0 705 //------------------------------CompareAndSwapINode---------------------------
roland@4287 706 class CompareAndSwapINode : public LoadStoreConditionalNode {
duke@0 707 public:
roland@4287 708 CompareAndSwapINode( Node *c, Node *mem, Node *adr, Node *val, Node *ex) : LoadStoreConditionalNode(c, mem, adr, val, ex) { }
duke@0 709 virtual int Opcode() const;
duke@0 710 };
duke@0 711
duke@0 712
duke@0 713 //------------------------------CompareAndSwapPNode---------------------------
roland@4287 714 class CompareAndSwapPNode : public LoadStoreConditionalNode {
duke@0 715 public:
roland@4287 716 CompareAndSwapPNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex) : LoadStoreConditionalNode(c, mem, adr, val, ex) { }
duke@0 717 virtual int Opcode() const;
duke@0 718 };
duke@0 719
coleenp@113 720 //------------------------------CompareAndSwapNNode---------------------------
roland@4287 721 class CompareAndSwapNNode : public LoadStoreConditionalNode {
coleenp@113 722 public:
roland@4287 723 CompareAndSwapNNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex) : LoadStoreConditionalNode(c, mem, adr, val, ex) { }
roland@4287 724 virtual int Opcode() const;
roland@4287 725 };
roland@4287 726
roland@4287 727 //------------------------------GetAndAddINode---------------------------
roland@4287 728 class GetAndAddINode : public LoadStoreNode {
roland@4287 729 public:
roland@4287 730 GetAndAddINode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeInt::INT, 4) { }
roland@4287 731 virtual int Opcode() const;
roland@4287 732 };
roland@4287 733
roland@4287 734 //------------------------------GetAndAddLNode---------------------------
roland@4287 735 class GetAndAddLNode : public LoadStoreNode {
roland@4287 736 public:
roland@4287 737 GetAndAddLNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeLong::LONG, 4) { }
roland@4287 738 virtual int Opcode() const;
roland@4287 739 };
roland@4287 740
roland@4287 741
roland@4287 742 //------------------------------GetAndSetINode---------------------------
roland@4287 743 class GetAndSetINode : public LoadStoreNode {
roland@4287 744 public:
roland@4287 745 GetAndSetINode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeInt::INT, 4) { }
roland@4287 746 virtual int Opcode() const;
roland@4287 747 };
roland@4287 748
roland@4287 749 //------------------------------GetAndSetINode---------------------------
roland@4287 750 class GetAndSetLNode : public LoadStoreNode {
roland@4287 751 public:
roland@4287 752 GetAndSetLNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeLong::LONG, 4) { }
roland@4287 753 virtual int Opcode() const;
roland@4287 754 };
roland@4287 755
roland@4287 756 //------------------------------GetAndSetPNode---------------------------
roland@4287 757 class GetAndSetPNode : public LoadStoreNode {
roland@4287 758 public:
roland@4287 759 GetAndSetPNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at, const Type* t ) : LoadStoreNode(c, mem, adr, val, at, t, 4) { }
roland@4287 760 virtual int Opcode() const;
roland@4287 761 };
roland@4287 762
roland@4287 763 //------------------------------GetAndSetNNode---------------------------
roland@4287 764 class GetAndSetNNode : public LoadStoreNode {
roland@4287 765 public:
roland@4287 766 GetAndSetNNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at, const Type* t ) : LoadStoreNode(c, mem, adr, val, at, t, 4) { }
coleenp@113 767 virtual int Opcode() const;
coleenp@113 768 };
coleenp@113 769
duke@0 770 //------------------------------ClearArray-------------------------------------
duke@0 771 class ClearArrayNode: public Node {
duke@0 772 public:
kvn@1174 773 ClearArrayNode( Node *ctrl, Node *arymem, Node *word_cnt, Node *base )
kvn@1174 774 : Node(ctrl,arymem,word_cnt,base) {
kvn@1174 775 init_class_id(Class_ClearArray);
kvn@1174 776 }
duke@0 777 virtual int Opcode() const;
duke@0 778 virtual const Type *bottom_type() const { return Type::MEMORY; }
duke@0 779 // ClearArray modifies array elements, and so affects only the
duke@0 780 // array memory addressed by the bottom_type of its base address.
duke@0 781 virtual const class TypePtr *adr_type() const;
duke@0 782 virtual Node *Identity( PhaseTransform *phase );
duke@0 783 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 784 virtual uint match_edge(uint idx) const;
duke@0 785
duke@0 786 // Clear the given area of an object or array.
duke@0 787 // The start offset must always be aligned mod BytesPerInt.
duke@0 788 // The end offset must always be aligned mod BytesPerLong.
duke@0 789 // Return the new memory.
duke@0 790 static Node* clear_memory(Node* control, Node* mem, Node* dest,
duke@0 791 intptr_t start_offset,
duke@0 792 intptr_t end_offset,
duke@0 793 PhaseGVN* phase);
duke@0 794 static Node* clear_memory(Node* control, Node* mem, Node* dest,
duke@0 795 intptr_t start_offset,
duke@0 796 Node* end_offset,
duke@0 797 PhaseGVN* phase);
duke@0 798 static Node* clear_memory(Node* control, Node* mem, Node* dest,
duke@0 799 Node* start_offset,
duke@0 800 Node* end_offset,
duke@0 801 PhaseGVN* phase);
kvn@1174 802 // Return allocation input memory edge if it is different instance
kvn@1174 803 // or itself if it is the one we are looking for.
kvn@1174 804 static bool step_through(Node** np, uint instance_id, PhaseTransform* phase);
duke@0 805 };
duke@0 806
kvn@2394 807 //------------------------------StrIntrinsic-------------------------------
kvn@2394 808 // Base class for Ideal nodes used in String instrinsic code.
kvn@2394 809 class StrIntrinsicNode: public Node {
duke@0 810 public:
kvn@2394 811 StrIntrinsicNode(Node* control, Node* char_array_mem,
kvn@2394 812 Node* s1, Node* c1, Node* s2, Node* c2):
kvn@2394 813 Node(control, char_array_mem, s1, c1, s2, c2) {
kvn@2394 814 }
kvn@2394 815
kvn@2394 816 StrIntrinsicNode(Node* control, Node* char_array_mem,
kvn@2394 817 Node* s1, Node* s2, Node* c):
kvn@2394 818 Node(control, char_array_mem, s1, s2, c) {
kvn@2394 819 }
kvn@2394 820
kvn@2394 821 StrIntrinsicNode(Node* control, Node* char_array_mem,
kvn@2394 822 Node* s1, Node* s2):
kvn@2394 823 Node(control, char_array_mem, s1, s2) {
kvn@2394 824 }
kvn@2394 825
duke@0 826 virtual bool depends_only_on_test() const { return false; }
kvn@1044 827 virtual const TypePtr* adr_type() const { return TypeAryPtr::CHARS; }
duke@0 828 virtual uint match_edge(uint idx) const;
duke@0 829 virtual uint ideal_reg() const { return Op_RegI; }
duke@0 830 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
kvn@3171 831 virtual const Type *Value(PhaseTransform *phase) const;
duke@0 832 };
duke@0 833
kvn@2394 834 //------------------------------StrComp-------------------------------------
kvn@2394 835 class StrCompNode: public StrIntrinsicNode {
kvn@2394 836 public:
kvn@2394 837 StrCompNode(Node* control, Node* char_array_mem,
kvn@2394 838 Node* s1, Node* c1, Node* s2, Node* c2):
kvn@2394 839 StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {};
kvn@2394 840 virtual int Opcode() const;
kvn@2394 841 virtual const Type* bottom_type() const { return TypeInt::INT; }
kvn@2394 842 };
kvn@2394 843
cfang@719 844 //------------------------------StrEquals-------------------------------------
kvn@2394 845 class StrEqualsNode: public StrIntrinsicNode {
cfang@719 846 public:
kvn@1044 847 StrEqualsNode(Node* control, Node* char_array_mem,
kvn@2394 848 Node* s1, Node* s2, Node* c):
kvn@2394 849 StrIntrinsicNode(control, char_array_mem, s1, s2, c) {};
cfang@719 850 virtual int Opcode() const;
cfang@719 851 virtual const Type* bottom_type() const { return TypeInt::BOOL; }
cfang@719 852 };
cfang@719 853
cfang@719 854 //------------------------------StrIndexOf-------------------------------------
kvn@2394 855 class StrIndexOfNode: public StrIntrinsicNode {
cfang@719 856 public:
kvn@1044 857 StrIndexOfNode(Node* control, Node* char_array_mem,
kvn@2394 858 Node* s1, Node* c1, Node* s2, Node* c2):
kvn@2394 859 StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {};
cfang@719 860 virtual int Opcode() const;
cfang@719 861 virtual const Type* bottom_type() const { return TypeInt::INT; }
cfang@719 862 };
cfang@719 863
rasbold@169 864 //------------------------------AryEq---------------------------------------
kvn@2394 865 class AryEqNode: public StrIntrinsicNode {
rasbold@169 866 public:
kvn@2394 867 AryEqNode(Node* control, Node* char_array_mem, Node* s1, Node* s2):
kvn@2394 868 StrIntrinsicNode(control, char_array_mem, s1, s2) {};
rasbold@169 869 virtual int Opcode() const;
rasbold@169 870 virtual const Type* bottom_type() const { return TypeInt::BOOL; }
rasbold@169 871 };
rasbold@169 872
duke@0 873 //------------------------------MemBar-----------------------------------------
duke@0 874 // There are different flavors of Memory Barriers to match the Java Memory
duke@0 875 // Model. Monitor-enter and volatile-load act as Aquires: no following ref
duke@0 876 // can be moved to before them. We insert a MemBar-Acquire after a FastLock or
duke@0 877 // volatile-load. Monitor-exit and volatile-store act as Release: no
twisti@643 878 // preceding ref can be moved to after them. We insert a MemBar-Release
duke@0 879 // before a FastUnlock or volatile-store. All volatiles need to be
duke@0 880 // serialized, so we follow all volatile-stores with a MemBar-Volatile to
twisti@643 881 // separate it from any following volatile-load.
duke@0 882 class MemBarNode: public MultiNode {
duke@0 883 virtual uint hash() const ; // { return NO_HASH; }
duke@0 884 virtual uint cmp( const Node &n ) const ; // Always fail, except on self
duke@0 885
duke@0 886 virtual uint size_of() const { return sizeof(*this); }
duke@0 887 // Memory type this node is serializing. Usually either rawptr or bottom.
duke@0 888 const TypePtr* _adr_type;
duke@0 889
duke@0 890 public:
duke@0 891 enum {
duke@0 892 Precedent = TypeFunc::Parms // optional edge to force precedence
duke@0 893 };
duke@0 894 MemBarNode(Compile* C, int alias_idx, Node* precedent);
duke@0 895 virtual int Opcode() const = 0;
duke@0 896 virtual const class TypePtr *adr_type() const { return _adr_type; }
duke@0 897 virtual const Type *Value( PhaseTransform *phase ) const;
duke@0 898 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 899 virtual uint match_edge(uint idx) const { return 0; }
duke@0 900 virtual const Type *bottom_type() const { return TypeTuple::MEMBAR; }
duke@0 901 virtual Node *match( const ProjNode *proj, const Matcher *m );
duke@0 902 // Factory method. Builds a wide or narrow membar.
duke@0 903 // Optional 'precedent' becomes an extra edge if not null.
duke@0 904 static MemBarNode* make(Compile* C, int opcode,
duke@0 905 int alias_idx = Compile::AliasIdxBot,
duke@0 906 Node* precedent = NULL);
duke@0 907 };
duke@0 908
duke@0 909 // "Acquire" - no following ref can move before (but earlier refs can
duke@0 910 // follow, like an early Load stalled in cache). Requires multi-cpu
roland@2844 911 // visibility. Inserted after a volatile load.
duke@0 912 class MemBarAcquireNode: public MemBarNode {
duke@0 913 public:
duke@0 914 MemBarAcquireNode(Compile* C, int alias_idx, Node* precedent)
duke@0 915 : MemBarNode(C, alias_idx, precedent) {}
duke@0 916 virtual int Opcode() const;
duke@0 917 };
duke@0 918
duke@0 919 // "Release" - no earlier ref can move after (but later refs can move
duke@0 920 // up, like a speculative pipelined cache-hitting Load). Requires
roland@2844 921 // multi-cpu visibility. Inserted before a volatile store.
duke@0 922 class MemBarReleaseNode: public MemBarNode {
duke@0 923 public:
duke@0 924 MemBarReleaseNode(Compile* C, int alias_idx, Node* precedent)
duke@0 925 : MemBarNode(C, alias_idx, precedent) {}
duke@0 926 virtual int Opcode() const;
duke@0 927 };
duke@0 928
roland@2844 929 // "Acquire" - no following ref can move before (but earlier refs can
roland@2844 930 // follow, like an early Load stalled in cache). Requires multi-cpu
roland@2844 931 // visibility. Inserted after a FastLock.
roland@2844 932 class MemBarAcquireLockNode: public MemBarNode {
roland@2844 933 public:
roland@2844 934 MemBarAcquireLockNode(Compile* C, int alias_idx, Node* precedent)
roland@2844 935 : MemBarNode(C, alias_idx, precedent) {}
roland@2844 936 virtual int Opcode() const;
roland@2844 937 };
roland@2844 938
roland@2844 939 // "Release" - no earlier ref can move after (but later refs can move
roland@2844 940 // up, like a speculative pipelined cache-hitting Load). Requires
roland@2844 941 // multi-cpu visibility. Inserted before a FastUnLock.
roland@2844 942 class MemBarReleaseLockNode: public MemBarNode {
roland@2844 943 public:
roland@2844 944 MemBarReleaseLockNode(Compile* C, int alias_idx, Node* precedent)
roland@2844 945 : MemBarNode(C, alias_idx, precedent) {}
roland@2844 946 virtual int Opcode() const;
roland@2844 947 };
roland@2844 948
roland@3256 949 class MemBarStoreStoreNode: public MemBarNode {
roland@3256 950 public:
roland@3256 951 MemBarStoreStoreNode(Compile* C, int alias_idx, Node* precedent)
roland@3256 952 : MemBarNode(C, alias_idx, precedent) {
roland@3256 953 init_class_id(Class_MemBarStoreStore);
roland@3256 954 }
roland@3256 955 virtual int Opcode() const;
roland@3256 956 };
roland@3256 957
duke@0 958 // Ordering between a volatile store and a following volatile load.
duke@0 959 // Requires multi-CPU visibility?
duke@0 960 class MemBarVolatileNode: public MemBarNode {
duke@0 961 public:
duke@0 962 MemBarVolatileNode(Compile* C, int alias_idx, Node* precedent)
duke@0 963 : MemBarNode(C, alias_idx, precedent) {}
duke@0 964 virtual int Opcode() const;
duke@0 965 };
duke@0 966
duke@0 967 // Ordering within the same CPU. Used to order unsafe memory references
duke@0 968 // inside the compiler when we lack alias info. Not needed "outside" the
duke@0 969 // compiler because the CPU does all the ordering for us.
duke@0 970 class MemBarCPUOrderNode: public MemBarNode {
duke@0 971 public:
duke@0 972 MemBarCPUOrderNode(Compile* C, int alias_idx, Node* precedent)
duke@0 973 : MemBarNode(C, alias_idx, precedent) {}
duke@0 974 virtual int Opcode() const;
duke@0 975 virtual uint ideal_reg() const { return 0; } // not matched in the AD file
duke@0 976 };
duke@0 977
duke@0 978 // Isolation of object setup after an AllocateNode and before next safepoint.
duke@0 979 // (See comment in memnode.cpp near InitializeNode::InitializeNode for semantics.)
duke@0 980 class InitializeNode: public MemBarNode {
duke@0 981 friend class AllocateNode;
duke@0 982
kvn@3010 983 enum {
kvn@3010 984 Incomplete = 0,
kvn@3010 985 Complete = 1,
kvn@3010 986 WithArraycopy = 2
kvn@3010 987 };
kvn@3010 988 int _is_complete;
duke@0 989
roland@3256 990 bool _does_not_escape;
roland@3256 991
duke@0 992 public:
duke@0 993 enum {
duke@0 994 Control = TypeFunc::Control,
duke@0 995 Memory = TypeFunc::Memory, // MergeMem for states affected by this op
duke@0 996 RawAddress = TypeFunc::Parms+0, // the newly-allocated raw address
duke@0 997 RawStores = TypeFunc::Parms+1 // zero or more stores (or TOP)
duke@0 998 };
duke@0 999
duke@0 1000 InitializeNode(Compile* C, int adr_type, Node* rawoop);
duke@0 1001 virtual int Opcode() const;
duke@0 1002 virtual uint size_of() const { return sizeof(*this); }
duke@0 1003 virtual uint ideal_reg() const { return 0; } // not matched in the AD file
duke@0 1004 virtual const RegMask &in_RegMask(uint) const; // mask for RawAddress
duke@0 1005
duke@0 1006 // Manage incoming memory edges via a MergeMem on in(Memory):
duke@0 1007 Node* memory(uint alias_idx);
duke@0 1008
duke@0 1009 // The raw memory edge coming directly from the Allocation.
duke@0 1010 // The contents of this memory are *always* all-zero-bits.
duke@0 1011 Node* zero_memory() { return memory(Compile::AliasIdxRaw); }
duke@0 1012
duke@0 1013 // Return the corresponding allocation for this initialization (or null if none).
duke@0 1014 // (Note: Both InitializeNode::allocation and AllocateNode::initialization
duke@0 1015 // are defined in graphKit.cpp, which sets up the bidirectional relation.)
duke@0 1016 AllocateNode* allocation();
duke@0 1017
duke@0 1018 // Anything other than zeroing in this init?
duke@0 1019 bool is_non_zero();
duke@0 1020
duke@0 1021 // An InitializeNode must completed before macro expansion is done.
duke@0 1022 // Completion requires that the AllocateNode must be followed by
duke@0 1023 // initialization of the new memory to zero, then to any initializers.
kvn@3010 1024 bool is_complete() { return _is_complete != Incomplete; }
kvn@3010 1025 bool is_complete_with_arraycopy() { return (_is_complete & WithArraycopy) != 0; }
duke@0 1026
duke@0 1027 // Mark complete. (Must not yet be complete.)
duke@0 1028 void set_complete(PhaseGVN* phase);
kvn@3010 1029 void set_complete_with_arraycopy() { _is_complete = Complete | WithArraycopy; }
duke@0 1030
roland@3256 1031 bool does_not_escape() { return _does_not_escape; }
roland@3256 1032 void set_does_not_escape() { _does_not_escape = true; }
roland@3256 1033
duke@0 1034 #ifdef ASSERT
duke@0 1035 // ensure all non-degenerate stores are ordered and non-overlapping
duke@0 1036 bool stores_are_sane(PhaseTransform* phase);
duke@0 1037 #endif //ASSERT
duke@0 1038
duke@0 1039 // See if this store can be captured; return offset where it initializes.
duke@0 1040 // Return 0 if the store cannot be moved (any sort of problem).
roland@4556 1041 intptr_t can_capture_store(StoreNode* st, PhaseTransform* phase, bool can_reshape);
duke@0 1042
duke@0 1043 // Capture another store; reformat it to write my internal raw memory.
duke@0 1044 // Return the captured copy, else NULL if there is some sort of problem.
roland@4556 1045 Node* capture_store(StoreNode* st, intptr_t start, PhaseTransform* phase, bool can_reshape);
duke@0 1046
duke@0 1047 // Find captured store which corresponds to the range [start..start+size).
duke@0 1048 // Return my own memory projection (meaning the initial zero bits)
duke@0 1049 // if there is no such store. Return NULL if there is a problem.
duke@0 1050 Node* find_captured_store(intptr_t start, int size_in_bytes, PhaseTransform* phase);
duke@0 1051
duke@0 1052 // Called when the associated AllocateNode is expanded into CFG.
duke@0 1053 Node* complete_stores(Node* rawctl, Node* rawmem, Node* rawptr,
duke@0 1054 intptr_t header_size, Node* size_in_bytes,
duke@0 1055 PhaseGVN* phase);
duke@0 1056
duke@0 1057 private:
duke@0 1058 void remove_extra_zeroes();
duke@0 1059
duke@0 1060 // Find out where a captured store should be placed (or already is placed).
duke@0 1061 int captured_store_insertion_point(intptr_t start, int size_in_bytes,
duke@0 1062 PhaseTransform* phase);
duke@0 1063
duke@0 1064 static intptr_t get_store_offset(Node* st, PhaseTransform* phase);
duke@0 1065
duke@0 1066 Node* make_raw_address(intptr_t offset, PhaseTransform* phase);
duke@0 1067
duke@0 1068 bool detect_init_independence(Node* n, bool st_is_pinned, int& count);
duke@0 1069
duke@0 1070 void coalesce_subword_stores(intptr_t header_size, Node* size_in_bytes,
duke@0 1071 PhaseGVN* phase);
duke@0 1072
duke@0 1073 intptr_t find_next_fullword_store(uint i, PhaseGVN* phase);
duke@0 1074 };
duke@0 1075
duke@0 1076 //------------------------------MergeMem---------------------------------------
duke@0 1077 // (See comment in memnode.cpp near MergeMemNode::MergeMemNode for semantics.)
duke@0 1078 class MergeMemNode: public Node {
duke@0 1079 virtual uint hash() const ; // { return NO_HASH; }
duke@0 1080 virtual uint cmp( const Node &n ) const ; // Always fail, except on self
duke@0 1081 friend class MergeMemStream;
duke@0 1082 MergeMemNode(Node* def); // clients use MergeMemNode::make
duke@0 1083
duke@0 1084 public:
duke@0 1085 // If the input is a whole memory state, clone it with all its slices intact.
duke@0 1086 // Otherwise, make a new memory state with just that base memory input.
duke@0 1087 // In either case, the result is a newly created MergeMem.
duke@0 1088 static MergeMemNode* make(Compile* C, Node* base_memory);
duke@0 1089
duke@0 1090 virtual int Opcode() const;
duke@0 1091 virtual Node *Identity( PhaseTransform *phase );
duke@0 1092 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
duke@0 1093 virtual uint ideal_reg() const { return NotAMachineReg; }
duke@0 1094 virtual uint match_edge(uint idx) const { return 0; }
duke@0 1095 virtual const RegMask &out_RegMask() const;
duke@0 1096 virtual const Type *bottom_type() const { return Type::MEMORY; }
duke@0 1097 virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; }
duke@0 1098 // sparse accessors
duke@0 1099 // Fetch the previously stored "set_memory_at", or else the base memory.
duke@0 1100 // (Caller should clone it if it is a phi-nest.)
duke@0 1101 Node* memory_at(uint alias_idx) const;
duke@0 1102 // set the memory, regardless of its previous value
duke@0 1103 void set_memory_at(uint alias_idx, Node* n);
duke@0 1104 // the "base" is the memory that provides the non-finite support
duke@0 1105 Node* base_memory() const { return in(Compile::AliasIdxBot); }
duke@0 1106 // warning: setting the base can implicitly set any of the other slices too
duke@0 1107 void set_base_memory(Node* def);
duke@0 1108 // sentinel value which denotes a copy of the base memory:
duke@0 1109 Node* empty_memory() const { return in(Compile::AliasIdxTop); }
duke@0 1110 static Node* make_empty_memory(); // where the sentinel comes from
duke@0 1111 bool is_empty_memory(Node* n) const { assert((n == empty_memory()) == n->is_top(), "sanity"); return n->is_top(); }
duke@0 1112 // hook for the iterator, to perform any necessary setup
duke@0 1113 void iteration_setup(const MergeMemNode* other = NULL);
duke@0 1114 // push sentinels until I am at least as long as the other (semantic no-op)
duke@0 1115 void grow_to_match(const MergeMemNode* other);
duke@0 1116 bool verify_sparse() const PRODUCT_RETURN0;
duke@0 1117 #ifndef PRODUCT
duke@0 1118 virtual void dump_spec(outputStream *st) const;
duke@0 1119 #endif
duke@0 1120 };
duke@0 1121
duke@0 1122 class MergeMemStream : public StackObj {
duke@0 1123 private:
duke@0 1124 MergeMemNode* _mm;
duke@0 1125 const MergeMemNode* _mm2; // optional second guy, contributes non-empty iterations
duke@0 1126 Node* _mm_base; // loop-invariant base memory of _mm
duke@0 1127 int _idx;
duke@0 1128 int _cnt;
duke@0 1129 Node* _mem;
duke@0 1130 Node* _mem2;
duke@0 1131 int _cnt2;
duke@0 1132
duke@0 1133 void init(MergeMemNode* mm, const MergeMemNode* mm2 = NULL) {
duke@0 1134 // subsume_node will break sparseness at times, whenever a memory slice
duke@0 1135 // folds down to a copy of the base ("fat") memory. In such a case,
duke@0 1136 // the raw edge will update to base, although it should be top.
duke@0 1137 // This iterator will recognize either top or base_memory as an
duke@0 1138 // "empty" slice. See is_empty, is_empty2, and next below.
duke@0 1139 //
duke@0 1140 // The sparseness property is repaired in MergeMemNode::Ideal.
duke@0 1141 // As long as access to a MergeMem goes through this iterator
duke@0 1142 // or the memory_at accessor, flaws in the sparseness will
duke@0 1143 // never be observed.
duke@0 1144 //
duke@0 1145 // Also, iteration_setup repairs sparseness.
duke@0 1146 assert(mm->verify_sparse(), "please, no dups of base");
duke@0 1147 assert(mm2==NULL || mm2->verify_sparse(), "please, no dups of base");
duke@0 1148
duke@0 1149 _mm = mm;
duke@0 1150 _mm_base = mm->base_memory();
duke@0 1151 _mm2 = mm2;
duke@0 1152 _cnt = mm->req();
duke@0 1153 _idx = Compile::AliasIdxBot-1; // start at the base memory
duke@0 1154 _mem = NULL;
duke@0 1155 _mem2 = NULL;
duke@0 1156 }
duke@0 1157
duke@0 1158 #ifdef ASSERT
duke@0 1159 Node* check_memory() const {
duke@0 1160 if (at_base_memory())
duke@0 1161 return _mm->base_memory();
duke@0 1162 else if ((uint)_idx < _mm->req() && !_mm->in(_idx)->is_top())
duke@0 1163 return _mm->memory_at(_idx);
duke@0 1164 else
duke@0 1165 return _mm_base;
duke@0 1166 }
duke@0 1167 Node* check_memory2() const {
duke@0 1168 return at_base_memory()? _mm2->base_memory(): _mm2->memory_at(_idx);
duke@0 1169 }
duke@0 1170 #endif
duke@0 1171
duke@0 1172 static bool match_memory(Node* mem, const MergeMemNode* mm, int idx) PRODUCT_RETURN0;
duke@0 1173 void assert_synch() const {
duke@0 1174 assert(!_mem || _idx >= _cnt || match_memory(_mem, _mm, _idx),
duke@0 1175 "no side-effects except through the stream");
duke@0 1176 }
duke@0 1177
duke@0 1178 public:
duke@0 1179
duke@0 1180 // expected usages:
duke@0 1181 // for (MergeMemStream mms(mem->is_MergeMem()); next_non_empty(); ) { ... }
duke@0 1182 // for (MergeMemStream mms(mem1, mem2); next_non_empty2(); ) { ... }
duke@0 1183
duke@0 1184 // iterate over one merge
duke@0 1185 MergeMemStream(MergeMemNode* mm) {
duke@0 1186 mm->iteration_setup();
duke@0 1187 init(mm);
duke@0 1188 debug_only(_cnt2 = 999);
duke@0 1189 }
duke@0 1190 // iterate in parallel over two merges
duke@0 1191 // only iterates through non-empty elements of mm2
duke@0 1192 MergeMemStream(MergeMemNode* mm, const MergeMemNode* mm2) {
duke@0 1193 assert(mm2, "second argument must be a MergeMem also");
duke@0 1194 ((MergeMemNode*)mm2)->iteration_setup(); // update hidden state
duke@0 1195 mm->iteration_setup(mm2);
duke@0 1196 init(mm, mm2);
duke@0 1197 _cnt2 = mm2->req();
duke@0 1198 }
duke@0 1199 #ifdef ASSERT
duke@0 1200 ~MergeMemStream() {
duke@0 1201 assert_synch();
duke@0 1202 }
duke@0 1203 #endif
duke@0 1204
duke@0 1205 MergeMemNode* all_memory() const {
duke@0 1206 return _mm;
duke@0 1207 }
duke@0 1208 Node* base_memory() const {
duke@0 1209 assert(_mm_base == _mm->base_memory(), "no update to base memory, please");
duke@0 1210 return _mm_base;
duke@0 1211 }
duke@0 1212 const MergeMemNode* all_memory2() const {
duke@0 1213 assert(_mm2 != NULL, "");
duke@0 1214 return _mm2;
duke@0 1215 }
duke@0 1216 bool at_base_memory() const {
duke@0 1217 return _idx == Compile::AliasIdxBot;
duke@0 1218 }
duke@0 1219 int alias_idx() const {
duke@0 1220 assert(_mem, "must call next 1st");
duke@0 1221 return _idx;
duke@0 1222 }
duke@0 1223
duke@0 1224 const TypePtr* adr_type() const {
duke@0 1225 return Compile::current()->get_adr_type(alias_idx());
duke@0 1226 }
duke@0 1227
duke@0 1228 const TypePtr* adr_type(Compile* C) const {
duke@0 1229 return C->get_adr_type(alias_idx());
duke@0 1230 }
duke@0 1231 bool is_empty() const {
duke@0 1232 assert(_mem, "must call next 1st");
duke@0 1233 assert(_mem->is_top() == (_mem==_mm->empty_memory()), "correct sentinel");
duke@0 1234 return _mem->is_top();
duke@0 1235 }
duke@0 1236 bool is_empty2() const {
duke@0 1237 assert(_mem2, "must call next 1st");
duke@0 1238 assert(_mem2->is_top() == (_mem2==_mm2->empty_memory()), "correct sentinel");
duke@0 1239 return _mem2->is_top();
duke@0 1240 }
duke@0 1241 Node* memory() const {
duke@0 1242 assert(!is_empty(), "must not be empty");
duke@0 1243 assert_synch();
duke@0 1244 return _mem;
duke@0 1245 }
duke@0 1246 // get the current memory, regardless of empty or non-empty status
duke@0 1247 Node* force_memory() const {
duke@0 1248 assert(!is_empty() || !at_base_memory(), "");
duke@0 1249 // Use _mm_base to defend against updates to _mem->base_memory().
duke@0 1250 Node *mem = _mem->is_top() ? _mm_base : _mem;
duke@0 1251 assert(mem == check_memory(), "");
duke@0 1252 return mem;
duke@0 1253 }
duke@0 1254 Node* memory2() const {
duke@0 1255 assert(_mem2 == check_memory2(), "");
duke@0 1256 return _mem2;
duke@0 1257 }
duke@0 1258 void set_memory(Node* mem) {
duke@0 1259 if (at_base_memory()) {
duke@0 1260 // Note that this does not change the invariant _mm_base.
duke@0 1261 _mm->set_base_memory(mem);
duke@0 1262 } else {
duke@0 1263 _mm->set_memory_at(_idx, mem);
duke@0 1264 }
duke@0 1265 _mem = mem;
duke@0 1266 assert_synch();
duke@0 1267 }
duke@0 1268
duke@0 1269 // Recover from a side effect to the MergeMemNode.
duke@0 1270 void set_memory() {
duke@0 1271 _mem = _mm->in(_idx);
duke@0 1272 }
duke@0 1273
duke@0 1274 bool next() { return next(false); }
duke@0 1275 bool next2() { return next(true); }
duke@0 1276
duke@0 1277 bool next_non_empty() { return next_non_empty(false); }
duke@0 1278 bool next_non_empty2() { return next_non_empty(true); }
duke@0 1279 // next_non_empty2 can yield states where is_empty() is true
duke@0 1280
duke@0 1281 private:
duke@0 1282 // find the next item, which might be empty
duke@0 1283 bool next(bool have_mm2) {
duke@0 1284 assert((_mm2 != NULL) == have_mm2, "use other next");
duke@0 1285 assert_synch();
duke@0 1286 if (++_idx < _cnt) {
duke@0 1287 // Note: This iterator allows _mm to be non-sparse.
duke@0 1288 // It behaves the same whether _mem is top or base_memory.
duke@0 1289 _mem = _mm->in(_idx);
duke@0 1290 if (have_mm2)
duke@0 1291 _mem2 = _mm2->in((_idx < _cnt2) ? _idx : Compile::AliasIdxTop);
duke@0 1292 return true;
duke@0 1293 }
duke@0 1294 return false;
duke@0 1295 }
duke@0 1296
duke@0 1297 // find the next non-empty item
duke@0 1298 bool next_non_empty(bool have_mm2) {
duke@0 1299 while (next(have_mm2)) {
duke@0 1300 if (!is_empty()) {
duke@0 1301 // make sure _mem2 is filled in sensibly
duke@0 1302 if (have_mm2 && _mem2->is_top()) _mem2 = _mm2->base_memory();
duke@0 1303 return true;
duke@0 1304 } else if (have_mm2 && !is_empty2()) {
duke@0 1305 return true; // is_empty() == true
duke@0 1306 }
duke@0 1307 }
duke@0 1308 return false;
duke@0 1309 }
duke@0 1310 };
duke@0 1311
duke@0 1312 //------------------------------Prefetch---------------------------------------
duke@0 1313
duke@0 1314 // Non-faulting prefetch load. Prefetch for many reads.
duke@0 1315 class PrefetchReadNode : public Node {
duke@0 1316 public:
duke@0 1317 PrefetchReadNode(Node *abio, Node *adr) : Node(0,abio,adr) {}
duke@0 1318 virtual int Opcode() const;
duke@0 1319 virtual uint ideal_reg() const { return NotAMachineReg; }
duke@0 1320 virtual uint match_edge(uint idx) const { return idx==2; }
duke@0 1321 virtual const Type *bottom_type() const { return Type::ABIO; }
duke@0 1322 };
duke@0 1323
duke@0 1324 // Non-faulting prefetch load. Prefetch for many reads & many writes.
duke@0 1325 class PrefetchWriteNode : public Node {
duke@0 1326 public:
duke@0 1327 PrefetchWriteNode(Node *abio, Node *adr) : Node(0,abio,adr) {}
duke@0 1328 virtual int Opcode() const;
duke@0 1329 virtual uint ideal_reg() const { return NotAMachineReg; }
duke@0 1330 virtual uint match_edge(uint idx) const { return idx==2; }
kvn@2849 1331 virtual const Type *bottom_type() const { return Type::ABIO; }
kvn@2849 1332 };
kvn@2849 1333
kvn@2849 1334 // Allocation prefetch which may fault, TLAB size have to be adjusted.
kvn@2849 1335 class PrefetchAllocationNode : public Node {
kvn@2849 1336 public:
kvn@2849 1337 PrefetchAllocationNode(Node *mem, Node *adr) : Node(0,mem,adr) {}
kvn@2849 1338 virtual int Opcode() const;
kvn@2849 1339 virtual uint ideal_reg() const { return NotAMachineReg; }
kvn@2849 1340 virtual uint match_edge(uint idx) const { return idx==2; }
kvn@1456 1341 virtual const Type *bottom_type() const { return ( AllocatePrefetchStyle == 3 ) ? Type::MEMORY : Type::ABIO; }
duke@0 1342 };
stefank@1992 1343
stefank@1992 1344 #endif // SHARE_VM_OPTO_MEMNODE_HPP