Print this page
rev 7082 : 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
Summary: Use MachMerge to hook together defs of the same multidef value in a block
Reviewed-by: kvn, vlivanov
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/hotspot/src/share/vm/opto/node.hpp
+++ new/hotspot/src/share/vm/opto/node.hpp
1 1 /*
2 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_OPTO_NODE_HPP
26 26 #define SHARE_VM_OPTO_NODE_HPP
27 27
28 28 #include "libadt/port.hpp"
29 29 #include "libadt/vectset.hpp"
30 30 #include "opto/compile.hpp"
31 31 #include "opto/type.hpp"
32 32
33 33 // Portions of code courtesy of Clifford Click
34 34
35 35 // Optimization - Graph Style
36 36
37 37
38 38 class AbstractLockNode;
39 39 class AddNode;
40 40 class AddPNode;
41 41 class AliasInfo;
42 42 class AllocateArrayNode;
43 43 class AllocateNode;
44 44 class Block;
45 45 class BoolNode;
46 46 class BoxLockNode;
47 47 class CMoveNode;
48 48 class CallDynamicJavaNode;
49 49 class CallJavaNode;
50 50 class CallLeafNode;
51 51 class CallNode;
52 52 class CallRuntimeNode;
53 53 class CallStaticJavaNode;
54 54 class CatchNode;
55 55 class CatchProjNode;
56 56 class CheckCastPPNode;
57 57 class ClearArrayNode;
58 58 class CmpNode;
59 59 class CodeBuffer;
60 60 class ConstraintCastNode;
61 61 class ConNode;
62 62 class CountedLoopNode;
63 63 class CountedLoopEndNode;
64 64 class DecodeNarrowPtrNode;
65 65 class DecodeNNode;
66 66 class DecodeNKlassNode;
67 67 class EncodeNarrowPtrNode;
68 68 class EncodePNode;
69 69 class EncodePKlassNode;
70 70 class FastLockNode;
71 71 class FastUnlockNode;
72 72 class IfNode;
73 73 class IfFalseNode;
74 74 class IfTrueNode;
75 75 class InitializeNode;
76 76 class JVMState;
77 77 class JumpNode;
78 78 class JumpProjNode;
79 79 class LoadNode;
80 80 class LoadStoreNode;
81 81 class LockNode;
82 82 class LoopNode;
83 83 class MachBranchNode;
84 84 class MachCallDynamicJavaNode;
85 85 class MachCallJavaNode;
86 86 class MachCallLeafNode;
87 87 class MachCallNode;
88 88 class MachCallRuntimeNode;
89 89 class MachCallStaticJavaNode;
90 90 class MachConstantBaseNode;
↓ open down ↓ |
90 lines elided |
↑ open up ↑ |
91 91 class MachConstantNode;
92 92 class MachGotoNode;
93 93 class MachIfNode;
94 94 class MachNode;
95 95 class MachNullCheckNode;
96 96 class MachProjNode;
97 97 class MachReturnNode;
98 98 class MachSafePointNode;
99 99 class MachSpillCopyNode;
100 100 class MachTempNode;
101 +class MachMergeNode;
101 102 class Matcher;
102 103 class MemBarNode;
103 104 class MemBarStoreStoreNode;
104 105 class MemNode;
105 106 class MergeMemNode;
106 107 class MulNode;
107 108 class MultiNode;
108 109 class MultiBranchNode;
109 110 class NeverBranchNode;
110 111 class Node;
111 112 class Node_Array;
112 113 class Node_List;
113 114 class Node_Stack;
114 115 class NullCheckNode;
115 116 class OopMap;
116 117 class ParmNode;
117 118 class PCTableNode;
118 119 class PhaseCCP;
119 120 class PhaseGVN;
120 121 class PhaseIterGVN;
121 122 class PhaseRegAlloc;
122 123 class PhaseTransform;
123 124 class PhaseValues;
124 125 class PhiNode;
125 126 class Pipeline;
126 127 class ProjNode;
127 128 class RegMask;
128 129 class RegionNode;
129 130 class RootNode;
130 131 class SafePointNode;
131 132 class SafePointScalarObjectNode;
132 133 class StartNode;
133 134 class State;
134 135 class StoreNode;
135 136 class SubNode;
136 137 class Type;
137 138 class TypeNode;
138 139 class UnlockNode;
139 140 class VectorNode;
140 141 class LoadVectorNode;
141 142 class StoreVectorNode;
142 143 class VectorSet;
143 144 typedef void (*NFunc)(Node&,void*);
144 145 extern "C" {
145 146 typedef int (*C_sort_func_t)(const void *, const void *);
146 147 }
147 148
148 149 // The type of all node counts and indexes.
149 150 // It must hold at least 16 bits, but must also be fast to load and store.
150 151 // This type, if less than 32 bits, could limit the number of possible nodes.
151 152 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
152 153 typedef unsigned int node_idx_t;
153 154
154 155
155 156 #ifndef OPTO_DU_ITERATOR_ASSERT
156 157 #ifdef ASSERT
157 158 #define OPTO_DU_ITERATOR_ASSERT 1
158 159 #else
159 160 #define OPTO_DU_ITERATOR_ASSERT 0
160 161 #endif
161 162 #endif //OPTO_DU_ITERATOR_ASSERT
162 163
163 164 #if OPTO_DU_ITERATOR_ASSERT
164 165 class DUIterator;
165 166 class DUIterator_Fast;
166 167 class DUIterator_Last;
167 168 #else
168 169 typedef uint DUIterator;
169 170 typedef Node** DUIterator_Fast;
170 171 typedef Node** DUIterator_Last;
171 172 #endif
172 173
173 174 // Node Sentinel
174 175 #define NodeSentinel (Node*)-1
175 176
176 177 // Unknown count frequency
177 178 #define COUNT_UNKNOWN (-1.0f)
178 179
179 180 //------------------------------Node-------------------------------------------
180 181 // Nodes define actions in the program. They create values, which have types.
181 182 // They are both vertices in a directed graph and program primitives. Nodes
182 183 // are labeled; the label is the "opcode", the primitive function in the lambda
183 184 // calculus sense that gives meaning to the Node. Node inputs are ordered (so
184 185 // that "a-b" is different from "b-a"). The inputs to a Node are the inputs to
185 186 // the Node's function. These inputs also define a Type equation for the Node.
186 187 // Solving these Type equations amounts to doing dataflow analysis.
187 188 // Control and data are uniformly represented in the graph. Finally, Nodes
188 189 // have a unique dense integer index which is used to index into side arrays
189 190 // whenever I have phase-specific information.
190 191
191 192 class Node {
192 193 friend class VMStructs;
193 194
194 195 // Lots of restrictions on cloning Nodes
195 196 Node(const Node&); // not defined; linker error to use these
196 197 Node &operator=(const Node &rhs);
197 198
198 199 public:
199 200 friend class Compile;
200 201 #if OPTO_DU_ITERATOR_ASSERT
201 202 friend class DUIterator_Common;
202 203 friend class DUIterator;
203 204 friend class DUIterator_Fast;
204 205 friend class DUIterator_Last;
205 206 #endif
206 207
207 208 // Because Nodes come and go, I define an Arena of Node structures to pull
208 209 // from. This should allow fast access to node creation & deletion. This
209 210 // field is a local cache of a value defined in some "program fragment" for
210 211 // which these Nodes are just a part of.
211 212
212 213 // New Operator that takes a Compile pointer, this will eventually
213 214 // be the "new" New operator.
214 215 inline void* operator new( size_t x, Compile* C) throw() {
215 216 Node* n = (Node*)C->node_arena()->Amalloc_D(x);
216 217 #ifdef ASSERT
217 218 n->_in = (Node**)n; // magic cookie for assertion check
218 219 #endif
219 220 n->_out = (Node**)C;
220 221 return (void*)n;
221 222 }
222 223
223 224 // Delete is a NOP
224 225 void operator delete( void *ptr ) {}
225 226 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
226 227 void destruct();
227 228
228 229 // Create a new Node. Required is the number is of inputs required for
229 230 // semantic correctness.
230 231 Node( uint required );
231 232
232 233 // Create a new Node with given input edges.
233 234 // This version requires use of the "edge-count" new.
234 235 // E.g. new (C,3) FooNode( C, NULL, left, right );
235 236 Node( Node *n0 );
236 237 Node( Node *n0, Node *n1 );
237 238 Node( Node *n0, Node *n1, Node *n2 );
238 239 Node( Node *n0, Node *n1, Node *n2, Node *n3 );
239 240 Node( Node *n0, Node *n1, Node *n2, Node *n3, Node *n4 );
240 241 Node( Node *n0, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5 );
241 242 Node( Node *n0, Node *n1, Node *n2, Node *n3,
242 243 Node *n4, Node *n5, Node *n6 );
243 244
244 245 // Clone an inherited Node given only the base Node type.
245 246 Node* clone() const;
246 247
247 248 // Clone a Node, immediately supplying one or two new edges.
248 249 // The first and second arguments, if non-null, replace in(1) and in(2),
249 250 // respectively.
250 251 Node* clone_with_data_edge(Node* in1, Node* in2 = NULL) const {
251 252 Node* nn = clone();
252 253 if (in1 != NULL) nn->set_req(1, in1);
253 254 if (in2 != NULL) nn->set_req(2, in2);
254 255 return nn;
255 256 }
256 257
257 258 private:
258 259 // Shared setup for the above constructors.
259 260 // Handles all interactions with Compile::current.
260 261 // Puts initial values in all Node fields except _idx.
261 262 // Returns the initial value for _idx, which cannot
262 263 // be initialized by assignment.
263 264 inline int Init(int req, Compile* C);
264 265
265 266 //----------------- input edge handling
266 267 protected:
267 268 friend class PhaseCFG; // Access to address of _in array elements
268 269 Node **_in; // Array of use-def references to Nodes
269 270 Node **_out; // Array of def-use references to Nodes
270 271
271 272 // Input edges are split into two categories. Required edges are required
272 273 // for semantic correctness; order is important and NULLs are allowed.
273 274 // Precedence edges are used to help determine execution order and are
274 275 // added, e.g., for scheduling purposes. They are unordered and not
275 276 // duplicated; they have no embedded NULLs. Edges from 0 to _cnt-1
276 277 // are required, from _cnt to _max-1 are precedence edges.
277 278 node_idx_t _cnt; // Total number of required Node inputs.
278 279
279 280 node_idx_t _max; // Actual length of input array.
280 281
281 282 // Output edges are an unordered list of def-use edges which exactly
282 283 // correspond to required input edges which point from other nodes
283 284 // to this one. Thus the count of the output edges is the number of
284 285 // users of this node.
285 286 node_idx_t _outcnt; // Total number of Node outputs.
286 287
287 288 node_idx_t _outmax; // Actual length of output array.
288 289
289 290 // Grow the actual input array to the next larger power-of-2 bigger than len.
290 291 void grow( uint len );
291 292 // Grow the output array to the next larger power-of-2 bigger than len.
292 293 void out_grow( uint len );
293 294
294 295 public:
295 296 // Each Node is assigned a unique small/dense number. This number is used
296 297 // to index into auxiliary arrays of data and bitvectors.
297 298 // It is declared const to defend against inadvertant assignment,
298 299 // since it is used by clients as a naked field.
299 300 const node_idx_t _idx;
300 301
301 302 // Get the (read-only) number of input edges
302 303 uint req() const { return _cnt; }
303 304 uint len() const { return _max; }
304 305 // Get the (read-only) number of output edges
305 306 uint outcnt() const { return _outcnt; }
306 307
307 308 #if OPTO_DU_ITERATOR_ASSERT
308 309 // Iterate over the out-edges of this node. Deletions are illegal.
309 310 inline DUIterator outs() const;
310 311 // Use this when the out array might have changed to suppress asserts.
311 312 inline DUIterator& refresh_out_pos(DUIterator& i) const;
312 313 // Does the node have an out at this position? (Used for iteration.)
313 314 inline bool has_out(DUIterator& i) const;
314 315 inline Node* out(DUIterator& i) const;
315 316 // Iterate over the out-edges of this node. All changes are illegal.
316 317 inline DUIterator_Fast fast_outs(DUIterator_Fast& max) const;
317 318 inline Node* fast_out(DUIterator_Fast& i) const;
318 319 // Iterate over the out-edges of this node, deleting one at a time.
319 320 inline DUIterator_Last last_outs(DUIterator_Last& min) const;
320 321 inline Node* last_out(DUIterator_Last& i) const;
321 322 // The inline bodies of all these methods are after the iterator definitions.
322 323 #else
323 324 // Iterate over the out-edges of this node. Deletions are illegal.
324 325 // This iteration uses integral indexes, to decouple from array reallocations.
325 326 DUIterator outs() const { return 0; }
326 327 // Use this when the out array might have changed to suppress asserts.
327 328 DUIterator refresh_out_pos(DUIterator i) const { return i; }
328 329
329 330 // Reference to the i'th output Node. Error if out of bounds.
330 331 Node* out(DUIterator i) const { assert(i < _outcnt, "oob"); return _out[i]; }
331 332 // Does the node have an out at this position? (Used for iteration.)
332 333 bool has_out(DUIterator i) const { return i < _outcnt; }
333 334
334 335 // Iterate over the out-edges of this node. All changes are illegal.
335 336 // This iteration uses a pointer internal to the out array.
336 337 DUIterator_Fast fast_outs(DUIterator_Fast& max) const {
337 338 Node** out = _out;
338 339 // Assign a limit pointer to the reference argument:
339 340 max = out + (ptrdiff_t)_outcnt;
340 341 // Return the base pointer:
341 342 return out;
342 343 }
343 344 Node* fast_out(DUIterator_Fast i) const { return *i; }
344 345 // Iterate over the out-edges of this node, deleting one at a time.
345 346 // This iteration uses a pointer internal to the out array.
346 347 DUIterator_Last last_outs(DUIterator_Last& min) const {
347 348 Node** out = _out;
348 349 // Assign a limit pointer to the reference argument:
349 350 min = out;
350 351 // Return the pointer to the start of the iteration:
351 352 return out + (ptrdiff_t)_outcnt - 1;
352 353 }
353 354 Node* last_out(DUIterator_Last i) const { return *i; }
354 355 #endif
355 356
356 357 // Reference to the i'th input Node. Error if out of bounds.
357 358 Node* in(uint i) const { assert(i < _max, err_msg_res("oob: i=%d, _max=%d", i, _max)); return _in[i]; }
358 359 // Reference to the i'th input Node. NULL if out of bounds.
359 360 Node* lookup(uint i) const { return ((i < _max) ? _in[i] : NULL); }
360 361 // Reference to the i'th output Node. Error if out of bounds.
361 362 // Use this accessor sparingly. We are going trying to use iterators instead.
362 363 Node* raw_out(uint i) const { assert(i < _outcnt,"oob"); return _out[i]; }
363 364 // Return the unique out edge.
364 365 Node* unique_out() const { assert(_outcnt==1,"not unique"); return _out[0]; }
365 366 // Delete out edge at position 'i' by moving last out edge to position 'i'
366 367 void raw_del_out(uint i) {
367 368 assert(i < _outcnt,"oob");
368 369 assert(_outcnt > 0,"oob");
369 370 #if OPTO_DU_ITERATOR_ASSERT
370 371 // Record that a change happened here.
371 372 debug_only(_last_del = _out[i]; ++_del_tick);
372 373 #endif
373 374 _out[i] = _out[--_outcnt];
374 375 // Smash the old edge so it can't be used accidentally.
375 376 debug_only(_out[_outcnt] = (Node *)(uintptr_t)0xdeadbeef);
376 377 }
377 378
378 379 #ifdef ASSERT
379 380 bool is_dead() const;
380 381 #define is_not_dead(n) ((n) == NULL || !VerifyIterativeGVN || !((n)->is_dead()))
381 382 #endif
382 383 // Check whether node has become unreachable
383 384 bool is_unreachable(PhaseIterGVN &igvn) const;
384 385
385 386 // Set a required input edge, also updates corresponding output edge
386 387 void add_req( Node *n ); // Append a NEW required input
387 388 void add_req( Node *n0, Node *n1 ) {
388 389 add_req(n0); add_req(n1); }
389 390 void add_req( Node *n0, Node *n1, Node *n2 ) {
390 391 add_req(n0); add_req(n1); add_req(n2); }
391 392 void add_req_batch( Node* n, uint m ); // Append m NEW required inputs (all n).
392 393 void del_req( uint idx ); // Delete required edge & compact
393 394 void del_req_ordered( uint idx ); // Delete required edge & compact with preserved order
394 395 void ins_req( uint i, Node *n ); // Insert a NEW required input
395 396 void set_req( uint i, Node *n ) {
396 397 assert( is_not_dead(n), "can not use dead node");
397 398 assert( i < _cnt, err_msg_res("oob: i=%d, _cnt=%d", i, _cnt));
398 399 assert( !VerifyHashTableKeys || _hash_lock == 0,
399 400 "remove node from hash table before modifying it");
400 401 Node** p = &_in[i]; // cache this._in, across the del_out call
401 402 if (*p != NULL) (*p)->del_out((Node *)this);
402 403 (*p) = n;
403 404 if (n != NULL) n->add_out((Node *)this);
404 405 }
405 406 // Light version of set_req() to init inputs after node creation.
406 407 void init_req( uint i, Node *n ) {
407 408 assert( i == 0 && this == n ||
408 409 is_not_dead(n), "can not use dead node");
409 410 assert( i < _cnt, "oob");
410 411 assert( !VerifyHashTableKeys || _hash_lock == 0,
411 412 "remove node from hash table before modifying it");
412 413 assert( _in[i] == NULL, "sanity");
413 414 _in[i] = n;
414 415 if (n != NULL) n->add_out((Node *)this);
415 416 }
416 417 // Find first occurrence of n among my edges:
417 418 int find_edge(Node* n);
418 419 int replace_edge(Node* old, Node* neww);
419 420 int replace_edges_in_range(Node* old, Node* neww, int start, int end);
420 421 // NULL out all inputs to eliminate incoming Def-Use edges.
421 422 // Return the number of edges between 'n' and 'this'
422 423 int disconnect_inputs(Node *n, Compile *c);
423 424
424 425 // Quickly, return true if and only if I am Compile::current()->top().
425 426 bool is_top() const {
426 427 assert((this == (Node*) Compile::current()->top()) == (_out == NULL), "");
427 428 return (_out == NULL);
428 429 }
429 430 // Reaffirm invariants for is_top. (Only from Compile::set_cached_top_node.)
430 431 void setup_is_top();
431 432
432 433 // Strip away casting. (It is depth-limited.)
433 434 Node* uncast() const;
434 435 // Return whether two Nodes are equivalent, after stripping casting.
435 436 bool eqv_uncast(const Node* n) const {
436 437 return (this->uncast() == n->uncast());
437 438 }
438 439
439 440 private:
440 441 static Node* uncast_helper(const Node* n);
441 442
442 443 // Add an output edge to the end of the list
443 444 void add_out( Node *n ) {
444 445 if (is_top()) return;
445 446 if( _outcnt == _outmax ) out_grow(_outcnt);
446 447 _out[_outcnt++] = n;
447 448 }
448 449 // Delete an output edge
449 450 void del_out( Node *n ) {
450 451 if (is_top()) return;
451 452 Node** outp = &_out[_outcnt];
452 453 // Find and remove n
453 454 do {
454 455 assert(outp > _out, "Missing Def-Use edge");
455 456 } while (*--outp != n);
456 457 *outp = _out[--_outcnt];
457 458 // Smash the old edge so it can't be used accidentally.
458 459 debug_only(_out[_outcnt] = (Node *)(uintptr_t)0xdeadbeef);
459 460 // Record that a change happened here.
460 461 #if OPTO_DU_ITERATOR_ASSERT
461 462 debug_only(_last_del = n; ++_del_tick);
462 463 #endif
463 464 }
464 465
465 466 public:
466 467 // Globally replace this node by a given new node, updating all uses.
467 468 void replace_by(Node* new_node);
468 469 // Globally replace this node by a given new node, updating all uses
469 470 // and cutting input edges of old node.
470 471 void subsume_by(Node* new_node, Compile* c) {
471 472 replace_by(new_node);
472 473 disconnect_inputs(NULL, c);
473 474 }
474 475 void set_req_X( uint i, Node *n, PhaseIterGVN *igvn );
475 476 // Find the one non-null required input. RegionNode only
476 477 Node *nonnull_req() const;
477 478 // Add or remove precedence edges
478 479 void add_prec( Node *n );
479 480 void rm_prec( uint i );
480 481 void set_prec( uint i, Node *n ) {
481 482 assert( is_not_dead(n), "can not use dead node");
482 483 assert( i >= _cnt, "not a precedence edge");
483 484 if (_in[i] != NULL) _in[i]->del_out((Node *)this);
484 485 _in[i] = n;
485 486 if (n != NULL) n->add_out((Node *)this);
486 487 }
487 488 // Set this node's index, used by cisc_version to replace current node
488 489 void set_idx(uint new_idx) {
489 490 const node_idx_t* ref = &_idx;
490 491 *(node_idx_t*)ref = new_idx;
491 492 }
492 493 // Swap input edge order. (Edge indexes i1 and i2 are usually 1 and 2.)
493 494 void swap_edges(uint i1, uint i2) {
494 495 debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH);
495 496 // Def-Use info is unchanged
496 497 Node* n1 = in(i1);
497 498 Node* n2 = in(i2);
498 499 _in[i1] = n2;
499 500 _in[i2] = n1;
500 501 // If this node is in the hash table, make sure it doesn't need a rehash.
501 502 assert(check_hash == NO_HASH || check_hash == hash(), "edge swap must preserve hash code");
502 503 }
503 504
504 505 // Iterators over input Nodes for a Node X are written as:
505 506 // for( i = 0; i < X.req(); i++ ) ... X[i] ...
506 507 // NOTE: Required edges can contain embedded NULL pointers.
507 508
508 509 //----------------- Other Node Properties
509 510
510 511 // Generate class id for some ideal nodes to avoid virtual query
511 512 // methods is_<Node>().
512 513 // Class id is the set of bits corresponded to the node class and all its
513 514 // super classes so that queries for super classes are also valid.
514 515 // Subclasses of the same super class have different assigned bit
515 516 // (the third parameter in the macro DEFINE_CLASS_ID).
516 517 // Classes with deeper hierarchy are declared first.
517 518 // Classes with the same hierarchy depth are sorted by usage frequency.
518 519 //
519 520 // The query method masks the bits to cut off bits of subclasses
520 521 // and then compare the result with the class id
521 522 // (see the macro DEFINE_CLASS_QUERY below).
522 523 //
523 524 // Class_MachCall=30, ClassMask_MachCall=31
524 525 // 12 8 4 0
525 526 // 0 0 0 0 0 0 0 0 1 1 1 1 0
526 527 // | | | |
527 528 // | | | Bit_Mach=2
528 529 // | | Bit_MachReturn=4
529 530 // | Bit_MachSafePoint=8
530 531 // Bit_MachCall=16
531 532 //
532 533 // Class_CountedLoop=56, ClassMask_CountedLoop=63
533 534 // 12 8 4 0
534 535 // 0 0 0 0 0 0 0 1 1 1 0 0 0
535 536 // | | |
536 537 // | | Bit_Region=8
537 538 // | Bit_Loop=16
538 539 // Bit_CountedLoop=32
539 540
540 541 #define DEFINE_CLASS_ID(cl, supcl, subn) \
541 542 Bit_##cl = (Class_##supcl == 0) ? 1 << subn : (Bit_##supcl) << (1 + subn) , \
542 543 Class_##cl = Class_##supcl + Bit_##cl , \
543 544 ClassMask_##cl = ((Bit_##cl << 1) - 1) ,
544 545
545 546 // This enum is used only for C2 ideal and mach nodes with is_<node>() methods
546 547 // so that it's values fits into 16 bits.
547 548 enum NodeClasses {
548 549 Bit_Node = 0x0000,
549 550 Class_Node = 0x0000,
550 551 ClassMask_Node = 0xFFFF,
551 552
552 553 DEFINE_CLASS_ID(Multi, Node, 0)
553 554 DEFINE_CLASS_ID(SafePoint, Multi, 0)
554 555 DEFINE_CLASS_ID(Call, SafePoint, 0)
555 556 DEFINE_CLASS_ID(CallJava, Call, 0)
556 557 DEFINE_CLASS_ID(CallStaticJava, CallJava, 0)
557 558 DEFINE_CLASS_ID(CallDynamicJava, CallJava, 1)
558 559 DEFINE_CLASS_ID(CallRuntime, Call, 1)
559 560 DEFINE_CLASS_ID(CallLeaf, CallRuntime, 0)
560 561 DEFINE_CLASS_ID(Allocate, Call, 2)
561 562 DEFINE_CLASS_ID(AllocateArray, Allocate, 0)
562 563 DEFINE_CLASS_ID(AbstractLock, Call, 3)
563 564 DEFINE_CLASS_ID(Lock, AbstractLock, 0)
564 565 DEFINE_CLASS_ID(Unlock, AbstractLock, 1)
565 566 DEFINE_CLASS_ID(MultiBranch, Multi, 1)
566 567 DEFINE_CLASS_ID(PCTable, MultiBranch, 0)
567 568 DEFINE_CLASS_ID(Catch, PCTable, 0)
568 569 DEFINE_CLASS_ID(Jump, PCTable, 1)
569 570 DEFINE_CLASS_ID(If, MultiBranch, 1)
570 571 DEFINE_CLASS_ID(CountedLoopEnd, If, 0)
571 572 DEFINE_CLASS_ID(NeverBranch, MultiBranch, 2)
572 573 DEFINE_CLASS_ID(Start, Multi, 2)
573 574 DEFINE_CLASS_ID(MemBar, Multi, 3)
574 575 DEFINE_CLASS_ID(Initialize, MemBar, 0)
575 576 DEFINE_CLASS_ID(MemBarStoreStore, MemBar, 1)
576 577
577 578 DEFINE_CLASS_ID(Mach, Node, 1)
578 579 DEFINE_CLASS_ID(MachReturn, Mach, 0)
579 580 DEFINE_CLASS_ID(MachSafePoint, MachReturn, 0)
580 581 DEFINE_CLASS_ID(MachCall, MachSafePoint, 0)
581 582 DEFINE_CLASS_ID(MachCallJava, MachCall, 0)
582 583 DEFINE_CLASS_ID(MachCallStaticJava, MachCallJava, 0)
583 584 DEFINE_CLASS_ID(MachCallDynamicJava, MachCallJava, 1)
↓ open down ↓ |
473 lines elided |
↑ open up ↑ |
584 585 DEFINE_CLASS_ID(MachCallRuntime, MachCall, 1)
585 586 DEFINE_CLASS_ID(MachCallLeaf, MachCallRuntime, 0)
586 587 DEFINE_CLASS_ID(MachBranch, Mach, 1)
587 588 DEFINE_CLASS_ID(MachIf, MachBranch, 0)
588 589 DEFINE_CLASS_ID(MachGoto, MachBranch, 1)
589 590 DEFINE_CLASS_ID(MachNullCheck, MachBranch, 2)
590 591 DEFINE_CLASS_ID(MachSpillCopy, Mach, 2)
591 592 DEFINE_CLASS_ID(MachTemp, Mach, 3)
592 593 DEFINE_CLASS_ID(MachConstantBase, Mach, 4)
593 594 DEFINE_CLASS_ID(MachConstant, Mach, 5)
595 + DEFINE_CLASS_ID(MachMerge, Mach, 6)
594 596
595 597 DEFINE_CLASS_ID(Type, Node, 2)
596 598 DEFINE_CLASS_ID(Phi, Type, 0)
597 599 DEFINE_CLASS_ID(ConstraintCast, Type, 1)
598 600 DEFINE_CLASS_ID(CheckCastPP, Type, 2)
599 601 DEFINE_CLASS_ID(CMove, Type, 3)
600 602 DEFINE_CLASS_ID(SafePointScalarObject, Type, 4)
601 603 DEFINE_CLASS_ID(DecodeNarrowPtr, Type, 5)
602 604 DEFINE_CLASS_ID(DecodeN, DecodeNarrowPtr, 0)
603 605 DEFINE_CLASS_ID(DecodeNKlass, DecodeNarrowPtr, 1)
604 606 DEFINE_CLASS_ID(EncodeNarrowPtr, Type, 6)
605 607 DEFINE_CLASS_ID(EncodeP, EncodeNarrowPtr, 0)
606 608 DEFINE_CLASS_ID(EncodePKlass, EncodeNarrowPtr, 1)
607 609
608 610 DEFINE_CLASS_ID(Proj, Node, 3)
609 611 DEFINE_CLASS_ID(CatchProj, Proj, 0)
610 612 DEFINE_CLASS_ID(JumpProj, Proj, 1)
611 613 DEFINE_CLASS_ID(IfTrue, Proj, 2)
612 614 DEFINE_CLASS_ID(IfFalse, Proj, 3)
613 615 DEFINE_CLASS_ID(Parm, Proj, 4)
614 616 DEFINE_CLASS_ID(MachProj, Proj, 5)
615 617
616 618 DEFINE_CLASS_ID(Mem, Node, 4)
617 619 DEFINE_CLASS_ID(Load, Mem, 0)
618 620 DEFINE_CLASS_ID(LoadVector, Load, 0)
619 621 DEFINE_CLASS_ID(Store, Mem, 1)
620 622 DEFINE_CLASS_ID(StoreVector, Store, 0)
621 623 DEFINE_CLASS_ID(LoadStore, Mem, 2)
622 624
623 625 DEFINE_CLASS_ID(Region, Node, 5)
624 626 DEFINE_CLASS_ID(Loop, Region, 0)
625 627 DEFINE_CLASS_ID(Root, Loop, 0)
626 628 DEFINE_CLASS_ID(CountedLoop, Loop, 1)
627 629
628 630 DEFINE_CLASS_ID(Sub, Node, 6)
629 631 DEFINE_CLASS_ID(Cmp, Sub, 0)
630 632 DEFINE_CLASS_ID(FastLock, Cmp, 0)
631 633 DEFINE_CLASS_ID(FastUnlock, Cmp, 1)
632 634
633 635 DEFINE_CLASS_ID(MergeMem, Node, 7)
634 636 DEFINE_CLASS_ID(Bool, Node, 8)
635 637 DEFINE_CLASS_ID(AddP, Node, 9)
636 638 DEFINE_CLASS_ID(BoxLock, Node, 10)
637 639 DEFINE_CLASS_ID(Add, Node, 11)
638 640 DEFINE_CLASS_ID(Mul, Node, 12)
639 641 DEFINE_CLASS_ID(Vector, Node, 13)
640 642 DEFINE_CLASS_ID(ClearArray, Node, 14)
641 643
642 644 _max_classes = ClassMask_ClearArray
643 645 };
644 646 #undef DEFINE_CLASS_ID
645 647
646 648 // Flags are sorted by usage frequency.
647 649 enum NodeFlags {
648 650 Flag_is_Copy = 0x01, // should be first bit to avoid shift
649 651 Flag_rematerialize = Flag_is_Copy << 1,
650 652 Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
651 653 Flag_is_macro = Flag_needs_anti_dependence_check << 1,
652 654 Flag_is_Con = Flag_is_macro << 1,
653 655 Flag_is_cisc_alternate = Flag_is_Con << 1,
654 656 Flag_is_dead_loop_safe = Flag_is_cisc_alternate << 1,
655 657 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
656 658 Flag_avoid_back_to_back_before = Flag_may_be_short_branch << 1,
657 659 Flag_avoid_back_to_back_after = Flag_avoid_back_to_back_before << 1,
658 660 Flag_has_call = Flag_avoid_back_to_back_after << 1,
659 661 Flag_is_expensive = Flag_has_call << 1,
660 662 _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
661 663 };
662 664
663 665 private:
664 666 jushort _class_id;
665 667 jushort _flags;
666 668
667 669 protected:
668 670 // These methods should be called from constructors only.
669 671 void init_class_id(jushort c) {
670 672 assert(c <= _max_classes, "invalid node class");
671 673 _class_id = c; // cast out const
672 674 }
673 675 void init_flags(jushort fl) {
674 676 assert(fl <= _max_flags, "invalid node flag");
675 677 _flags |= fl;
676 678 }
677 679 void clear_flag(jushort fl) {
678 680 assert(fl <= _max_flags, "invalid node flag");
679 681 _flags &= ~fl;
680 682 }
681 683
682 684 public:
683 685 const jushort class_id() const { return _class_id; }
684 686
685 687 const jushort flags() const { return _flags; }
686 688
687 689 // Return a dense integer opcode number
688 690 virtual int Opcode() const;
689 691
690 692 // Virtual inherited Node size
691 693 virtual uint size_of() const;
692 694
693 695 // Other interesting Node properties
694 696 #define DEFINE_CLASS_QUERY(type) \
695 697 bool is_##type() const { \
696 698 return ((_class_id & ClassMask_##type) == Class_##type); \
697 699 } \
698 700 type##Node *as_##type() const { \
699 701 assert(is_##type(), "invalid node class"); \
700 702 return (type##Node*)this; \
701 703 } \
702 704 type##Node* isa_##type() const { \
703 705 return (is_##type()) ? as_##type() : NULL; \
704 706 }
705 707
706 708 DEFINE_CLASS_QUERY(AbstractLock)
707 709 DEFINE_CLASS_QUERY(Add)
708 710 DEFINE_CLASS_QUERY(AddP)
709 711 DEFINE_CLASS_QUERY(Allocate)
710 712 DEFINE_CLASS_QUERY(AllocateArray)
711 713 DEFINE_CLASS_QUERY(Bool)
712 714 DEFINE_CLASS_QUERY(BoxLock)
713 715 DEFINE_CLASS_QUERY(Call)
714 716 DEFINE_CLASS_QUERY(CallDynamicJava)
715 717 DEFINE_CLASS_QUERY(CallJava)
716 718 DEFINE_CLASS_QUERY(CallLeaf)
717 719 DEFINE_CLASS_QUERY(CallRuntime)
718 720 DEFINE_CLASS_QUERY(CallStaticJava)
719 721 DEFINE_CLASS_QUERY(Catch)
720 722 DEFINE_CLASS_QUERY(CatchProj)
721 723 DEFINE_CLASS_QUERY(CheckCastPP)
722 724 DEFINE_CLASS_QUERY(ConstraintCast)
723 725 DEFINE_CLASS_QUERY(ClearArray)
724 726 DEFINE_CLASS_QUERY(CMove)
725 727 DEFINE_CLASS_QUERY(Cmp)
726 728 DEFINE_CLASS_QUERY(CountedLoop)
727 729 DEFINE_CLASS_QUERY(CountedLoopEnd)
728 730 DEFINE_CLASS_QUERY(DecodeNarrowPtr)
729 731 DEFINE_CLASS_QUERY(DecodeN)
730 732 DEFINE_CLASS_QUERY(DecodeNKlass)
731 733 DEFINE_CLASS_QUERY(EncodeNarrowPtr)
732 734 DEFINE_CLASS_QUERY(EncodeP)
733 735 DEFINE_CLASS_QUERY(EncodePKlass)
734 736 DEFINE_CLASS_QUERY(FastLock)
735 737 DEFINE_CLASS_QUERY(FastUnlock)
736 738 DEFINE_CLASS_QUERY(If)
737 739 DEFINE_CLASS_QUERY(IfFalse)
738 740 DEFINE_CLASS_QUERY(IfTrue)
739 741 DEFINE_CLASS_QUERY(Initialize)
740 742 DEFINE_CLASS_QUERY(Jump)
741 743 DEFINE_CLASS_QUERY(JumpProj)
742 744 DEFINE_CLASS_QUERY(Load)
743 745 DEFINE_CLASS_QUERY(LoadStore)
744 746 DEFINE_CLASS_QUERY(Lock)
745 747 DEFINE_CLASS_QUERY(Loop)
746 748 DEFINE_CLASS_QUERY(Mach)
747 749 DEFINE_CLASS_QUERY(MachBranch)
748 750 DEFINE_CLASS_QUERY(MachCall)
749 751 DEFINE_CLASS_QUERY(MachCallDynamicJava)
750 752 DEFINE_CLASS_QUERY(MachCallJava)
751 753 DEFINE_CLASS_QUERY(MachCallLeaf)
752 754 DEFINE_CLASS_QUERY(MachCallRuntime)
753 755 DEFINE_CLASS_QUERY(MachCallStaticJava)
↓ open down ↓ |
150 lines elided |
↑ open up ↑ |
754 756 DEFINE_CLASS_QUERY(MachConstantBase)
755 757 DEFINE_CLASS_QUERY(MachConstant)
756 758 DEFINE_CLASS_QUERY(MachGoto)
757 759 DEFINE_CLASS_QUERY(MachIf)
758 760 DEFINE_CLASS_QUERY(MachNullCheck)
759 761 DEFINE_CLASS_QUERY(MachProj)
760 762 DEFINE_CLASS_QUERY(MachReturn)
761 763 DEFINE_CLASS_QUERY(MachSafePoint)
762 764 DEFINE_CLASS_QUERY(MachSpillCopy)
763 765 DEFINE_CLASS_QUERY(MachTemp)
766 + DEFINE_CLASS_QUERY(MachMerge)
764 767 DEFINE_CLASS_QUERY(Mem)
765 768 DEFINE_CLASS_QUERY(MemBar)
766 769 DEFINE_CLASS_QUERY(MemBarStoreStore)
767 770 DEFINE_CLASS_QUERY(MergeMem)
768 771 DEFINE_CLASS_QUERY(Mul)
769 772 DEFINE_CLASS_QUERY(Multi)
770 773 DEFINE_CLASS_QUERY(MultiBranch)
771 774 DEFINE_CLASS_QUERY(Parm)
772 775 DEFINE_CLASS_QUERY(PCTable)
773 776 DEFINE_CLASS_QUERY(Phi)
774 777 DEFINE_CLASS_QUERY(Proj)
775 778 DEFINE_CLASS_QUERY(Region)
776 779 DEFINE_CLASS_QUERY(Root)
777 780 DEFINE_CLASS_QUERY(SafePoint)
778 781 DEFINE_CLASS_QUERY(SafePointScalarObject)
779 782 DEFINE_CLASS_QUERY(Start)
780 783 DEFINE_CLASS_QUERY(Store)
781 784 DEFINE_CLASS_QUERY(Sub)
782 785 DEFINE_CLASS_QUERY(Type)
783 786 DEFINE_CLASS_QUERY(Vector)
784 787 DEFINE_CLASS_QUERY(LoadVector)
785 788 DEFINE_CLASS_QUERY(StoreVector)
786 789 DEFINE_CLASS_QUERY(Unlock)
787 790
788 791 #undef DEFINE_CLASS_QUERY
789 792
790 793 // duplicate of is_MachSpillCopy()
791 794 bool is_SpillCopy () const {
792 795 return ((_class_id & ClassMask_MachSpillCopy) == Class_MachSpillCopy);
793 796 }
794 797
795 798 bool is_Con () const { return (_flags & Flag_is_Con) != 0; }
796 799 // The data node which is safe to leave in dead loop during IGVN optimization.
797 800 bool is_dead_loop_safe() const {
798 801 return is_Phi() || (is_Proj() && in(0) == NULL) ||
799 802 ((_flags & (Flag_is_dead_loop_safe | Flag_is_Con)) != 0 &&
800 803 (!is_Proj() || !in(0)->is_Allocate()));
801 804 }
802 805
803 806 // is_Copy() returns copied edge index (0 or 1)
804 807 uint is_Copy() const { return (_flags & Flag_is_Copy); }
805 808
806 809 virtual bool is_CFG() const { return false; }
807 810
808 811 // If this node is control-dependent on a test, can it be
809 812 // rerouted to a dominating equivalent test? This is usually
810 813 // true of non-CFG nodes, but can be false for operations which
811 814 // depend for their correct sequencing on more than one test.
812 815 // (In that case, hoisting to a dominating test may silently
813 816 // skip some other important test.)
814 817 virtual bool depends_only_on_test() const { assert(!is_CFG(), ""); return true; };
815 818
816 819 // When building basic blocks, I need to have a notion of block beginning
817 820 // Nodes, next block selector Nodes (block enders), and next block
818 821 // projections. These calls need to work on their machine equivalents. The
819 822 // Ideal beginning Nodes are RootNode, RegionNode and StartNode.
820 823 bool is_block_start() const {
821 824 if ( is_Region() )
822 825 return this == (const Node*)in(0);
823 826 else
824 827 return is_Start();
825 828 }
826 829
827 830 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root,
828 831 // Goto and Return. This call also returns the block ending Node.
829 832 virtual const Node *is_block_proj() const;
830 833
831 834 // The node is a "macro" node which needs to be expanded before matching
832 835 bool is_macro() const { return (_flags & Flag_is_macro) != 0; }
833 836 // The node is expensive: the best control is set during loop opts
834 837 bool is_expensive() const { return (_flags & Flag_is_expensive) != 0 && in(0) != NULL; }
835 838
836 839 //----------------- Optimization
837 840
838 841 // Get the worst-case Type output for this Node.
839 842 virtual const class Type *bottom_type() const;
840 843
841 844 // If we find a better type for a node, try to record it permanently.
842 845 // Return true if this node actually changed.
843 846 // Be sure to do the hash_delete game in the "rehash" variant.
844 847 void raise_bottom_type(const Type* new_type);
845 848
846 849 // Get the address type with which this node uses and/or defs memory,
847 850 // or NULL if none. The address type is conservatively wide.
848 851 // Returns non-null for calls, membars, loads, stores, etc.
849 852 // Returns TypePtr::BOTTOM if the node touches memory "broadly".
850 853 virtual const class TypePtr *adr_type() const { return NULL; }
851 854
852 855 // Return an existing node which computes the same function as this node.
853 856 // The optimistic combined algorithm requires this to return a Node which
854 857 // is a small number of steps away (e.g., one of my inputs).
855 858 virtual Node *Identity( PhaseTransform *phase );
856 859
857 860 // Return the set of values this Node can take on at runtime.
858 861 virtual const Type *Value( PhaseTransform *phase ) const;
859 862
860 863 // Return a node which is more "ideal" than the current node.
861 864 // The invariants on this call are subtle. If in doubt, read the
862 865 // treatise in node.cpp above the default implemention AND TEST WITH
863 866 // +VerifyIterativeGVN!
864 867 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
865 868
866 869 // Some nodes have specific Ideal subgraph transformations only if they are
867 870 // unique users of specific nodes. Such nodes should be put on IGVN worklist
868 871 // for the transformations to happen.
869 872 bool has_special_unique_user() const;
870 873
871 874 // Skip Proj and CatchProj nodes chains. Check for Null and Top.
872 875 Node* find_exact_control(Node* ctrl);
873 876
874 877 // Check if 'this' node dominates or equal to 'sub'.
875 878 bool dominates(Node* sub, Node_List &nlist);
876 879
877 880 protected:
878 881 bool remove_dead_region(PhaseGVN *phase, bool can_reshape);
879 882 public:
880 883
881 884 // Idealize graph, using DU info. Done after constant propagation
882 885 virtual Node *Ideal_DU_postCCP( PhaseCCP *ccp );
883 886
884 887 // See if there is valid pipeline info
885 888 static const Pipeline *pipeline_class();
886 889 virtual const Pipeline *pipeline() const;
887 890
888 891 // Compute the latency from the def to this instruction of the ith input node
889 892 uint latency(uint i);
890 893
891 894 // Hash & compare functions, for pessimistic value numbering
892 895
893 896 // If the hash function returns the special sentinel value NO_HASH,
894 897 // the node is guaranteed never to compare equal to any other node.
895 898 // If we accidentally generate a hash with value NO_HASH the node
896 899 // won't go into the table and we'll lose a little optimization.
897 900 enum { NO_HASH = 0 };
898 901 virtual uint hash() const;
899 902 virtual uint cmp( const Node &n ) const;
900 903
901 904 // Operation appears to be iteratively computed (such as an induction variable)
902 905 // It is possible for this operation to return false for a loop-varying
903 906 // value, if it appears (by local graph inspection) to be computed by a simple conditional.
904 907 bool is_iteratively_computed();
905 908
906 909 // Determine if a node is Counted loop induction variable.
907 910 // The method is defined in loopnode.cpp.
908 911 const Node* is_loop_iv() const;
909 912
910 913 // Return a node with opcode "opc" and same inputs as "this" if one can
911 914 // be found; Otherwise return NULL;
912 915 Node* find_similar(int opc);
913 916
914 917 // Return the unique control out if only one. Null if none or more than one.
915 918 Node* unique_ctrl_out();
916 919
917 920 //----------------- Code Generation
918 921
919 922 // Ideal register class for Matching. Zero means unmatched instruction
920 923 // (these are cloned instead of converted to machine nodes).
921 924 virtual uint ideal_reg() const;
922 925
923 926 static const uint NotAMachineReg; // must be > max. machine register
924 927
925 928 // Do we Match on this edge index or not? Generally false for Control
926 929 // and true for everything else. Weird for calls & returns.
927 930 virtual uint match_edge(uint idx) const;
928 931
929 932 // Register class output is returned in
930 933 virtual const RegMask &out_RegMask() const;
931 934 // Register class input is expected in
932 935 virtual const RegMask &in_RegMask(uint) const;
933 936 // Should we clone rather than spill this instruction?
934 937 bool rematerialize() const;
935 938
936 939 // Return JVM State Object if this Node carries debug info, or NULL otherwise
937 940 virtual JVMState* jvms() const;
938 941
939 942 // Print as assembly
940 943 virtual void format( PhaseRegAlloc *, outputStream* st = tty ) const;
941 944 // Emit bytes starting at parameter 'ptr'
942 945 // Bump 'ptr' by the number of output bytes
943 946 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
944 947 // Size of instruction in bytes
945 948 virtual uint size(PhaseRegAlloc *ra_) const;
946 949
947 950 // Convenience function to extract an integer constant from a node.
948 951 // If it is not an integer constant (either Con, CastII, or Mach),
949 952 // return value_if_unknown.
950 953 jint find_int_con(jint value_if_unknown) const {
951 954 const TypeInt* t = find_int_type();
952 955 return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown;
953 956 }
954 957 // Return the constant, knowing it is an integer constant already
955 958 jint get_int() const {
956 959 const TypeInt* t = find_int_type();
957 960 guarantee(t != NULL, "must be con");
958 961 return t->get_con();
959 962 }
960 963 // Here's where the work is done. Can produce non-constant int types too.
961 964 const TypeInt* find_int_type() const;
962 965
963 966 // Same thing for long (and intptr_t, via type.hpp):
964 967 jlong get_long() const {
965 968 const TypeLong* t = find_long_type();
966 969 guarantee(t != NULL, "must be con");
967 970 return t->get_con();
968 971 }
969 972 jlong find_long_con(jint value_if_unknown) const {
970 973 const TypeLong* t = find_long_type();
971 974 return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown;
972 975 }
973 976 const TypeLong* find_long_type() const;
974 977
975 978 const TypePtr* get_ptr_type() const;
976 979
977 980 // These guys are called by code generated by ADLC:
978 981 intptr_t get_ptr() const;
979 982 intptr_t get_narrowcon() const;
980 983 jdouble getd() const;
981 984 jfloat getf() const;
982 985
983 986 // Nodes which are pinned into basic blocks
984 987 virtual bool pinned() const { return false; }
985 988
986 989 // Nodes which use memory without consuming it, hence need antidependences
987 990 // More specifically, needs_anti_dependence_check returns true iff the node
988 991 // (a) does a load, and (b) does not perform a store (except perhaps to a
989 992 // stack slot or some other unaliased location).
990 993 bool needs_anti_dependence_check() const;
991 994
992 995 // Return which operand this instruction may cisc-spill. In other words,
993 996 // return operand position that can convert from reg to memory access
994 997 virtual int cisc_operand() const { return AdlcVMDeps::Not_cisc_spillable; }
995 998 bool is_cisc_alternate() const { return (_flags & Flag_is_cisc_alternate) != 0; }
996 999
997 1000 //----------------- Graph walking
998 1001 public:
999 1002 // Walk and apply member functions recursively.
1000 1003 // Supplied (this) pointer is root.
1001 1004 void walk(NFunc pre, NFunc post, void *env);
1002 1005 static void nop(Node &, void*); // Dummy empty function
1003 1006 static void packregion( Node &n, void* );
1004 1007 private:
1005 1008 void walk_(NFunc pre, NFunc post, void *env, VectorSet &visited);
1006 1009
1007 1010 //----------------- Printing, etc
1008 1011 public:
1009 1012 #ifndef PRODUCT
1010 1013 Node* find(int idx) const; // Search the graph for the given idx.
1011 1014 Node* find_ctrl(int idx) const; // Search control ancestors for the given idx.
1012 1015 void dump() const { dump("\n"); } // Print this node.
1013 1016 void dump(const char* suffix, outputStream *st = tty) const;// Print this node.
1014 1017 void dump(int depth) const; // Print this node, recursively to depth d
1015 1018 void dump_ctrl(int depth) const; // Print control nodes, to depth d
1016 1019 virtual void dump_req(outputStream *st = tty) const; // Print required-edge info
1017 1020 virtual void dump_prec(outputStream *st = tty) const; // Print precedence-edge info
1018 1021 virtual void dump_out(outputStream *st = tty) const; // Print the output edge info
1019 1022 virtual void dump_spec(outputStream *st) const {}; // Print per-node info
1020 1023 void verify_edges(Unique_Node_List &visited); // Verify bi-directional edges
1021 1024 void verify() const; // Check Def-Use info for my subgraph
1022 1025 static void verify_recur(const Node *n, int verify_depth, VectorSet &old_space, VectorSet &new_space);
1023 1026
1024 1027 // This call defines a class-unique string used to identify class instances
1025 1028 virtual const char *Name() const;
1026 1029
1027 1030 void dump_format(PhaseRegAlloc *ra) const; // debug access to MachNode::format(...)
1028 1031 // RegMask Print Functions
1029 1032 void dump_in_regmask(int idx) { in_RegMask(idx).dump(); }
1030 1033 void dump_out_regmask() { out_RegMask().dump(); }
1031 1034 static bool in_dump() { return Compile::current()->_in_dump_cnt > 0; }
1032 1035 void fast_dump() const {
1033 1036 tty->print("%4d: %-17s", _idx, Name());
1034 1037 for (uint i = 0; i < len(); i++)
1035 1038 if (in(i))
1036 1039 tty->print(" %4d", in(i)->_idx);
1037 1040 else
1038 1041 tty->print(" NULL");
1039 1042 tty->print("\n");
1040 1043 }
1041 1044 #endif
1042 1045 #ifdef ASSERT
1043 1046 void verify_construction();
1044 1047 bool verify_jvms(const JVMState* jvms) const;
1045 1048 int _debug_idx; // Unique value assigned to every node.
1046 1049 int debug_idx() const { return _debug_idx; }
1047 1050 void set_debug_idx( int debug_idx ) { _debug_idx = debug_idx; }
1048 1051
1049 1052 Node* _debug_orig; // Original version of this, if any.
1050 1053 Node* debug_orig() const { return _debug_orig; }
1051 1054 void set_debug_orig(Node* orig); // _debug_orig = orig
1052 1055
1053 1056 int _hash_lock; // Barrier to modifications of nodes in the hash table
1054 1057 void enter_hash_lock() { ++_hash_lock; assert(_hash_lock < 99, "in too many hash tables?"); }
1055 1058 void exit_hash_lock() { --_hash_lock; assert(_hash_lock >= 0, "mispaired hash locks"); }
1056 1059
1057 1060 static void init_NodeProperty();
1058 1061
1059 1062 #if OPTO_DU_ITERATOR_ASSERT
1060 1063 const Node* _last_del; // The last deleted node.
1061 1064 uint _del_tick; // Bumped when a deletion happens..
1062 1065 #endif
1063 1066 #endif
1064 1067 };
1065 1068
1066 1069 //-----------------------------------------------------------------------------
1067 1070 // Iterators over DU info, and associated Node functions.
1068 1071
1069 1072 #if OPTO_DU_ITERATOR_ASSERT
1070 1073
1071 1074 // Common code for assertion checking on DU iterators.
1072 1075 class DUIterator_Common VALUE_OBJ_CLASS_SPEC {
1073 1076 #ifdef ASSERT
1074 1077 protected:
1075 1078 bool _vdui; // cached value of VerifyDUIterators
1076 1079 const Node* _node; // the node containing the _out array
1077 1080 uint _outcnt; // cached node->_outcnt
1078 1081 uint _del_tick; // cached node->_del_tick
1079 1082 Node* _last; // last value produced by the iterator
1080 1083
1081 1084 void sample(const Node* node); // used by c'tor to set up for verifies
1082 1085 void verify(const Node* node, bool at_end_ok = false);
1083 1086 void verify_resync();
1084 1087 void reset(const DUIterator_Common& that);
1085 1088
1086 1089 // The VDUI_ONLY macro protects code conditionalized on VerifyDUIterators
1087 1090 #define I_VDUI_ONLY(i,x) { if ((i)._vdui) { x; } }
1088 1091 #else
1089 1092 #define I_VDUI_ONLY(i,x) { }
1090 1093 #endif //ASSERT
1091 1094 };
1092 1095
1093 1096 #define VDUI_ONLY(x) I_VDUI_ONLY(*this, x)
1094 1097
1095 1098 // Default DU iterator. Allows appends onto the out array.
1096 1099 // Allows deletion from the out array only at the current point.
1097 1100 // Usage:
1098 1101 // for (DUIterator i = x->outs(); x->has_out(i); i++) {
1099 1102 // Node* y = x->out(i);
1100 1103 // ...
1101 1104 // }
1102 1105 // Compiles in product mode to a unsigned integer index, which indexes
1103 1106 // onto a repeatedly reloaded base pointer of x->_out. The loop predicate
1104 1107 // also reloads x->_outcnt. If you delete, you must perform "--i" just
1105 1108 // before continuing the loop. You must delete only the last-produced
1106 1109 // edge. You must delete only a single copy of the last-produced edge,
1107 1110 // or else you must delete all copies at once (the first time the edge
1108 1111 // is produced by the iterator).
1109 1112 class DUIterator : public DUIterator_Common {
1110 1113 friend class Node;
1111 1114
1112 1115 // This is the index which provides the product-mode behavior.
1113 1116 // Whatever the product-mode version of the system does to the
1114 1117 // DUI index is done to this index. All other fields in
1115 1118 // this class are used only for assertion checking.
1116 1119 uint _idx;
1117 1120
1118 1121 #ifdef ASSERT
1119 1122 uint _refresh_tick; // Records the refresh activity.
1120 1123
1121 1124 void sample(const Node* node); // Initialize _refresh_tick etc.
1122 1125 void verify(const Node* node, bool at_end_ok = false);
1123 1126 void verify_increment(); // Verify an increment operation.
1124 1127 void verify_resync(); // Verify that we can back up over a deletion.
1125 1128 void verify_finish(); // Verify that the loop terminated properly.
1126 1129 void refresh(); // Resample verification info.
1127 1130 void reset(const DUIterator& that); // Resample after assignment.
1128 1131 #endif
1129 1132
1130 1133 DUIterator(const Node* node, int dummy_to_avoid_conversion)
1131 1134 { _idx = 0; debug_only(sample(node)); }
1132 1135
1133 1136 public:
1134 1137 // initialize to garbage; clear _vdui to disable asserts
1135 1138 DUIterator()
1136 1139 { /*initialize to garbage*/ debug_only(_vdui = false); }
1137 1140
1138 1141 void operator++(int dummy_to_specify_postfix_op)
1139 1142 { _idx++; VDUI_ONLY(verify_increment()); }
1140 1143
1141 1144 void operator--()
1142 1145 { VDUI_ONLY(verify_resync()); --_idx; }
1143 1146
1144 1147 ~DUIterator()
1145 1148 { VDUI_ONLY(verify_finish()); }
1146 1149
1147 1150 void operator=(const DUIterator& that)
1148 1151 { _idx = that._idx; debug_only(reset(that)); }
1149 1152 };
1150 1153
1151 1154 DUIterator Node::outs() const
1152 1155 { return DUIterator(this, 0); }
1153 1156 DUIterator& Node::refresh_out_pos(DUIterator& i) const
1154 1157 { I_VDUI_ONLY(i, i.refresh()); return i; }
1155 1158 bool Node::has_out(DUIterator& i) const
1156 1159 { I_VDUI_ONLY(i, i.verify(this,true));return i._idx < _outcnt; }
1157 1160 Node* Node::out(DUIterator& i) const
1158 1161 { I_VDUI_ONLY(i, i.verify(this)); return debug_only(i._last=) _out[i._idx]; }
1159 1162
1160 1163
1161 1164 // Faster DU iterator. Disallows insertions into the out array.
1162 1165 // Allows deletion from the out array only at the current point.
1163 1166 // Usage:
1164 1167 // for (DUIterator_Fast imax, i = x->fast_outs(imax); i < imax; i++) {
1165 1168 // Node* y = x->fast_out(i);
1166 1169 // ...
1167 1170 // }
1168 1171 // Compiles in product mode to raw Node** pointer arithmetic, with
1169 1172 // no reloading of pointers from the original node x. If you delete,
1170 1173 // you must perform "--i; --imax" just before continuing the loop.
1171 1174 // If you delete multiple copies of the same edge, you must decrement
1172 1175 // imax, but not i, multiple times: "--i, imax -= num_edges".
1173 1176 class DUIterator_Fast : public DUIterator_Common {
1174 1177 friend class Node;
1175 1178 friend class DUIterator_Last;
1176 1179
1177 1180 // This is the pointer which provides the product-mode behavior.
1178 1181 // Whatever the product-mode version of the system does to the
1179 1182 // DUI pointer is done to this pointer. All other fields in
1180 1183 // this class are used only for assertion checking.
1181 1184 Node** _outp;
1182 1185
1183 1186 #ifdef ASSERT
1184 1187 void verify(const Node* node, bool at_end_ok = false);
1185 1188 void verify_limit();
1186 1189 void verify_resync();
1187 1190 void verify_relimit(uint n);
1188 1191 void reset(const DUIterator_Fast& that);
1189 1192 #endif
1190 1193
1191 1194 // Note: offset must be signed, since -1 is sometimes passed
1192 1195 DUIterator_Fast(const Node* node, ptrdiff_t offset)
1193 1196 { _outp = node->_out + offset; debug_only(sample(node)); }
1194 1197
1195 1198 public:
1196 1199 // initialize to garbage; clear _vdui to disable asserts
1197 1200 DUIterator_Fast()
1198 1201 { /*initialize to garbage*/ debug_only(_vdui = false); }
1199 1202
1200 1203 void operator++(int dummy_to_specify_postfix_op)
1201 1204 { _outp++; VDUI_ONLY(verify(_node, true)); }
1202 1205
1203 1206 void operator--()
1204 1207 { VDUI_ONLY(verify_resync()); --_outp; }
1205 1208
1206 1209 void operator-=(uint n) // applied to the limit only
1207 1210 { _outp -= n; VDUI_ONLY(verify_relimit(n)); }
1208 1211
1209 1212 bool operator<(DUIterator_Fast& limit) {
1210 1213 I_VDUI_ONLY(*this, this->verify(_node, true));
1211 1214 I_VDUI_ONLY(limit, limit.verify_limit());
1212 1215 return _outp < limit._outp;
1213 1216 }
1214 1217
1215 1218 void operator=(const DUIterator_Fast& that)
1216 1219 { _outp = that._outp; debug_only(reset(that)); }
1217 1220 };
1218 1221
1219 1222 DUIterator_Fast Node::fast_outs(DUIterator_Fast& imax) const {
1220 1223 // Assign a limit pointer to the reference argument:
1221 1224 imax = DUIterator_Fast(this, (ptrdiff_t)_outcnt);
1222 1225 // Return the base pointer:
1223 1226 return DUIterator_Fast(this, 0);
1224 1227 }
1225 1228 Node* Node::fast_out(DUIterator_Fast& i) const {
1226 1229 I_VDUI_ONLY(i, i.verify(this));
1227 1230 return debug_only(i._last=) *i._outp;
1228 1231 }
1229 1232
1230 1233
1231 1234 // Faster DU iterator. Requires each successive edge to be removed.
1232 1235 // Does not allow insertion of any edges.
1233 1236 // Usage:
1234 1237 // for (DUIterator_Last imin, i = x->last_outs(imin); i >= imin; i -= num_edges) {
1235 1238 // Node* y = x->last_out(i);
1236 1239 // ...
1237 1240 // }
1238 1241 // Compiles in product mode to raw Node** pointer arithmetic, with
1239 1242 // no reloading of pointers from the original node x.
1240 1243 class DUIterator_Last : private DUIterator_Fast {
1241 1244 friend class Node;
1242 1245
1243 1246 #ifdef ASSERT
1244 1247 void verify(const Node* node, bool at_end_ok = false);
1245 1248 void verify_limit();
1246 1249 void verify_step(uint num_edges);
1247 1250 #endif
1248 1251
1249 1252 // Note: offset must be signed, since -1 is sometimes passed
1250 1253 DUIterator_Last(const Node* node, ptrdiff_t offset)
1251 1254 : DUIterator_Fast(node, offset) { }
1252 1255
1253 1256 void operator++(int dummy_to_specify_postfix_op) {} // do not use
1254 1257 void operator<(int) {} // do not use
1255 1258
1256 1259 public:
1257 1260 DUIterator_Last() { }
1258 1261 // initialize to garbage
1259 1262
1260 1263 void operator--()
1261 1264 { _outp--; VDUI_ONLY(verify_step(1)); }
1262 1265
1263 1266 void operator-=(uint n)
1264 1267 { _outp -= n; VDUI_ONLY(verify_step(n)); }
1265 1268
1266 1269 bool operator>=(DUIterator_Last& limit) {
1267 1270 I_VDUI_ONLY(*this, this->verify(_node, true));
1268 1271 I_VDUI_ONLY(limit, limit.verify_limit());
1269 1272 return _outp >= limit._outp;
1270 1273 }
1271 1274
1272 1275 void operator=(const DUIterator_Last& that)
1273 1276 { DUIterator_Fast::operator=(that); }
1274 1277 };
1275 1278
1276 1279 DUIterator_Last Node::last_outs(DUIterator_Last& imin) const {
1277 1280 // Assign a limit pointer to the reference argument:
1278 1281 imin = DUIterator_Last(this, 0);
1279 1282 // Return the initial pointer:
1280 1283 return DUIterator_Last(this, (ptrdiff_t)_outcnt - 1);
1281 1284 }
1282 1285 Node* Node::last_out(DUIterator_Last& i) const {
1283 1286 I_VDUI_ONLY(i, i.verify(this));
1284 1287 return debug_only(i._last=) *i._outp;
1285 1288 }
1286 1289
1287 1290 #endif //OPTO_DU_ITERATOR_ASSERT
1288 1291
1289 1292 #undef I_VDUI_ONLY
1290 1293 #undef VDUI_ONLY
1291 1294
1292 1295 // An Iterator that truly follows the iterator pattern. Doesn't
1293 1296 // support deletion but could be made to.
1294 1297 //
1295 1298 // for (SimpleDUIterator i(n); i.has_next(); i.next()) {
1296 1299 // Node* m = i.get();
1297 1300 //
1298 1301 class SimpleDUIterator : public StackObj {
1299 1302 private:
1300 1303 Node* node;
1301 1304 DUIterator_Fast i;
1302 1305 DUIterator_Fast imax;
1303 1306 public:
1304 1307 SimpleDUIterator(Node* n): node(n), i(n->fast_outs(imax)) {}
1305 1308 bool has_next() { return i < imax; }
1306 1309 void next() { i++; }
1307 1310 Node* get() { return node->fast_out(i); }
1308 1311 };
1309 1312
1310 1313
1311 1314 //-----------------------------------------------------------------------------
1312 1315 // Map dense integer indices to Nodes. Uses classic doubling-array trick.
1313 1316 // Abstractly provides an infinite array of Node*'s, initialized to NULL.
1314 1317 // Note that the constructor just zeros things, and since I use Arena
1315 1318 // allocation I do not need a destructor to reclaim storage.
1316 1319 class Node_Array : public ResourceObj {
1317 1320 friend class VMStructs;
1318 1321 protected:
1319 1322 Arena *_a; // Arena to allocate in
1320 1323 uint _max;
1321 1324 Node **_nodes;
1322 1325 void grow( uint i ); // Grow array node to fit
1323 1326 public:
1324 1327 Node_Array(Arena *a) : _a(a), _max(OptoNodeListSize) {
1325 1328 _nodes = NEW_ARENA_ARRAY( a, Node *, OptoNodeListSize );
1326 1329 for( int i = 0; i < OptoNodeListSize; i++ ) {
1327 1330 _nodes[i] = NULL;
1328 1331 }
1329 1332 }
1330 1333
1331 1334 Node_Array(Node_Array *na) : _a(na->_a), _max(na->_max), _nodes(na->_nodes) {}
1332 1335 Node *operator[] ( uint i ) const // Lookup, or NULL for not mapped
1333 1336 { return (i<_max) ? _nodes[i] : (Node*)NULL; }
1334 1337 Node *at( uint i ) const { assert(i<_max,"oob"); return _nodes[i]; }
1335 1338 Node **adr() { return _nodes; }
1336 1339 // Extend the mapping: index i maps to Node *n.
1337 1340 void map( uint i, Node *n ) { if( i>=_max ) grow(i); _nodes[i] = n; }
1338 1341 void insert( uint i, Node *n );
1339 1342 void remove( uint i ); // Remove, preserving order
1340 1343 void sort( C_sort_func_t func);
1341 1344 void reset( Arena *new_a ); // Zap mapping to empty; reclaim storage
1342 1345 void clear(); // Set all entries to NULL, keep storage
1343 1346 uint Size() const { return _max; }
1344 1347 void dump() const;
1345 1348 };
1346 1349
1347 1350 class Node_List : public Node_Array {
1348 1351 friend class VMStructs;
1349 1352 uint _cnt;
1350 1353 public:
1351 1354 Node_List() : Node_Array(Thread::current()->resource_area()), _cnt(0) {}
1352 1355 Node_List(Arena *a) : Node_Array(a), _cnt(0) {}
1353 1356 bool contains(const Node* n) const {
1354 1357 for (uint e = 0; e < size(); e++) {
1355 1358 if (at(e) == n) return true;
1356 1359 }
1357 1360 return false;
1358 1361 }
1359 1362 void insert( uint i, Node *n ) { Node_Array::insert(i,n); _cnt++; }
1360 1363 void remove( uint i ) { Node_Array::remove(i); _cnt--; }
1361 1364 void push( Node *b ) { map(_cnt++,b); }
1362 1365 void yank( Node *n ); // Find and remove
1363 1366 Node *pop() { return _nodes[--_cnt]; }
1364 1367 Node *rpop() { Node *b = _nodes[0]; _nodes[0]=_nodes[--_cnt]; return b;}
1365 1368 void clear() { _cnt = 0; Node_Array::clear(); } // retain storage
1366 1369 uint size() const { return _cnt; }
1367 1370 void dump() const;
1368 1371 };
1369 1372
1370 1373 //------------------------------Unique_Node_List-------------------------------
1371 1374 class Unique_Node_List : public Node_List {
1372 1375 friend class VMStructs;
1373 1376 VectorSet _in_worklist;
1374 1377 uint _clock_index; // Index in list where to pop from next
1375 1378 public:
1376 1379 Unique_Node_List() : Node_List(), _in_worklist(Thread::current()->resource_area()), _clock_index(0) {}
1377 1380 Unique_Node_List(Arena *a) : Node_List(a), _in_worklist(a), _clock_index(0) {}
1378 1381
1379 1382 void remove( Node *n );
1380 1383 bool member( Node *n ) { return _in_worklist.test(n->_idx) != 0; }
1381 1384 VectorSet &member_set(){ return _in_worklist; }
1382 1385
1383 1386 void push( Node *b ) {
1384 1387 if( !_in_worklist.test_set(b->_idx) )
1385 1388 Node_List::push(b);
1386 1389 }
1387 1390 Node *pop() {
1388 1391 if( _clock_index >= size() ) _clock_index = 0;
1389 1392 Node *b = at(_clock_index);
1390 1393 map( _clock_index, Node_List::pop());
1391 1394 if (size() != 0) _clock_index++; // Always start from 0
1392 1395 _in_worklist >>= b->_idx;
1393 1396 return b;
1394 1397 }
1395 1398 Node *remove( uint i ) {
1396 1399 Node *b = Node_List::at(i);
1397 1400 _in_worklist >>= b->_idx;
1398 1401 map(i,Node_List::pop());
1399 1402 return b;
1400 1403 }
1401 1404 void yank( Node *n ) { _in_worklist >>= n->_idx; Node_List::yank(n); }
1402 1405 void clear() {
1403 1406 _in_worklist.Clear(); // Discards storage but grows automatically
1404 1407 Node_List::clear();
1405 1408 _clock_index = 0;
1406 1409 }
1407 1410
1408 1411 // Used after parsing to remove useless nodes before Iterative GVN
1409 1412 void remove_useless_nodes(VectorSet &useful);
1410 1413
1411 1414 #ifndef PRODUCT
1412 1415 void print_set() const { _in_worklist.print(); }
1413 1416 #endif
1414 1417 };
1415 1418
1416 1419 // Inline definition of Compile::record_for_igvn must be deferred to this point.
1417 1420 inline void Compile::record_for_igvn(Node* n) {
1418 1421 _for_igvn->push(n);
1419 1422 }
1420 1423
1421 1424 //------------------------------Node_Stack-------------------------------------
1422 1425 class Node_Stack {
1423 1426 friend class VMStructs;
1424 1427 protected:
1425 1428 struct INode {
1426 1429 Node *node; // Processed node
1427 1430 uint indx; // Index of next node's child
1428 1431 };
1429 1432 INode *_inode_top; // tos, stack grows up
1430 1433 INode *_inode_max; // End of _inodes == _inodes + _max
1431 1434 INode *_inodes; // Array storage for the stack
1432 1435 Arena *_a; // Arena to allocate in
1433 1436 void grow();
1434 1437 public:
1435 1438 Node_Stack(int size) {
1436 1439 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1437 1440 _a = Thread::current()->resource_area();
1438 1441 _inodes = NEW_ARENA_ARRAY( _a, INode, max );
1439 1442 _inode_max = _inodes + max;
1440 1443 _inode_top = _inodes - 1; // stack is empty
1441 1444 }
1442 1445
1443 1446 Node_Stack(Arena *a, int size) : _a(a) {
1444 1447 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1445 1448 _inodes = NEW_ARENA_ARRAY( _a, INode, max );
1446 1449 _inode_max = _inodes + max;
1447 1450 _inode_top = _inodes - 1; // stack is empty
1448 1451 }
1449 1452
1450 1453 void pop() {
1451 1454 assert(_inode_top >= _inodes, "node stack underflow");
1452 1455 --_inode_top;
1453 1456 }
1454 1457 void push(Node *n, uint i) {
1455 1458 ++_inode_top;
1456 1459 if (_inode_top >= _inode_max) grow();
1457 1460 INode *top = _inode_top; // optimization
1458 1461 top->node = n;
1459 1462 top->indx = i;
1460 1463 }
1461 1464 Node *node() const {
1462 1465 return _inode_top->node;
1463 1466 }
1464 1467 Node* node_at(uint i) const {
1465 1468 assert(_inodes + i <= _inode_top, "in range");
1466 1469 return _inodes[i].node;
1467 1470 }
1468 1471 uint index() const {
1469 1472 return _inode_top->indx;
1470 1473 }
1471 1474 uint index_at(uint i) const {
1472 1475 assert(_inodes + i <= _inode_top, "in range");
1473 1476 return _inodes[i].indx;
1474 1477 }
1475 1478 void set_node(Node *n) {
1476 1479 _inode_top->node = n;
1477 1480 }
1478 1481 void set_index(uint i) {
1479 1482 _inode_top->indx = i;
1480 1483 }
1481 1484 uint size_max() const { return (uint)pointer_delta(_inode_max, _inodes, sizeof(INode)); } // Max size
1482 1485 uint size() const { return (uint)pointer_delta((_inode_top+1), _inodes, sizeof(INode)); } // Current size
1483 1486 bool is_nonempty() const { return (_inode_top >= _inodes); }
1484 1487 bool is_empty() const { return (_inode_top < _inodes); }
1485 1488 void clear() { _inode_top = _inodes - 1; } // retain storage
1486 1489
1487 1490 // Node_Stack is used to map nodes.
1488 1491 Node* find(uint idx) const;
1489 1492 };
1490 1493
1491 1494
1492 1495 //-----------------------------Node_Notes--------------------------------------
1493 1496 // Debugging or profiling annotations loosely and sparsely associated
1494 1497 // with some nodes. See Compile::node_notes_at for the accessor.
1495 1498 class Node_Notes VALUE_OBJ_CLASS_SPEC {
1496 1499 friend class VMStructs;
1497 1500 JVMState* _jvms;
1498 1501
1499 1502 public:
1500 1503 Node_Notes(JVMState* jvms = NULL) {
1501 1504 _jvms = jvms;
1502 1505 }
1503 1506
1504 1507 JVMState* jvms() { return _jvms; }
1505 1508 void set_jvms(JVMState* x) { _jvms = x; }
1506 1509
1507 1510 // True if there is nothing here.
1508 1511 bool is_clear() {
1509 1512 return (_jvms == NULL);
1510 1513 }
1511 1514
1512 1515 // Make there be nothing here.
1513 1516 void clear() {
1514 1517 _jvms = NULL;
1515 1518 }
1516 1519
1517 1520 // Make a new, clean node notes.
1518 1521 static Node_Notes* make(Compile* C) {
1519 1522 Node_Notes* nn = NEW_ARENA_ARRAY(C->comp_arena(), Node_Notes, 1);
1520 1523 nn->clear();
1521 1524 return nn;
1522 1525 }
1523 1526
1524 1527 Node_Notes* clone(Compile* C) {
1525 1528 Node_Notes* nn = NEW_ARENA_ARRAY(C->comp_arena(), Node_Notes, 1);
1526 1529 (*nn) = (*this);
1527 1530 return nn;
1528 1531 }
1529 1532
1530 1533 // Absorb any information from source.
1531 1534 bool update_from(Node_Notes* source) {
1532 1535 bool changed = false;
1533 1536 if (source != NULL) {
1534 1537 if (source->jvms() != NULL) {
1535 1538 set_jvms(source->jvms());
1536 1539 changed = true;
1537 1540 }
1538 1541 }
1539 1542 return changed;
1540 1543 }
1541 1544 };
1542 1545
1543 1546 // Inlined accessors for Compile::node_nodes that require the preceding class:
1544 1547 inline Node_Notes*
1545 1548 Compile::locate_node_notes(GrowableArray<Node_Notes*>* arr,
1546 1549 int idx, bool can_grow) {
1547 1550 assert(idx >= 0, "oob");
1548 1551 int block_idx = (idx >> _log2_node_notes_block_size);
1549 1552 int grow_by = (block_idx - (arr == NULL? 0: arr->length()));
1550 1553 if (grow_by >= 0) {
1551 1554 if (!can_grow) return NULL;
1552 1555 grow_node_notes(arr, grow_by + 1);
1553 1556 }
1554 1557 // (Every element of arr is a sub-array of length _node_notes_block_size.)
1555 1558 return arr->at(block_idx) + (idx & (_node_notes_block_size-1));
1556 1559 }
1557 1560
1558 1561 inline bool
1559 1562 Compile::set_node_notes_at(int idx, Node_Notes* value) {
1560 1563 if (value == NULL || value->is_clear())
1561 1564 return false; // nothing to write => write nothing
1562 1565 Node_Notes* loc = locate_node_notes(_node_note_array, idx, true);
1563 1566 assert(loc != NULL, "");
1564 1567 return loc->update_from(value);
1565 1568 }
1566 1569
1567 1570
1568 1571 //------------------------------TypeNode---------------------------------------
1569 1572 // Node with a Type constant.
1570 1573 class TypeNode : public Node {
1571 1574 protected:
1572 1575 virtual uint hash() const; // Check the type
1573 1576 virtual uint cmp( const Node &n ) const;
1574 1577 virtual uint size_of() const; // Size is bigger
1575 1578 const Type* const _type;
1576 1579 public:
1577 1580 void set_type(const Type* t) {
1578 1581 assert(t != NULL, "sanity");
1579 1582 debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH);
1580 1583 *(const Type**)&_type = t; // cast away const-ness
1581 1584 // If this node is in the hash table, make sure it doesn't need a rehash.
1582 1585 assert(check_hash == NO_HASH || check_hash == hash(), "type change must preserve hash code");
1583 1586 }
1584 1587 const Type* type() const { assert(_type != NULL, "sanity"); return _type; };
1585 1588 TypeNode( const Type *t, uint required ) : Node(required), _type(t) {
1586 1589 init_class_id(Class_Type);
1587 1590 }
1588 1591 virtual const Type *Value( PhaseTransform *phase ) const;
1589 1592 virtual const Type *bottom_type() const;
1590 1593 virtual uint ideal_reg() const;
1591 1594 #ifndef PRODUCT
1592 1595 virtual void dump_spec(outputStream *st) const;
1593 1596 #endif
1594 1597 };
1595 1598
1596 1599 #endif // SHARE_VM_OPTO_NODE_HPP
↓ open down ↓ |
823 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX