Lines Matching refs:block

342         assert(block_of_op_with_id(def_pos) == block_of_op_with_id(interval->spill_definition_pos()), "block must be equal");
433 BlockBegin* block = block_at(i);
434 LIR_OpList* instructions = block->lir()->instructions_list();
438 // iterate all instructions of the block. skip the first because it is always a label
466 // prepare insertion buffer (appended when all instructions of the block are processed)
467 insertion_buffer.init(block->lir());
485 block->lir()->append(&insertion_buffer);
487 } // end of block iteration
494 // Compute depth-first and linear scan block orders, and number LIR_Op nodes for linear scan.
520 BlockBegin* block = block_at(i);
521 block->set_first_lir_instruction_id(op_id);
522 LIR_OpList* instructions = block->lir()->instructions_list();
530 _block_of_op.at_put(idx, block);
536 block->set_last_lir_instruction_id(op_id - 2);
546 // ********** Phase 2: compute local live sets separately for each block
547 // (sets live_gen and live_kill for each block)
583 BlockBegin* block = block_at(i);
588 if (block->is_set(BlockBegin::exception_entry_flag)) {
590 // implicitly defined (= killed) at the beginning of the block.
591 for_each_phi_fun(block, phi,
596 LIR_OpList* instructions = block->lir()->instructions_list();
599 // iterate all instructions of the block. skip the first because it is always a label
629 if (block->loop_index() >= 0) {
630 local_interval_in_loop.set_bit(reg, block->loop_index());
636 // fixed intervals are never live at block boundaries, so
639 // the entry block may have incoming values in registers, which is ok.
640 if (!opr->is_virtual_register() && block != ir()->start()) {
643 assert(live_kill.at(reg), "using fixed register that is not defined in this block");
647 assert(live_kill.at(reg), "using fixed register that is not defined in this block");
673 if (block->loop_index() >= 0) {
674 local_interval_in_loop.set_bit(reg, block->loop_index());
680 // fixed intervals are never live at block boundaries, so
706 if (block->loop_index() >= 0) {
707 local_interval_in_loop.set_bit(reg, block->loop_index());
713 // fixed intervals are never live at block boundaries, so
730 block->set_live_gen (live_gen);
731 block->set_live_kill(live_kill);
732 block->set_live_in (BitMap(live_size)); block->live_in().clear();
733 block->set_live_out (BitMap(live_size)); block->live_out().clear();
735 TRACE_LINEAR_SCAN(4, tty->print("live_gen B%d ", block->block_id()); print_bitmap(block->live_gen()));
736 TRACE_LINEAR_SCAN(4, tty->print("live_kill B%d ", block->block_id()); print_bitmap(block->live_kill()));
737 } // end of block iteration
749 // (sets live_in and live_out for each block)
760 // Perform a backward dataflow analysis to compute live_out and live_in for each block.
769 BlockBegin* block = block_at(i);
773 // live_out(block) is the union of live_in(sux), for successors sux of block
774 int n = block->number_of_sux();
775 int e = block->number_of_exception_handlers();
777 // block has successors
779 live_out.set_from(block->sux_at(0)->live_in());
781 live_out.set_union(block->sux_at(j)->live_in());
787 live_out.set_union(block->exception_handler_at(j)->live_in());
790 if (!block->live_out().is_same(live_out)) {
792 BitMap temp = block->live_out();
793 block->set_live_out(live_out);
802 // live_in(block) is the union of live_gen(block) with (live_out(block) & !live_kill(block))
804 BitMap live_in = block->live_in();
805 live_in.set_from(block->live_out());
806 live_in.set_difference(block->live_kill());
807 live_in.set_union(block->live_gen());
816 tty->print("(%d) live_in%c B%d ", iteration_count, c, block->block_id()); print_bitmap(block->live_in());
817 tty->print("(%d) live_out%c B%d ", iteration_count, c, block->block_id()); print_bitmap(block->live_out());
830 // check that fixed intervals are not live at block boundaries
833 BlockBegin* block = block_at(i);
835 assert(block->live_in().at(j) == false, "live_in set of fixed register must be empty");
836 assert(block->live_out().at(j) == false, "live_out set of fixed register must be empty");
837 assert(block->live_gen().at(j) == false, "live_gen set of fixed register must be empty");
842 // check that the live_in set of the first block is empty
847 tty->print_cr("Error: live_in set of first block must be empty (when this fails, virtual registers are used before they are defined)");
858 BlockBegin* block = block_at(j);
859 if (block->live_gen().at(i)) {
860 tty->print_cr(" used in block B%d", block->block_id());
862 if (block->live_kill().at(i)) {
863 tty->print_cr(" defined in block B%d", block->block_id());
871 assert(false, "live_in set of first block must be empty");
873 bailout("live_in set of first block not empty");
966 // start is the beginning of the current block until a def is encountered.)
1190 assert(block_of_op_with_id(move->id())->number_of_preds() == 0, "move from stack must be in first block");
1322 BlockBegin* block = block_at(i);
1323 LIR_OpList* instructions = block->lir()->instructions_list();
1324 int block_from = block->first_lir_instruction_id();
1325 int block_to = block->last_lir_instruction_id();
1330 // Update intervals for registers live at the end of this block;
1331 BitMap live = block->live_out();
1335 assert(number >= LIR_OprDesc::vreg_base, "fixed intervals must not be live on block bounds");
1342 // that the block was part of a non-natural loop, so it might
1344 if (block->is_set(BlockBegin::linear_scan_loop_end_flag) &&
1345 block->loop_index() != -1 &&
1346 is_interval_in_loop(number, block->loop_index())) {
1351 // iterate all instructions of the block in reverse order.
1416 } // end of block iteration
1674 Interval* LinearScan::interval_at_block_begin(BlockBegin* block, int reg_num) {
1678 return split_child_at_op_id(interval_at(reg_num), block->first_lir_instruction_id(), LIR_OpVisitState::outputMode);
1681 Interval* LinearScan::interval_at_block_end(BlockBegin* block, int reg_num) {
1685 return split_child_at_op_id(interval_at(reg_num), block->last_lir_instruction_id() + 1, LIR_OpVisitState::outputMode);
1727 assert(branch->cond() == lir_cond_always, "block does not end with an unconditional jump");
1736 assert(from_block->lir()->instructions_list()->at(0)->as_OpLabel() != NULL, "block does not start with a label");
1763 BlockBegin* block = block_at(i);
1765 // check if block has only one predecessor and only one successor
1766 if (block->number_of_preds() == 1 && block->number_of_sux() == 1 && block->number_of_exception_handlers() == 0) {
1767 LIR_OpList* instructions = block->lir()->instructions_list();
1768 assert(instructions->at(0)->code() == lir_label, "block must start with label");
1769 assert(instructions->last()->code() == lir_branch, "block with successors must end with branch");
1770 assert(instructions->last()->as_OpBranch()->cond() == lir_cond_always, "block with successor must end with unconditional branch");
1772 // check if block is empty (only label and branch)
1774 BlockBegin* pred = block->pred_at(0);
1775 BlockBegin* sux = block->sux_at(0);
1779 TRACE_LINEAR_SCAN(3, tty->print_cr("**** optimizing empty block B%d (pred: B%d, sux: B%d)", block->block_id(), pred->block_id(), sux->block_id()));
1780 block_completed.set_bit(block->linear_scan_number());
1782 // directly resolve between pred and sux (without looking at the empty block between)
1785 move_resolver.set_insert_position(block->lir(), 0);
1821 void LinearScan::resolve_exception_entry(BlockBegin* block, int reg_num, MoveResolver &move_resolver) {
1827 Interval* interval = interval_at_block_begin(block, reg_num);
1842 int from_op_id = block->first_lir_instruction_id();
1870 void LinearScan::resolve_exception_entry(BlockBegin* block, MoveResolver &move_resolver) {
1871 assert(block->is_set(BlockBegin::exception_entry_flag), "should not call otherwise");
1876 for (int r = (int)block->live_in().get_next_one_offset(0, size); r < size; r = (int)block->live_in().get_next_one_offset(r + 1, size)) {
1877 resolve_exception_entry(block, r, move_resolver);
1881 for_each_phi_fun(block, phi,
1882 resolve_exception_entry(block, phi->operand()->vreg_number(), move_resolver)
1887 move_resolver.set_insert_position(block->lir(), 0);
1905 // phi function of the exception entry block
1948 BlockBegin* block = handler->entry_block();
1950 for (int r = (int)block->live_in().get_next_one_offset(0, size); r < size; r = (int)block->live_in().get_next_one_offset(r + 1, size)) {
1955 for_each_phi_fun(block, phi,
1977 BlockBegin* block = block_at(i);
1978 if (block->is_set(BlockBegin::exception_entry_flag)) {
1979 resolve_exception_entry(block, move_resolver);
1984 BlockBegin* block = block_at(i);
1985 LIR_List* ops = block->lir();
1988 // iterate all instructions of the block. skip the first because it is always a label
2171 BlockBegin* block = block_of_op_with_id(op_id);
2172 if (block->number_of_sux() <= 1 && op_id == block->last_lir_instruction_id()) {
2173 // check if spill moves could have been appended at the end of this block, but
2176 LIR_OpBranch* branch = block->lir()->instructions_list()->last()->as_OpBranch();
2178 if (block->live_out().at(opr->vreg_number())) {
2179 assert(branch->cond() == lir_cond_always, "block does not end with an unconditional jump");
2180 assert(false, "can't get split child for the last branch of a block because the information would be incorrect (moves are inserted before the branch in resolve_data_flow)");
2201 assert(op_id == -1 || !is_block_begin(op_id), "holes at begin of block may also result from control flow");
2796 BlockBegin* block = block_of_op_with_id(op_id);
2797 if (block->number_of_sux() == 1 && op_id == block->last_lir_instruction_id()) {
2798 // generating debug information for the last instruction of a block.
2800 // and so the wrong operand would be returned (spill moves at block boundaries are not
2802 // Solution: use the first op_id of the branch target block instead.
2803 if (block->lir()->instructions_list()->last()->as_OpBranch() != NULL) {
2804 if (block->live_out().at(opr->vreg_number())) {
2805 op_id = block->sux_at(0)->first_lir_instruction_id();
3004 // iterate all instructions of the block and remove all null-values.
3027 BlockBegin* block = block_at(i);
3028 assign_reg_num(block->lir()->instructions_list(), iw);
3135 BlockBegin* block = block_at(i);
3136 tty->print("B%d [%d, %d, %d, %d] ", block->block_id(), block->first_lir_instruction_id(), block->last_lir_instruction_id(), block->loop_index(), block->loop_depth());
3174 TRACE_LINEAR_SCAN(2, tty->print_cr("********* verifying that unpinned constants are not alive across block boundaries"));
3269 BlockBegin* block = block_at(i);
3271 LIR_OpList* instructions = block->lir()->instructions_list();
3369 BlockBegin* block = block_at(i);
3370 BitMap live_at_edge = block->live_in();
3374 TRACE_LINEAR_SCAN(4, tty->print("checking interval %d of block B%d", r, block->block_id()));
3378 assert(value != NULL, "all intervals live across block boundaries must have Value");
3381 // TKR assert(value->as_Constant() == NULL || value->is_pinned(), "only pinned constants can be alive accross block boundaries");
3402 IntervalList* state_for_block(BlockBegin* block) { return _saved_states.at(block->block_id()); }
3403 void set_state_for_block(BlockBegin* block, IntervalList* saved_state) { _saved_states.at_put(block->block_id(), saved_state); }
3404 void add_to_work_list(BlockBegin* block) { if (!_work_list.contains(block)) _work_list.append(block); }
3411 void process_block(BlockBegin* block);
3413 void process_successor(BlockBegin* block, IntervalList* input_state);
3435 // setup input registers (method arguments) for first block
3457 BlockBegin* block = _work_list.at(0);
3460 process_block(block);
3464 void RegisterVerifier::process_block(BlockBegin* block) {
3465 TRACE_LINEAR_SCAN(2, tty->cr(); tty->print_cr("process_block B%d", block->block_id()));
3468 IntervalList* input_state = copy(state_for_block(block));
3484 // process all operations of the block
3485 process_operations(block->lir(), input_state);
3488 for (int i = 0; i < block->number_of_sux(); i++) {
3489 process_successor(block->sux_at(i), input_state);
3505 void RegisterVerifier::process_successor(BlockBegin* block, IntervalList* input_state) {
3506 IntervalList* saved_state = state_for_block(block);
3509 // this block was already processed before.
3524 TRACE_LINEAR_SCAN(4, tty->print_cr("process_successor B%d: invalidating slot %d", block->block_id(), i));
3530 // already processed block with correct input_state
3531 TRACE_LINEAR_SCAN(2, tty->print_cr("process_successor B%d: previous visit already correct", block->block_id()));
3533 // must re-visit this block
3534 TRACE_LINEAR_SCAN(2, tty->print_cr("process_successor B%d: must re-visit because input state changed", block->block_id()));
3535 add_to_work_list(block);
3539 // block was not processed before, so set initial input_state
3540 TRACE_LINEAR_SCAN(2, tty->print_cr("process_successor B%d: initial visit", block->block_id()));
3542 set_state_for_block(block, copy(input_state));
3543 add_to_work_list(block);
3577 // visit all instructions of the block
3867 TRACE_LINEAR_SCAN(4, tty->print_cr("MoveResolver: resolving mappings for Block B%d, index %d", _insert_list->block() != NULL ? _insert_list->block()->block_id() : -1, _insert_idx));
3952 TRACE_LINEAR_SCAN(4, tty->print_cr("MoveResolver: setting insert position to Block B%d, index %d", insert_list->block() != NULL ? insert_list->block()->block_id() : -1, insert_idx));
3961 TRACE_LINEAR_SCAN(4, tty->print_cr("MoveResolver: moving insert position to Block B%d, index %d", insert_list->block() != NULL ? insert_list->block()->block_id() : -1, insert_idx));
3969 // block changed -> append insertion_buffer because it is
3970 // bound to a specific block and create a new insertion_buffer
4979 assert(op_id > 0 && allocator()->block_of_op_with_id(op_id - 2) == op_block, "cannot insert move at block boundary");
4981 // calculate index of instruction inside instruction list of current block
4982 // the minimal index (for a block with no spill moves) can be calculated because the
4984 // When the block already contains spill moves, the index must be increased until the
5009 assert(from_block_nr < to_block_nr, "must cross block boundary");
5023 // block with lower loop-depth found -> split at the end of this block
5028 assert(optimal_split_pos > allocator()->max_lir_op_id() || allocator()->is_block_begin(optimal_split_pos), "algorithm must move split pos to block boundary");
5046 // beginning of a block, then min_split_pos is also a possible split position.
5047 // Use the block before as min_block, because then min_block->last_lir_instruction_id() + 2 == min_split_pos
5051 // when an interval ends at the end of the last block of the method
5053 // block at this op_id)
5058 // split position cannot be moved to block boundary, so split as late as possible
5059 TRACE_LINEAR_SCAN(4, tty->print_cr(" cannot move split pos to block boundary because min_pos and max_pos are in same block"));
5071 // seach optimal block boundary between min_split_pos and max_split_pos
5072 TRACE_LINEAR_SCAN(4, tty->print_cr(" moving split pos to optimal block boundary between block B%d and B%d", min_block->block_id(), max_block->block_id()));
5084 // the max-position to this loop block.
5089 TRACE_LINEAR_SCAN(4, tty->print_cr(" interval is used in loop that ends in block B%d, so trying to move max_block back from B%d to B%d", loop_block->block_id(), max_block->block_id(), loop_block->block_id()));
5090 assert(loop_block != min_block, "loop_block and min_block must be different because block boundary is needed between");
5151 assert(allocator()->is_block_begin(optimal_split_pos) || (optimal_split_pos % 2 == 1), "split pos must be odd when not on block boundary");
5152 assert(!allocator()->is_block_begin(optimal_split_pos) || (optimal_split_pos % 2 == 0), "split pos must be even on block boundary");
5227 assert(allocator()->is_block_begin(optimal_split_pos) || (optimal_split_pos % 2 == 1), "split pos must be odd when not on block boundary");
5228 assert(!allocator()->is_block_begin(optimal_split_pos) || (optimal_split_pos % 2 == 0), "split pos must be even on block boundary");
5803 // ignore the first block in the list (index 0 is not processed)
5805 BlockBegin* block = code->at(i);
5807 if (block->number_of_preds() > 1 && !block->is_set(BlockBegin::exception_entry_flag)) {
5808 optimizer.optimize_moves_at_block_end(block);
5810 if (block->number_of_sux() == 2) {
5811 optimizer.optimize_moves_at_block_begin(block);
5855 // at least one block is already empty -> no optimization possible
5888 void EdgeMoveOptimizer::optimize_moves_at_block_end(BlockBegin* block) {
5889 TRACE_LINEAR_SCAN(4, tty->print_cr("optimizing moves at end of block B%d", block->block_id()));
5891 if (block->is_predecessor(block)) {
5897 int num_preds = block->number_of_preds();
5899 assert(!block->is_set(BlockBegin::exception_entry_flag), "exception handlers not allowed");
5904 BlockBegin* pred = block->pred_at(i);
5914 assert(pred->sux_at(0) == block, "invalid control flow");
5915 assert(pred_instructions->last()->code() == lir_branch, "block with successor must end with branch");
5917 assert(pred_instructions->last()->as_OpBranch()->cond() == lir_cond_always, "block must end with unconditional branch");
5924 // ignore the unconditional branch at the end of the block
5942 // insert the instruction at the beginning of the current block
5943 block->lir()->insert_before(1, op);
5953 void EdgeMoveOptimizer::optimize_moves_at_block_begin(BlockBegin* block) {
5954 TRACE_LINEAR_SCAN(4, tty->print_cr("optimization moves at begin of block B%d", block->block_id()));
5957 int num_sux = block->number_of_sux();
5959 LIR_OpList* cur_instructions = block->lir()->instructions_list();
5962 assert(cur_instructions->last()->code() == lir_branch, "block with successor must end with branch");
5964 assert(cur_instructions->last()->as_OpBranch()->cond() == lir_cond_always, "block must end with unconditional branch");
5979 // now it is guaranteed that the block ends with two branch instructions.
5980 // the instructions are inserted at the end of the block before these two branches
5987 if ((op->code() == lir_branch || op->code() == lir_cond_float_branch) && ((LIR_OpBranch*)op)->block() != NULL) {
5988 assert(false, "block with two successors can have only two branch instructions");
5995 BlockBegin* sux = block->sux_at(i);
5998 assert(sux_instructions->at(0)->code() == lir_label, "block must start with label");
6005 assert(sux->pred_at(0) == block, "invalid control flow");
6008 // ignore the label at the beginning of the block
6025 // insert instruction at end of current block
6026 block->lir()->insert_before(insert_idx, op);
6047 // push the OSR entry block to the end so that we're not jumping over it.
6075 // the header_block is the last block instead of the first block of the loop
6095 BlockBegin* block = code->at(i);
6097 if (block->is_set(BlockBegin::linear_scan_loop_header_flag)) {
6098 reorder_short_loop(code, block, i);
6107 bool ControlFlowOptimizer::can_delete_block(BlockBegin* block) {
6108 if (block->number_of_sux() != 1 || block->number_of_exception_handlers() != 0 || block->is_entry_block()) {
6112 LIR_OpList* instructions = block->lir()->instructions_list();
6114 assert(instructions->length() >= 2, "block must have label and branch");
6118 assert(instructions->last()->as_OpBranch()->block() == block->sux_at(0), "branch target must be the successor");
6120 // block must have exactly one successor
6129 void ControlFlowOptimizer::substitute_branch_target(BlockBegin* block, BlockBegin* target_from, BlockBegin* target_to) {
6130 TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting empty block: substituting from B%d to B%d inside B%d", target_from->block_id(), target_to->block_id(), block->block_id()));
6132 LIR_OpList* instructions = block->lir()->instructions_list();
6142 if (branch->block() == target_from) {
6158 BlockBegin* block = code->at(old_pos);
6160 if (can_delete_block(block)) {
6161 BlockBegin* new_target = block->sux_at(0);
6164 if (block->is_set(BlockBegin::backward_branch_target_flag)) {
6173 for (j = block->number_of_preds() - 1; j >= 0; j--) {
6174 BlockBegin* pred = block->pred_at(j);
6182 substitute_branch_target(pred, block, new_target);
6183 pred->substitute_sux(block, new_target);
6186 // adjust position of this block in the block list if blocks before
6201 // skip the last block because there a branch is always necessary
6203 BlockBegin* block = code->at(i);
6204 LIR_OpList* instructions = block->lir()->instructions_list();
6211 assert(last_branch->block() != NULL, "last branch must always have a block as target");
6212 assert(last_branch->label() == last_branch->block()->label(), "must be equal");
6215 if (last_branch->block() == code->at(i + 1)) {
6217 TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting unconditional branch at end of block B%d", block->block_id()));
6239 if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) {
6241 TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id()));
6244 prev_branch->change_block(last_branch->block());
6265 BlockBegin* block = code->at(i);
6266 LIR_OpList* cur_instructions = block->lir()->instructions_list();
6271 // the block contains only a label and a return
6272 // if a predecessor ends with an unconditional jump to this block, then the jump
6275 // Note: the original block with only a return statement cannot be deleted completely
6276 // because the predecessors might have other (conditional) jumps to this block
6280 assert(block->number_of_sux() == 0 ||
6281 (return_converted.at(block->block_id()) && block->number_of_sux() == 1),
6287 for (int j = block->number_of_preds() - 1; j >= 0; j--) {
6288 BlockBegin* pred = block->pred_at(j);
6296 if (pred_last_branch->block() == block && pred_last_branch->cond() == lir_cond_always && pred_last_branch->info() == NULL) {
6314 BlockBegin* block = code->at(i);
6315 LIR_OpList* instructions = block->lir()->instructions_list();
6322 assert(op_branch->block() == NULL || code->index_of(op_branch->block()) != -1, "branch target not valid");
6327 for (j = 0; j < block->number_of_sux() - 1; j++) {
6328 BlockBegin* sux = block->sux_at(j);
6332 for (j = 0; j < block->number_of_preds() - 1; j++) {
6333 BlockBegin* pred = block->pred_at(j);
6558 if (branch->block() == NULL) {