Mercurial > hg > graal-compiler
comparison src/share/vm/opto/loopTransform.cpp @ 7196:2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
Summary: keep an (almost) accurate running count of the reachable (live) flow graph nodes.
Reviewed-by: kvn, twisti, jrose, vlivanov
author | bharadwaj |
---|---|
date | Tue, 27 Nov 2012 17:24:15 -0800 |
parents | d2582a08fa5d |
children | b30b3c2a0cf2 |
comparison
equal
deleted
inserted
replaced
7195:2cd5e15048e6 | 7196:2aff40cb4703 |
---|---|
267 // Return TRUE or FALSE if the loop should be peeled or not. Peel if we can | 267 // Return TRUE or FALSE if the loop should be peeled or not. Peel if we can |
268 // make some loop-invariant test (usually a null-check) happen before the loop. | 268 // make some loop-invariant test (usually a null-check) happen before the loop. |
269 bool IdealLoopTree::policy_peeling( PhaseIdealLoop *phase ) const { | 269 bool IdealLoopTree::policy_peeling( PhaseIdealLoop *phase ) const { |
270 Node *test = ((IdealLoopTree*)this)->tail(); | 270 Node *test = ((IdealLoopTree*)this)->tail(); |
271 int body_size = ((IdealLoopTree*)this)->_body.size(); | 271 int body_size = ((IdealLoopTree*)this)->_body.size(); |
272 int uniq = phase->C->unique(); | 272 int live_node_count = phase->C->live_nodes(); |
273 // Peeling does loop cloning which can result in O(N^2) node construction | 273 // Peeling does loop cloning which can result in O(N^2) node construction |
274 if( body_size > 255 /* Prevent overflow for large body_size */ | 274 if( body_size > 255 /* Prevent overflow for large body_size */ |
275 || (body_size * body_size + uniq > MaxNodeLimit) ) { | 275 || (body_size * body_size + live_node_count > MaxNodeLimit) ) { |
276 return false; // too large to safely clone | 276 return false; // too large to safely clone |
277 } | 277 } |
278 while( test != _head ) { // Scan till run off top of loop | 278 while( test != _head ) { // Scan till run off top of loop |
279 if( test->is_If() ) { // Test? | 279 if( test->is_If() ) { // Test? |
280 Node *ctrl = phase->get_ctrl(test->in(1)); | 280 Node *ctrl = phase->get_ctrl(test->in(1)); |
599 uint tst_body_size = (new_body_size - EMPTY_LOOP_SIZE) / trip_count + EMPTY_LOOP_SIZE; | 599 uint tst_body_size = (new_body_size - EMPTY_LOOP_SIZE) / trip_count + EMPTY_LOOP_SIZE; |
600 if (body_size != tst_body_size) // Check for int overflow | 600 if (body_size != tst_body_size) // Check for int overflow |
601 return false; | 601 return false; |
602 if (new_body_size > unroll_limit || | 602 if (new_body_size > unroll_limit || |
603 // Unrolling can result in a large amount of node construction | 603 // Unrolling can result in a large amount of node construction |
604 new_body_size >= MaxNodeLimit - phase->C->unique()) { | 604 new_body_size >= MaxNodeLimit - (uint) phase->C->live_nodes()) { |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 // Do not unroll a loop with String intrinsics code. | 608 // Do not unroll a loop with String intrinsics code. |
609 // String intrinsics are large and have loops. | 609 // String intrinsics are large and have loops. |
2266 } | 2266 } |
2267 } | 2267 } |
2268 | 2268 |
2269 // Skip next optimizations if running low on nodes. Note that | 2269 // Skip next optimizations if running low on nodes. Note that |
2270 // policy_unswitching and policy_maximally_unroll have this check. | 2270 // policy_unswitching and policy_maximally_unroll have this check. |
2271 uint nodes_left = MaxNodeLimit - phase->C->unique(); | 2271 uint nodes_left = MaxNodeLimit - (uint) phase->C->live_nodes(); |
2272 if ((2 * _body.size()) > nodes_left) { | 2272 if ((2 * _body.size()) > nodes_left) { |
2273 return true; | 2273 return true; |
2274 } | 2274 } |
2275 | 2275 |
2276 // Counted loops may be peeled, may need some iterations run up | 2276 // Counted loops may be peeled, may need some iterations run up |