src/share/vm/opto/phaseX.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8129847-8u-dev Sdiff src/share/vm/opto

src/share/vm/opto/phaseX.cpp

Print this page




 381   if (_table != (Node**)badAddress)  clear();
 382 }
 383 
 384 void NodeHash::operator=(const NodeHash& nh) {
 385   // Unlock all nodes upon replacement of table.
 386   if (&nh == this)  return;
 387   if (_table != (Node**)badAddress)  clear();
 388   memcpy(this, &nh, sizeof(*this));
 389   // Do not increment hash_lock counts again.
 390   // Instead, be sure we never again use the source table.
 391   ((NodeHash*)&nh)->_table = (Node**)badAddress;
 392 }
 393 
 394 
 395 #endif
 396 
 397 
 398 //=============================================================================
 399 //------------------------------PhaseRemoveUseless-----------------------------
 400 // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
 401 PhaseRemoveUseless::PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ) : Phase(Remove_Useless),
 402   _useful(Thread::current()->resource_area()) {
 403 
 404   // Implementation requires 'UseLoopSafepoints == true' and an edge from root
 405   // to each SafePointNode at a backward branch.  Inserted in add_safepoint().
 406   if( !UseLoopSafepoints || !OptoRemoveUseless ) return;
 407 
 408   // Identify nodes that are reachable from below, useful.
 409   C->identify_useful_nodes(_useful);
 410   // Update dead node list
 411   C->update_dead_node_list(_useful);
 412 
 413   // Remove all useless nodes from PhaseValues' recorded types
 414   // Must be done before disconnecting nodes to preserve hash-table-invariant
 415   gvn->remove_useless_nodes(_useful.member_set());
 416 
 417   // Remove all useless nodes from future worklist
 418   worklist->remove_useless_nodes(_useful.member_set());
 419 
 420   // Disconnect 'useless' nodes that are adjacent to useful nodes
 421   C->remove_useless_nodes(_useful);
 422 
 423   // Remove edges from "root" to each SafePoint at a backward branch.
 424   // They were inserted during parsing (see add_safepoint()) to make infinite
 425   // loops without calls or exceptions visible to root, i.e., useful.
 426   Node *root = C->root();
 427   if( root != NULL ) {
 428     for( uint i = root->req(); i < root->len(); ++i ) {
 429       Node *n = root->in(i);
 430       if( n != NULL && n->is_SafePoint() ) {
 431         root->rm_prec(i);
 432         --i;
 433       }
 434     }
 435   }












































































 436 }
 437 
 438 
 439 //=============================================================================
 440 //------------------------------PhaseTransform---------------------------------
 441 PhaseTransform::PhaseTransform( PhaseNumber pnum ) : Phase(pnum),
 442   _arena(Thread::current()->resource_area()),
 443   _nodes(_arena),
 444   _types(_arena)
 445 {
 446   init_con_caches();
 447 #ifndef PRODUCT
 448   clear_progress();
 449   clear_transforms();
 450   set_allow_progress(true);
 451 #endif
 452   // Force allocation for currently existing nodes
 453   _types.map(C->unique(), NULL);
 454 }
 455 




 381   if (_table != (Node**)badAddress)  clear();
 382 }
 383 
 384 void NodeHash::operator=(const NodeHash& nh) {
 385   // Unlock all nodes upon replacement of table.
 386   if (&nh == this)  return;
 387   if (_table != (Node**)badAddress)  clear();
 388   memcpy(this, &nh, sizeof(*this));
 389   // Do not increment hash_lock counts again.
 390   // Instead, be sure we never again use the source table.
 391   ((NodeHash*)&nh)->_table = (Node**)badAddress;
 392 }
 393 
 394 
 395 #endif
 396 
 397 
 398 //=============================================================================
 399 //------------------------------PhaseRemoveUseless-----------------------------
 400 // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
 401 PhaseRemoveUseless::PhaseRemoveUseless(PhaseGVN *gvn, Unique_Node_List *worklist, PhaseNumber phase_num) : Phase(phase_num),
 402   _useful(Thread::current()->resource_area()) {
 403 
 404   // Implementation requires 'UseLoopSafepoints == true' and an edge from root
 405   // to each SafePointNode at a backward branch.  Inserted in add_safepoint().
 406   if( !UseLoopSafepoints || !OptoRemoveUseless ) return;
 407 
 408   // Identify nodes that are reachable from below, useful.
 409   C->identify_useful_nodes(_useful);
 410   // Update dead node list
 411   C->update_dead_node_list(_useful);
 412 
 413   // Remove all useless nodes from PhaseValues' recorded types
 414   // Must be done before disconnecting nodes to preserve hash-table-invariant
 415   gvn->remove_useless_nodes(_useful.member_set());
 416 
 417   // Remove all useless nodes from future worklist
 418   worklist->remove_useless_nodes(_useful.member_set());
 419 
 420   // Disconnect 'useless' nodes that are adjacent to useful nodes
 421   C->remove_useless_nodes(_useful);
 422 
 423   // Remove edges from "root" to each SafePoint at a backward branch.
 424   // They were inserted during parsing (see add_safepoint()) to make infinite
 425   // loops without calls or exceptions visible to root, i.e., useful.
 426   Node *root = C->root();
 427   if( root != NULL ) {
 428     for( uint i = root->req(); i < root->len(); ++i ) {
 429       Node *n = root->in(i);
 430       if( n != NULL && n->is_SafePoint() ) {
 431         root->rm_prec(i);
 432         --i;
 433       }
 434     }
 435   }
 436 }
 437 
 438 //=============================================================================
 439 //------------------------------PhaseRenumberLive------------------------------
 440 // First, remove useless nodes (equivalent to identifying live nodes).
 441 // Then, renumber live nodes.
 442 //
 443 // The set of live nodes is returned by PhaseRemoveUseless in the _useful structure.
 444 // If the number of live nodes is 'x' (where 'x' == _useful.size()), then the
 445 // PhaseRenumberLive updates the node ID of each node (the _idx field) with a unique
 446 // value in the range [0, x).
 447 //
 448 // At the end of the PhaseRenumberLive phase, the compiler's count of unique nodes is
 449 // updated to 'x' and the list of dead nodes is reset (as there are no dead nodes).
 450 //
 451 // The PhaseRenumberLive phase updates two data structures with the new node IDs.
 452 // (1) The worklist is used by the PhaseIterGVN phase to identify nodes that must be
 453 // processed. A new worklist (with the updated node IDs) is returned in 'new_worklist'.
 454 // (2) Type information (the field PhaseGVN::_types) maps type information to each
 455 // node ID. The mapping is updated to use the new node IDs as well. Updated type
 456 // information is returned in PhaseGVN::_types.
 457 //
 458 // The PhaseRenumberLive phase does not preserve the order of elements in the worklist.
 459 //
 460 // Other data structures used by the compiler are not updated. The hash table for value
 461 // numbering (the field PhaseGVN::_table) is not updated because computing the hash
 462 // values is not based on node IDs. The field PhaseGVN::_nodes is not updated either
 463 // because it is empty wherever PhaseRenumberLive is used.
 464 PhaseRenumberLive::PhaseRenumberLive(PhaseGVN* gvn,
 465                                      Unique_Node_List* worklist, Unique_Node_List* new_worklist,
 466                                      PhaseNumber phase_num) :
 467   PhaseRemoveUseless(gvn, worklist, Renumber_Live) {
 468 
 469   assert(RenumberLiveNodes, "RenumberLiveNodes must be set to true for node renumbering to take place");
 470   assert(C->live_nodes() == _useful.size(), "the number of live nodes must match the number of useful nodes");
 471   assert(gvn->nodes_size() == 0, "GVN must not contain any nodes at this point");
 472 
 473   uint old_unique_count = C->unique();
 474   uint live_node_count = C->live_nodes();
 475   uint worklist_size = worklist->size();
 476 
 477   // Storage for the updated type information.
 478   Type_Array new_type_array(C->comp_arena());
 479 
 480   // Iterate over the set of live nodes.
 481   uint current_idx = 0; // The current new node ID. Incremented after every assignment.
 482   for (uint i = 0; i < _useful.size(); i++) {
 483     Node* n = _useful.at(i);
 484     const Type* type = gvn->type_or_null(n);
 485     new_type_array.map(current_idx, type);
 486 
 487     bool in_worklist = false;
 488     if (worklist->member(n)) {
 489       in_worklist = true;
 490     }
 491 
 492     n->set_idx(current_idx); // Update node ID.
 493 
 494     if (in_worklist) {
 495       new_worklist->push(n);
 496     }
 497 
 498     current_idx++;
 499   }
 500 
 501   assert(worklist_size == new_worklist->size(), "the new worklist must have the same size as the original worklist");
 502   assert(live_node_count == current_idx, "all live nodes must be processed");
 503 
 504   // Replace the compiler's type information with the updated type information.
 505   gvn->replace_types(new_type_array);
 506 
 507   // Update the unique node count of the compilation to the number of currently live nodes.
 508   C->set_unique(live_node_count);
 509 
 510   // Set the dead node count to 0 and reset dead node list.
 511   C->reset_dead_node_list();
 512 }
 513 
 514 
 515 //=============================================================================
 516 //------------------------------PhaseTransform---------------------------------
 517 PhaseTransform::PhaseTransform( PhaseNumber pnum ) : Phase(pnum),
 518   _arena(Thread::current()->resource_area()),
 519   _nodes(_arena),
 520   _types(_arena)
 521 {
 522   init_con_caches();
 523 #ifndef PRODUCT
 524   clear_progress();
 525   clear_transforms();
 526   set_allow_progress(true);
 527 #endif
 528   // Force allocation for currently existing nodes
 529   _types.map(C->unique(), NULL);
 530 }
 531 


src/share/vm/opto/phaseX.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File