/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "opto/callnode.hpp"
#include "opto/chaitin.hpp"
#include "opto/machnode.hpp"
//=============================================================================
//------------------------------PhaseLive--------------------------------------
// problem is monotonic. The steady-state solution looks like this: pull a
// block from the worklist. It has a set of delta's - values which are newly
// live-in from the block. Push these to the live-out sets of all predecessor
// blocks. At each predecessor, the new live-out values are ANDed with what is
// already live-out (extra stuff is added to the live-out sets). Then the
// remaining new live-out values are ANDed with what is locally defined.
// Leftover bits become the new live-in for the predecessor block, and the pred
// block is put on the worklist.
// The locally live-in stuff is computed once and added to predecessor
// live-out sets. This separate compilation is done in the outer loop below.
PhaseLive::PhaseLive( const PhaseCFG &cfg, LRG_List &names, Arena *arena ) : Phase(LIVE), _cfg(cfg), _names(names), _arena(arena), _live(0) {
}
// Init the sparse live arrays. This data is live on exit from here!
// The _live info is the live-out info.
uint i;
for( i=0; i<_cfg._num_blocks; i++ ) {
}
// Init the sparse arrays for delta-sets.
// Does the memory used by _defs and _deltas get reclaimed? Does it matter? TT
// Array of values defined locally in blocks
for( i=0; i<_cfg._num_blocks; i++ ) {
}
// Array of delta-set pointers, indexed by block pre_order-1.
// Blocks having done pass-1
// Outer loop: must compute local live-in sets and push into predecessors.
// Compute the local live-in set. Start with any new live-out bits.
uint i;
if( n->is_Phi() ) break;
}
}
}
#ifdef ASSERT
#endif
// Remove anything defined by Phis and the block start instruction
for( uint k=i; k>0; k-- ) {
}
// Push these live-in things to predecessors
// PhiNode uses go in the live-out set of prior blocks.
for( uint k=i; k>0; k-- )
}
freeset( b );
// Inner loop: blocks that picked up new live-out values to be propagated
// !!!!!
// #ifdef ASSERT
iters++;
// #endif
// Add new-live-in to predecessors live-out sets
freeset(b);
} // End of while-worklist-not-empty
} // End of for-all-blocks-outer-loop
// We explicitly clear all of the IndexSets which we are about to release.
// This allows us to recycle their internal memory into IndexSet's free list.
for( i=0; i<_cfg._num_blocks; i++ ) {
if (_deltas[i]) {
// Is this always true?
}
}
}
}
//------------------------------stats------------------------------------------
#ifndef PRODUCT
}
#endif
//------------------------------getset-----------------------------------------
// Get an IndexSet for a block. Return existing one, if any. Make a new
// empty one if a prior one does not exist.
if( !delta ) // Not on worklist?
// Get a free set; flag as being on worklist
return delta; // Return set of new live-out items
}
//------------------------------getfreeset-------------------------------------
// Pull from free list, or allocate. Internal allocation on the returned set
// is always from thread local storage.
IndexSet *f = _free_IndexSet;
if( !f ) {
f = new IndexSet;
// f->set_arena(Thread::current()->resource_area());
} else {
// Pull from free list
_free_IndexSet = f->next();
//f->_cnt = 0; // Reset to empty
// f->set_arena(Thread::current()->resource_area());
}
return f;
}
//------------------------------freeset----------------------------------------
// Free an IndexSet from a block.
f->set_next(_free_IndexSet);
_free_IndexSet = f; // Drop onto free list
}
//------------------------------add_liveout------------------------------------
// Add a live-out value to a given blocks live-out set. If it is new, then
// also add it to the delta set and stick the block on the worklist.
// We extended the live-out set. See if the value is generated locally.
// If it is not, then we must extend the live-in set.
}
}
}
//------------------------------add_liveout------------------------------------
// Add a vector of live-out values to a given blocks live-out set.
uint r;
}
if( !on_worklist && // Not on worklist?
} else { // Nothing there; just free it
}
}
#ifndef PRODUCT
//------------------------------dump-------------------------------------------
// Dump the live-out set for a block
}
}
//------------------------------verify_base_ptrs-------------------------------
// Verify that base pointers and derived pointers are still sane.
#ifdef ASSERT
if( n->is_Phi() ) break;
// Found a safepoint?
if( n->is_MachSafePoint() ) {
// Now scan for a live derived pointer
// search upwards through spills and spill phis for AddP
uint k = 0;
// See PhaseChaitin::find_base_for_derived() for all cases.
if( isc ) {
if (is_derived) {
// Derived is NULL+offset
assert(!is_derived || check->bottom_type()->is_ptr()->ptr() == TypePtr::Null,"Bad derived pointer");
} else {
// Base either ConP(NULL) or loadConP
} else {
}
}
#ifdef _LP64
#endif
// Valid nodes
} else {
assert(false,"Bad base or derived pointer");
}
} else {
}
k++;
} // End while
}
} // End of check for derived pointers
} // End of Kcheck for debug info
} // End of if found a safepoint
} // End of forall instructions in block
} // End of forall blocks
#endif
}
//------------------------------verify-------------------------------------
// Verify that graphs and base pointers are still sane.
#ifdef ASSERT
if( VerifyOpto || VerifyRegisterAllocator ) {
verify_base_ptrs(a);
if(verify_ifg)
}
#endif
}
#endif