src/share/vm/opto/memnode.hpp

Thu, 24 May 2018 17:06:56 +0800

author
aoqi
date
Thu, 24 May 2018 17:06:56 +0800
changeset 8604
04d83ba48607
parent 7994
04ff2f6cd0eb
child 8856
ac27a9c85bea
permissions
-rw-r--r--

Merge

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

mercurial