8137160: Use Compile::live_nodes instead of Compile::unique() in appropriate places -- followup
Summary: Change two code locations to use live_nodes() instead of unique() for allocating memory. Adjust comments.
Reviewed-by: kvn
--- a/hotspot/src/share/vm/opto/compile.cpp Wed Oct 07 06:56:58 2015 -0400
+++ b/hotspot/src/share/vm/opto/compile.cpp Thu Oct 08 12:10:19 2015 +0200
@@ -317,7 +317,7 @@
// Use breadth-first pass that records state in a Unique_Node_List,
// recursive traversal is slower.
void Compile::identify_useful_nodes(Unique_Node_List &useful) {
- int estimated_worklist_size = unique();
+ int estimated_worklist_size = live_nodes();
useful.map( estimated_worklist_size, NULL ); // preallocate space
// Initialize worklist
@@ -3314,7 +3314,7 @@
Final_Reshape_Counts frc;
// Visit everybody reachable!
- // Allocate stack of size C->unique()/2 to avoid frequent realloc
+ // Allocate stack of size C->live_nodes()/2 to avoid frequent realloc
Node_Stack nstack(live_nodes() >> 1);
final_graph_reshaping_walk(nstack, root(), frc);
--- a/hotspot/src/share/vm/opto/domgraph.cpp Wed Oct 07 06:56:58 2015 -0400
+++ b/hotspot/src/share/vm/opto/domgraph.cpp Thu Oct 08 12:10:19 2015 +0200
@@ -506,7 +506,7 @@
// Perform DFS search. Setup 'vertex' as DFS to vertex mapping. Setup
// 'semi' as vertex to DFS mapping. Set 'parent' to DFS parent.
int NTarjan::DFS( NTarjan *ntarjan, VectorSet &visited, PhaseIdealLoop *pil, uint *dfsorder) {
- // Allocate stack of size C->unique()/8 to avoid frequent realloc
+ // Allocate stack of size C->live_nodes()/8 to avoid frequent realloc
GrowableArray <Node *> dfstack(pil->C->live_nodes() >> 3);
Node *b = pil->C->root();
int dfsnum = 1;
--- a/hotspot/src/share/vm/opto/matcher.cpp Wed Oct 07 06:56:58 2015 -0400
+++ b/hotspot/src/share/vm/opto/matcher.cpp Thu Oct 08 12:10:19 2015 +0200
@@ -326,14 +326,14 @@
grow_new_node_array(C->unique());
// Reset node counter so MachNodes start with _idx at 0
- int nodes = C->unique(); // save value
+ int live_nodes = C->live_nodes();
C->set_unique(0);
C->reset_dead_node_list();
// Recursively match trees from old space into new space.
// Correct leaves of new-space Nodes; they point to old-space.
_visited.Clear(); // Clear visit bits for xform call
- C->set_cached_top_node(xform( C->top(), nodes ));
+ C->set_cached_top_node(xform( C->top(), live_nodes ));
if (!C->failing()) {
Node* xroot = xform( C->root(), 1 );
if (xroot == NULL) {
@@ -1001,7 +1001,7 @@
Node *Matcher::transform( Node *n ) { ShouldNotCallThis(); return n; }
Node *Matcher::xform( Node *n, int max_stack ) {
// Use one stack to keep both: child's node/state and parent's node/index
- MStack mstack(max_stack * 2 * 2); // C->unique() * 2 * 2
+ MStack mstack(max_stack * 2 * 2); // usually: C->live_nodes() * 2 * 2
mstack.push(n, Visit, NULL, -1); // set NULL as parent to indicate root
while (mstack.is_nonempty()) {
@@ -2076,7 +2076,7 @@
//------------------------------find_shared------------------------------------
// Set bits if Node is shared or otherwise a root
void Matcher::find_shared( Node *n ) {
- // Allocate stack of size C->unique() * 2 to avoid frequent realloc
+ // Allocate stack of size C->live_nodes() * 2 to avoid frequent realloc
MStack mstack(C->live_nodes() * 2);
// Mark nodes as address_visited if they are inputs to an address expression
VectorSet address_visited(Thread::current()->resource_area());