378 // Find an entry by its index value
379 for( uint i = 0; i < _max; i++ ) {
380 Node *m = _table[i];
381 if( !m || m == _sentinel ) continue;
382 if( m->_idx == (uint)idx ) return m;
383 }
384 return NULL;
385 }
386 #endif
387
388 #ifdef ASSERT
389 NodeHash::~NodeHash() {
390 // Unlock all nodes upon destruction of table.
391 if (_table != (Node**)badAddress) clear();
392 }
393
394 void NodeHash::operator=(const NodeHash& nh) {
395 // Unlock all nodes upon replacement of table.
396 if (&nh == this) return;
397 if (_table != (Node**)badAddress) clear();
398 memcpy(this, &nh, sizeof(*this));
399 // Do not increment hash_lock counts again.
400 // Instead, be sure we never again use the source table.
401 ((NodeHash*)&nh)->_table = (Node**)badAddress;
402 }
403
404
405 #endif
406
407
408 //=============================================================================
409 //------------------------------PhaseRemoveUseless-----------------------------
410 // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
411 PhaseRemoveUseless::PhaseRemoveUseless(PhaseGVN *gvn, Unique_Node_List *worklist, PhaseNumber phase_num) : Phase(phase_num),
412 _useful(Thread::current()->resource_area()) {
413
414 // Implementation requires 'UseLoopSafepoints == true' and an edge from root
415 // to each SafePointNode at a backward branch. Inserted in add_safepoint().
416 if( !UseLoopSafepoints || !OptoRemoveUseless ) return;
417
418 // Identify nodes that are reachable from below, useful.
1659
1660 #ifndef PRODUCT
1661 //------------------------------~PhaseCCP--------------------------------------
1662 PhaseCCP::~PhaseCCP() {
1663 inc_invokes();
1664 _total_constants += count_constants();
1665 }
1666 #endif
1667
1668
1669 #ifdef ASSERT
1670 static bool ccp_type_widens(const Type* t, const Type* t0) {
1671 assert(t->meet(t0) == t, "Not monotonic");
1672 switch (t->base() == t0->base() ? t->base() : Type::Top) {
1673 case Type::Int:
1674 assert(t0->isa_int()->_widen <= t->isa_int()->_widen, "widen increases");
1675 break;
1676 case Type::Long:
1677 assert(t0->isa_long()->_widen <= t->isa_long()->_widen, "widen increases");
1678 break;
1679 }
1680 return true;
1681 }
1682 #endif //ASSERT
1683
1684 //------------------------------analyze----------------------------------------
1685 void PhaseCCP::analyze() {
1686 // Initialize all types to TOP, optimistic analysis
1687 for (int i = C->unique() - 1; i >= 0; i--) {
1688 _types.map(i,Type::TOP);
1689 }
1690
1691 // Push root onto worklist
1692 Unique_Node_List worklist;
1693 worklist.push(C->root());
1694
1695 // Pull from worklist; compute new value; push changes out.
1696 // This loop is the meat of CCP.
1697 while( worklist.size() ) {
1698 Node *n = worklist.pop();
|
378 // Find an entry by its index value
379 for( uint i = 0; i < _max; i++ ) {
380 Node *m = _table[i];
381 if( !m || m == _sentinel ) continue;
382 if( m->_idx == (uint)idx ) return m;
383 }
384 return NULL;
385 }
386 #endif
387
388 #ifdef ASSERT
389 NodeHash::~NodeHash() {
390 // Unlock all nodes upon destruction of table.
391 if (_table != (Node**)badAddress) clear();
392 }
393
394 void NodeHash::operator=(const NodeHash& nh) {
395 // Unlock all nodes upon replacement of table.
396 if (&nh == this) return;
397 if (_table != (Node**)badAddress) clear();
398 memcpy((void*)this, (void*)&nh, sizeof(*this));
399 // Do not increment hash_lock counts again.
400 // Instead, be sure we never again use the source table.
401 ((NodeHash*)&nh)->_table = (Node**)badAddress;
402 }
403
404
405 #endif
406
407
408 //=============================================================================
409 //------------------------------PhaseRemoveUseless-----------------------------
410 // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
411 PhaseRemoveUseless::PhaseRemoveUseless(PhaseGVN *gvn, Unique_Node_List *worklist, PhaseNumber phase_num) : Phase(phase_num),
412 _useful(Thread::current()->resource_area()) {
413
414 // Implementation requires 'UseLoopSafepoints == true' and an edge from root
415 // to each SafePointNode at a backward branch. Inserted in add_safepoint().
416 if( !UseLoopSafepoints || !OptoRemoveUseless ) return;
417
418 // Identify nodes that are reachable from below, useful.
1659
1660 #ifndef PRODUCT
1661 //------------------------------~PhaseCCP--------------------------------------
1662 PhaseCCP::~PhaseCCP() {
1663 inc_invokes();
1664 _total_constants += count_constants();
1665 }
1666 #endif
1667
1668
1669 #ifdef ASSERT
1670 static bool ccp_type_widens(const Type* t, const Type* t0) {
1671 assert(t->meet(t0) == t, "Not monotonic");
1672 switch (t->base() == t0->base() ? t->base() : Type::Top) {
1673 case Type::Int:
1674 assert(t0->isa_int()->_widen <= t->isa_int()->_widen, "widen increases");
1675 break;
1676 case Type::Long:
1677 assert(t0->isa_long()->_widen <= t->isa_long()->_widen, "widen increases");
1678 break;
1679 default:
1680 break;
1681 }
1682 return true;
1683 }
1684 #endif //ASSERT
1685
1686 //------------------------------analyze----------------------------------------
1687 void PhaseCCP::analyze() {
1688 // Initialize all types to TOP, optimistic analysis
1689 for (int i = C->unique() - 1; i >= 0; i--) {
1690 _types.map(i,Type::TOP);
1691 }
1692
1693 // Push root onto worklist
1694 Unique_Node_List worklist;
1695 worklist.push(C->root());
1696
1697 // Pull from worklist; compute new value; push changes out.
1698 // This loop is the meat of CCP.
1699 while( worklist.size() ) {
1700 Node *n = worklist.pop();
|