mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
6611837: block frequency is zero
Insert_goto_at should set frequency for newly created blocks Reviewed-by: never
This commit is contained in:
parent
8ab0a4d7a9
commit
bdd62705f2
2 changed files with 30 additions and 1 deletions
|
@ -467,6 +467,10 @@ void PhaseCFG::insert_goto_at(uint block_no, uint succ_no) {
|
||||||
// get successor block succ_no
|
// get successor block succ_no
|
||||||
assert(succ_no < in->_num_succs, "illegal successor number");
|
assert(succ_no < in->_num_succs, "illegal successor number");
|
||||||
Block* out = in->_succs[succ_no];
|
Block* out = in->_succs[succ_no];
|
||||||
|
// Compute frequency of the new block. Do this before inserting
|
||||||
|
// new block in case succ_prob() needs to infer the probability from
|
||||||
|
// surrounding blocks.
|
||||||
|
float freq = in->_freq * in->succ_prob(succ_no);
|
||||||
// get ProjNode corresponding to the succ_no'th successor of the in block
|
// get ProjNode corresponding to the succ_no'th successor of the in block
|
||||||
ProjNode* proj = in->_nodes[in->_nodes.size() - in->_num_succs + succ_no]->as_Proj();
|
ProjNode* proj = in->_nodes[in->_nodes.size() - in->_num_succs + succ_no]->as_Proj();
|
||||||
// create region for basic block
|
// create region for basic block
|
||||||
|
@ -491,6 +495,8 @@ void PhaseCFG::insert_goto_at(uint block_no, uint succ_no) {
|
||||||
}
|
}
|
||||||
// remap predecessor's successor to new block
|
// remap predecessor's successor to new block
|
||||||
in->_succs.map(succ_no, block);
|
in->_succs.map(succ_no, block);
|
||||||
|
// Set the frequency of the new block
|
||||||
|
block->_freq = freq;
|
||||||
// add new basic block to basic block list
|
// add new basic block to basic block list
|
||||||
_blocks.insert(block_no + 1, block);
|
_blocks.insert(block_no + 1, block);
|
||||||
_num_blocks++;
|
_num_blocks++;
|
||||||
|
|
|
@ -1609,7 +1609,30 @@ void CFGLoop::compute_freq() {
|
||||||
float Block::succ_prob(uint i) {
|
float Block::succ_prob(uint i) {
|
||||||
int eidx = end_idx();
|
int eidx = end_idx();
|
||||||
Node *n = _nodes[eidx]; // Get ending Node
|
Node *n = _nodes[eidx]; // Get ending Node
|
||||||
int op = n->is_Mach() ? n->as_Mach()->ideal_Opcode() : n->Opcode();
|
|
||||||
|
int op = n->Opcode();
|
||||||
|
if (n->is_Mach()) {
|
||||||
|
if (n->is_MachNullCheck()) {
|
||||||
|
// Can only reach here if called after lcm. The original Op_If is gone,
|
||||||
|
// so we attempt to infer the probability from one or both of the
|
||||||
|
// successor blocks.
|
||||||
|
assert(_num_succs == 2, "expecting 2 successors of a null check");
|
||||||
|
// If either successor has only one predecessor, then the
|
||||||
|
// probabiltity estimate can be derived using the
|
||||||
|
// relative frequency of the successor and this block.
|
||||||
|
if (_succs[i]->num_preds() == 2) {
|
||||||
|
return _succs[i]->_freq / _freq;
|
||||||
|
} else if (_succs[1-i]->num_preds() == 2) {
|
||||||
|
return 1 - (_succs[1-i]->_freq / _freq);
|
||||||
|
} else {
|
||||||
|
// Estimate using both successor frequencies
|
||||||
|
float freq = _succs[i]->_freq;
|
||||||
|
return freq / (freq + _succs[1-i]->_freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
op = n->as_Mach()->ideal_Opcode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Switch on branch type
|
// Switch on branch type
|
||||||
switch( op ) {
|
switch( op ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue