519 } 520 521 //------------------------------Invariance----------------------------------- 522 // Helper class for loop_predication_impl to compute invariance on the fly and 523 // clone invariants. 524 class Invariance : public StackObj { 525 VectorSet _visited, _invariant; 526 Node_Stack _stack; 527 VectorSet _clone_visited; 528 Node_List _old_new; // map of old to new (clone) 529 IdealLoopTree* _lpt; 530 PhaseIdealLoop* _phase; 531 532 // Helper function to set up the invariance for invariance computation 533 // If n is a known invariant, set up directly. Otherwise, look up the 534 // the possibility to push n onto the stack for further processing. 535 void visit(Node* use, Node* n) { 536 if (_lpt->is_invariant(n)) { // known invariant 537 _invariant.set(n->_idx); 538 } else if (!n->is_CFG()) { 539 Node *n_ctrl = _phase->ctrl_or_self(n); 540 Node *u_ctrl = _phase->ctrl_or_self(use); // self if use is a CFG 541 if (_phase->is_dominator(n_ctrl, u_ctrl)) { 542 _stack.push(n, n->in(0) == NULL ? 1 : 0); 543 } 544 } 545 } 546 547 // Compute invariance for "the_node" and (possibly) all its inputs recursively 548 // on the fly 549 void compute_invariance(Node* n) { 550 assert(_visited.test(n->_idx), "must be"); 551 visit(n, n); 552 while (_stack.is_nonempty()) { 553 Node* n = _stack.node(); 554 uint idx = _stack.index(); 555 if (idx == n->req()) { // all inputs are processed 556 _stack.pop(); 557 // n is invariant if it's inputs are all invariant 558 bool all_inputs_invariant = true; | 519 } 520 521 //------------------------------Invariance----------------------------------- 522 // Helper class for loop_predication_impl to compute invariance on the fly and 523 // clone invariants. 524 class Invariance : public StackObj { 525 VectorSet _visited, _invariant; 526 Node_Stack _stack; 527 VectorSet _clone_visited; 528 Node_List _old_new; // map of old to new (clone) 529 IdealLoopTree* _lpt; 530 PhaseIdealLoop* _phase; 531 532 // Helper function to set up the invariance for invariance computation 533 // If n is a known invariant, set up directly. Otherwise, look up the 534 // the possibility to push n onto the stack for further processing. 535 void visit(Node* use, Node* n) { 536 if (_lpt->is_invariant(n)) { // known invariant 537 _invariant.set(n->_idx); 538 } else if (!n->is_CFG()) { 539 if (n->Opcode() == Op_ShenandoahWriteBarrier) { 540 return; 541 } 542 Node *n_ctrl = _phase->ctrl_or_self(n); 543 Node *u_ctrl = _phase->ctrl_or_self(use); // self if use is a CFG 544 if (_phase->is_dominator(n_ctrl, u_ctrl)) { 545 _stack.push(n, n->in(0) == NULL ? 1 : 0); 546 } 547 } 548 } 549 550 // Compute invariance for "the_node" and (possibly) all its inputs recursively 551 // on the fly 552 void compute_invariance(Node* n) { 553 assert(_visited.test(n->_idx), "must be"); 554 visit(n, n); 555 while (_stack.is_nonempty()) { 556 Node* n = _stack.node(); 557 uint idx = _stack.index(); 558 if (idx == n->req()) { // all inputs are processed 559 _stack.pop(); 560 // n is invariant if it's inputs are all invariant 561 bool all_inputs_invariant = true; |