421 void compute_invariance(Node* n) {
422 assert(_visited.test(n->_idx), "must be");
423 visit(n, n);
424 while (_stack.is_nonempty()) {
425 Node* n = _stack.node();
426 uint idx = _stack.index();
427 if (idx == n->req()) { // all inputs are processed
428 _stack.pop();
429 // n is invariant if it's inputs are all invariant
430 bool all_inputs_invariant = true;
431 for (uint i = 0; i < n->req(); i++) {
432 Node* in = n->in(i);
433 if (in == NULL) continue;
434 assert(_visited.test(in->_idx), "must have visited input");
435 if (!_invariant.test(in->_idx)) { // bad guy
436 all_inputs_invariant = false;
437 break;
438 }
439 }
440 if (all_inputs_invariant) {
441 _invariant.set(n->_idx); // I am a invariant too
442 }
443 } else { // process next input
444 _stack.set_index(idx + 1);
445 Node* m = n->in(idx);
446 if (m != NULL && !_visited.test_set(m->_idx)) {
447 visit(n, m);
448 }
449 }
450 }
451 }
452
453 // Helper function to set up _old_new map for clone_nodes.
454 // If n is a known invariant, set up directly ("clone" of n == n).
455 // Otherwise, push n onto the stack for real cloning.
456 void clone_visit(Node* n) {
457 assert(_invariant.test(n->_idx), "must be invariant");
458 if (_lpt->is_invariant(n)) { // known invariant
459 _old_new.map(n->_idx, n);
460 } else { // to be cloned
461 assert(!n->is_CFG(), "should not see CFG here");
|
421 void compute_invariance(Node* n) {
422 assert(_visited.test(n->_idx), "must be");
423 visit(n, n);
424 while (_stack.is_nonempty()) {
425 Node* n = _stack.node();
426 uint idx = _stack.index();
427 if (idx == n->req()) { // all inputs are processed
428 _stack.pop();
429 // n is invariant if it's inputs are all invariant
430 bool all_inputs_invariant = true;
431 for (uint i = 0; i < n->req(); i++) {
432 Node* in = n->in(i);
433 if (in == NULL) continue;
434 assert(_visited.test(in->_idx), "must have visited input");
435 if (!_invariant.test(in->_idx)) { // bad guy
436 all_inputs_invariant = false;
437 break;
438 }
439 }
440 if (all_inputs_invariant) {
441 // If n's control is a predicate that was moved out of the
442 // loop, it was marked invariant but n is only invariant if
443 // it depends only on that test. Otherwise, unless that test
444 // is out of the loop, it's not invariant.
445 if (n->is_CFG() || n->depends_only_on_test() || n->in(0) == NULL || !_phase->is_member(_lpt, n->in(0))) {
446 _invariant.set(n->_idx); // I am a invariant too
447 }
448 }
449 } else { // process next input
450 _stack.set_index(idx + 1);
451 Node* m = n->in(idx);
452 if (m != NULL && !_visited.test_set(m->_idx)) {
453 visit(n, m);
454 }
455 }
456 }
457 }
458
459 // Helper function to set up _old_new map for clone_nodes.
460 // If n is a known invariant, set up directly ("clone" of n == n).
461 // Otherwise, push n onto the stack for real cloning.
462 void clone_visit(Node* n) {
463 assert(_invariant.test(n->_idx), "must be invariant");
464 if (_lpt->is_invariant(n)) { // known invariant
465 _old_new.map(n->_idx, n);
466 } else { // to be cloned
467 assert(!n->is_CFG(), "should not see CFG here");
|