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