Mercurial > hg > graal-compiler
comparison src/share/vm/opto/gcm.cpp @ 308:756b58154237
6611837: block frequency is zero
Summary: insert_goto_at should set frequency for newly created blocks
Reviewed-by: never
author | rasbold |
---|---|
date | Thu, 28 Aug 2008 10:22:12 -0700 |
parents | 9c2ecc2ffb12 |
children | 72c5366e5d86 |
comparison
equal
deleted
inserted
replaced
307:892493c3d862 | 308:756b58154237 |
---|---|
1607 //------------------------------succ_prob------------------------------------- | 1607 //------------------------------succ_prob------------------------------------- |
1608 // Determine the probability of reaching successor 'i' from the receiver block. | 1608 // Determine the probability of reaching successor 'i' from the receiver block. |
1609 float Block::succ_prob(uint i) { | 1609 float Block::succ_prob(uint i) { |
1610 int eidx = end_idx(); | 1610 int eidx = end_idx(); |
1611 Node *n = _nodes[eidx]; // Get ending Node | 1611 Node *n = _nodes[eidx]; // Get ending Node |
1612 int op = n->is_Mach() ? n->as_Mach()->ideal_Opcode() : n->Opcode(); | 1612 |
1613 int op = n->Opcode(); | |
1614 if (n->is_Mach()) { | |
1615 if (n->is_MachNullCheck()) { | |
1616 // Can only reach here if called after lcm. The original Op_If is gone, | |
1617 // so we attempt to infer the probability from one or both of the | |
1618 // successor blocks. | |
1619 assert(_num_succs == 2, "expecting 2 successors of a null check"); | |
1620 // If either successor has only one predecessor, then the | |
1621 // probabiltity estimate can be derived using the | |
1622 // relative frequency of the successor and this block. | |
1623 if (_succs[i]->num_preds() == 2) { | |
1624 return _succs[i]->_freq / _freq; | |
1625 } else if (_succs[1-i]->num_preds() == 2) { | |
1626 return 1 - (_succs[1-i]->_freq / _freq); | |
1627 } else { | |
1628 // Estimate using both successor frequencies | |
1629 float freq = _succs[i]->_freq; | |
1630 return freq / (freq + _succs[1-i]->_freq); | |
1631 } | |
1632 } | |
1633 op = n->as_Mach()->ideal_Opcode(); | |
1634 } | |
1635 | |
1613 | 1636 |
1614 // Switch on branch type | 1637 // Switch on branch type |
1615 switch( op ) { | 1638 switch( op ) { |
1616 case Op_CountedLoopEnd: | 1639 case Op_CountedLoopEnd: |
1617 case Op_If: { | 1640 case Op_If: { |