392 } 393 394 //------------------------------Invariance----------------------------------- 395 // Helper class for loop_predication_impl to compute invariance on the fly and 396 // clone invariants. 397 class Invariance : public StackObj { 398 VectorSet _visited, _invariant; 399 Node_Stack _stack; 400 VectorSet _clone_visited; 401 Node_List _old_new; // map of old to new (clone) 402 IdealLoopTree* _lpt; 403 PhaseIdealLoop* _phase; 404 405 // Helper function to set up the invariance for invariance computation 406 // If n is a known invariant, set up directly. Otherwise, look up the 407 // the possibility to push n onto the stack for further processing. 408 void visit(Node* use, Node* n) { 409 if (_lpt->is_invariant(n)) { // known invariant 410 _invariant.set(n->_idx); 411 } else if (!n->is_CFG()) { 412 Node *n_ctrl = _phase->ctrl_or_self(n); 413 Node *u_ctrl = _phase->ctrl_or_self(use); // self if use is a CFG 414 if (_phase->is_dominator(n_ctrl, u_ctrl)) { 415 _stack.push(n, n->in(0) == NULL ? 1 : 0); 416 } 417 } 418 } 419 420 // Compute invariance for "the_node" and (possibly) all its inputs recursively 421 // on the fly 422 void compute_invariance(Node* n) { 423 assert(_visited.test(n->_idx), "must be"); 424 visit(n, n); 425 while (_stack.is_nonempty()) { 426 Node* n = _stack.node(); 427 uint idx = _stack.index(); 428 if (idx == n->req()) { // all inputs are processed 429 _stack.pop(); 430 // n is invariant if it's inputs are all invariant 431 bool all_inputs_invariant = true; | 392 } 393 394 //------------------------------Invariance----------------------------------- 395 // Helper class for loop_predication_impl to compute invariance on the fly and 396 // clone invariants. 397 class Invariance : public StackObj { 398 VectorSet _visited, _invariant; 399 Node_Stack _stack; 400 VectorSet _clone_visited; 401 Node_List _old_new; // map of old to new (clone) 402 IdealLoopTree* _lpt; 403 PhaseIdealLoop* _phase; 404 405 // Helper function to set up the invariance for invariance computation 406 // If n is a known invariant, set up directly. Otherwise, look up the 407 // the possibility to push n onto the stack for further processing. 408 void visit(Node* use, Node* n) { 409 if (_lpt->is_invariant(n)) { // known invariant 410 _invariant.set(n->_idx); 411 } else if (!n->is_CFG()) { 412 if (n->Opcode() == Op_ShenandoahLoadReferenceBarrier) { 413 return; 414 } 415 Node *n_ctrl = _phase->ctrl_or_self(n); 416 Node *u_ctrl = _phase->ctrl_or_self(use); // self if use is a CFG 417 if (_phase->is_dominator(n_ctrl, u_ctrl)) { 418 _stack.push(n, n->in(0) == NULL ? 1 : 0); 419 } 420 } 421 } 422 423 // Compute invariance for "the_node" and (possibly) all its inputs recursively 424 // on the fly 425 void compute_invariance(Node* n) { 426 assert(_visited.test(n->_idx), "must be"); 427 visit(n, n); 428 while (_stack.is_nonempty()) { 429 Node* n = _stack.node(); 430 uint idx = _stack.index(); 431 if (idx == n->req()) { // all inputs are processed 432 _stack.pop(); 433 // n is invariant if it's inputs are all invariant 434 bool all_inputs_invariant = true; |