src/share/vm/opto/memnode.hpp

Mon, 25 Feb 2013 14:13:04 +0100

author
roland
date
Mon, 25 Feb 2013 14:13:04 +0100
changeset 4657
6931f425c517
parent 4479
b30b3c2a0cf2
child 5110
6f3fd5150b67
permissions
-rw-r--r--

8007294: ReduceFieldZeroing doesn't check for dependent load and can lead to incorrect execution
Summary: InitializeNode::can_capture_store() must check that the captured store doesn't overwrite a memory location that is loaded before the store.
Reviewed-by: kvn

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

mercurial