src/share/vm/opto/memnode.hpp

Mon, 27 Jan 2014 10:20:51 -0800

author
kvn
date
Mon, 27 Jan 2014 10:20:51 -0800
changeset 6293
2185d483f5f8
parent 6198
55fb97c4c58d
child 6503
a9becfeecd1b
permissions
-rw-r--r--

8032566: Crash in JIT when running Scala compiler (and compiling Scala std lib)
Summary: Switch off EliminateAutoBox flag by default in jdk8 release.
Reviewed-by: iveresov

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

mercurial