465 assert(block_no < _num_blocks, "illegal block number"); |
465 assert(block_no < _num_blocks, "illegal block number"); |
466 Block* in = _blocks[block_no]; |
466 Block* in = _blocks[block_no]; |
467 // get successor block succ_no |
467 // get successor block succ_no |
468 assert(succ_no < in->_num_succs, "illegal successor number"); |
468 assert(succ_no < in->_num_succs, "illegal successor number"); |
469 Block* out = in->_succs[succ_no]; |
469 Block* out = in->_succs[succ_no]; |
|
470 // Compute frequency of the new block. Do this before inserting |
|
471 // new block in case succ_prob() needs to infer the probability from |
|
472 // surrounding blocks. |
|
473 float freq = in->_freq * in->succ_prob(succ_no); |
470 // get ProjNode corresponding to the succ_no'th successor of the in block |
474 // get ProjNode corresponding to the succ_no'th successor of the in block |
471 ProjNode* proj = in->_nodes[in->_nodes.size() - in->_num_succs + succ_no]->as_Proj(); |
475 ProjNode* proj = in->_nodes[in->_nodes.size() - in->_num_succs + succ_no]->as_Proj(); |
472 // create region for basic block |
476 // create region for basic block |
473 RegionNode* region = new (C, 2) RegionNode(2); |
477 RegionNode* region = new (C, 2) RegionNode(2); |
474 region->init_req(1, proj); |
478 region->init_req(1, proj); |
489 for (uint i = 1; i < out->num_preds(); i++) { |
493 for (uint i = 1; i < out->num_preds(); i++) { |
490 if (out->pred(i) == proj) out->head()->set_req(i, gto); |
494 if (out->pred(i) == proj) out->head()->set_req(i, gto); |
491 } |
495 } |
492 // remap predecessor's successor to new block |
496 // remap predecessor's successor to new block |
493 in->_succs.map(succ_no, block); |
497 in->_succs.map(succ_no, block); |
|
498 // Set the frequency of the new block |
|
499 block->_freq = freq; |
494 // add new basic block to basic block list |
500 // add new basic block to basic block list |
495 _blocks.insert(block_no + 1, block); |
501 _blocks.insert(block_no + 1, block); |
496 _num_blocks++; |
502 _num_blocks++; |
497 } |
503 } |
498 |
504 |