659 // Special case: is_Call() returns true for both CallNode and MachCallNode. |
659 // Special case: is_Call() returns true for both CallNode and MachCallNode. |
660 bool is_Call() const { |
660 bool is_Call() const { |
661 return (_flags & Flag_is_Call) != 0; |
661 return (_flags & Flag_is_Call) != 0; |
662 } |
662 } |
663 |
663 |
|
664 CallNode* isa_Call() const { |
|
665 return is_Call() ? as_Call() : NULL; |
|
666 } |
|
667 |
664 CallNode *as_Call() const { // Only for CallNode (not for MachCallNode) |
668 CallNode *as_Call() const { // Only for CallNode (not for MachCallNode) |
665 assert((_class_id & ClassMask_Call) == Class_Call, "invalid node class"); |
669 assert((_class_id & ClassMask_Call) == Class_Call, "invalid node class"); |
666 return (CallNode*)this; |
670 return (CallNode*)this; |
667 } |
671 } |
668 |
672 |
669 #define DEFINE_CLASS_QUERY(type) \ |
673 #define DEFINE_CLASS_QUERY(type) \ |
670 bool is_##type() const { \ |
674 bool is_##type() const { \ |
671 return ((_class_id & ClassMask_##type) == Class_##type); \ |
675 return ((_class_id & ClassMask_##type) == Class_##type); \ |
672 } \ |
676 } \ |
673 type##Node *as_##type() const { \ |
677 type##Node *as_##type() const { \ |
674 assert(is_##type(), "invalid node class"); \ |
678 assert(is_##type(), "invalid node class"); \ |
675 return (type##Node*)this; \ |
679 return (type##Node*)this; \ |
|
680 } \ |
|
681 type##Node* isa_##type() const { \ |
|
682 return (is_##type()) ? as_##type() : NULL; \ |
676 } |
683 } |
677 |
684 |
678 DEFINE_CLASS_QUERY(AbstractLock) |
685 DEFINE_CLASS_QUERY(AbstractLock) |
679 DEFINE_CLASS_QUERY(Add) |
686 DEFINE_CLASS_QUERY(Add) |
680 DEFINE_CLASS_QUERY(AddP) |
687 DEFINE_CLASS_QUERY(AddP) |
1247 #endif //OPTO_DU_ITERATOR_ASSERT |
1254 #endif //OPTO_DU_ITERATOR_ASSERT |
1248 |
1255 |
1249 #undef I_VDUI_ONLY |
1256 #undef I_VDUI_ONLY |
1250 #undef VDUI_ONLY |
1257 #undef VDUI_ONLY |
1251 |
1258 |
|
1259 // An Iterator that truly follows the iterator pattern. Doesn't |
|
1260 // support deletion but could be made to. |
|
1261 // |
|
1262 // for (SimpleDUIterator i(n); i.has_next(); i.next()) { |
|
1263 // Node* m = i.get(); |
|
1264 // |
|
1265 class SimpleDUIterator : public StackObj { |
|
1266 private: |
|
1267 Node* node; |
|
1268 DUIterator_Fast i; |
|
1269 DUIterator_Fast imax; |
|
1270 public: |
|
1271 SimpleDUIterator(Node* n): node(n), i(n->fast_outs(imax)) {} |
|
1272 bool has_next() { return i < imax; } |
|
1273 void next() { i++; } |
|
1274 Node* get() { return node->fast_out(i); } |
|
1275 }; |
|
1276 |
1252 |
1277 |
1253 //----------------------------------------------------------------------------- |
1278 //----------------------------------------------------------------------------- |
1254 // Map dense integer indices to Nodes. Uses classic doubling-array trick. |
1279 // Map dense integer indices to Nodes. Uses classic doubling-array trick. |
1255 // Abstractly provides an infinite array of Node*'s, initialized to NULL. |
1280 // Abstractly provides an infinite array of Node*'s, initialized to NULL. |
1256 // Note that the constructor just zeros things, and since I use Arena |
1281 // Note that the constructor just zeros things, and since I use Arena |
1288 class Node_List : public Node_Array { |
1313 class Node_List : public Node_Array { |
1289 uint _cnt; |
1314 uint _cnt; |
1290 public: |
1315 public: |
1291 Node_List() : Node_Array(Thread::current()->resource_area()), _cnt(0) {} |
1316 Node_List() : Node_Array(Thread::current()->resource_area()), _cnt(0) {} |
1292 Node_List(Arena *a) : Node_Array(a), _cnt(0) {} |
1317 Node_List(Arena *a) : Node_Array(a), _cnt(0) {} |
|
1318 bool contains(Node* n) { |
|
1319 for (uint e = 0; e < size(); e++) { |
|
1320 if (at(e) == n) return true; |
|
1321 } |
|
1322 return false; |
|
1323 } |
1293 void insert( uint i, Node *n ) { Node_Array::insert(i,n); _cnt++; } |
1324 void insert( uint i, Node *n ) { Node_Array::insert(i,n); _cnt++; } |
1294 void remove( uint i ) { Node_Array::remove(i); _cnt--; } |
1325 void remove( uint i ) { Node_Array::remove(i); _cnt--; } |
1295 void push( Node *b ) { map(_cnt++,b); } |
1326 void push( Node *b ) { map(_cnt++,b); } |
1296 void yank( Node *n ); // Find and remove |
1327 void yank( Node *n ); // Find and remove |
1297 Node *pop() { return _nodes[--_cnt]; } |
1328 Node *pop() { return _nodes[--_cnt]; } |