void LIR_Assembler::emit_block(BlockBegin* block) {
    if (block->is_set(BlockBegin::backward_branch_target_flag)) {
        align_backward_branch_target();
    }

    // if this block is the start of an exception handler, record the
    // PC offset of the first instruction for later construction of
    // the ExceptionHandlerTable
    if (block->is_set(BlockBegin::exception_entry_flag)) {
        block->set_exception_handler_pco(code_offset());
    }

#ifndef PRODUCT
    if (PrintLIRWithAssembly) {
        // don't print Phi's
        InstructionPrinter ip(false);
        block->print(ip);
    }
#endif /* PRODUCT */

    assert(block->lir() != NULL, "must have LIR");
    X86_ONLY(assert(_masm->rsp_offset() == 0, "frame size should be fixed"));

#ifndef PRODUCT
    if (CommentedAssembly) {
        stringStream st;
        st.print_cr(" block B%d [%d, %d]", block->block_id(), block->bci(), block->end()->printable_bci());
        _masm->block_comment(st.as_string());
    }
#endif

    emit_lir_list(block->lir());

    X86_ONLY(assert(_masm->rsp_offset() == 0, "frame size should be fixed"));
}
void LIR_Assembler::emit_exception_entries(ExceptionInfoList* info_list) {
    for (int i = 0; i < info_list->length(); i++) {
        XHandlers* handlers = info_list->at(i)->exception_handlers();

        for (int j = 0; j < handlers->length(); j++) {
            XHandler* handler = handlers->handler_at(j);
            assert(handler->lir_op_id() != -1, "handler not processed by LinearScan");
            assert(handler->entry_code() == NULL ||
                   handler->entry_code()->instructions_list()->last()->code() == lir_branch ||
                   handler->entry_code()->instructions_list()->last()->code() == lir_delay_slot, "last operation must be branch");

            if (handler->entry_pco() == -1) {
                // entry code not emitted yet
                if (handler->entry_code() != NULL && handler->entry_code()->instructions_list()->length() > 1) {
                    handler->set_entry_pco(code_offset());
                    if (CommentedAssembly) {
                        _masm->block_comment("Exception adapter block");
                    }
                    emit_lir_list(handler->entry_code());
                } else {
                    handler->set_entry_pco(handler->entry_block()->exception_handler_pco());
                }

                assert(handler->entry_pco() != -1, "must be set now");
            }
        }
    }
}
void LIR_Assembler::emit_exception_entries(ExceptionInfoList* info_list) {
  // tell these to the MacroAssembler 

  for (int i = 0; i < info_list->length(); i++) {
    XHandlers* handlers = info_list->at(i)->exception_handlers();

    for (int j = 0; j < handlers->length(); j++) {
      XHandler* handler = handlers->handler_at(j);
      assert(handler->lir_op_id() != -1, "handler not processed by LinearScan");
      assert(handler->entry_code() == NULL ||
handler->entry_code()->instructions_list()->last()->code()==lir_branch,"last operation must be branch");

      if (!handler->entry_lbl()) {
        // entry code not emitted yet
        if (handler->entry_code() != NULL && handler->entry_code()->instructions_list()->length() > 1) {
          handler->set_entry_lbl(new Label(_masm)); // bind label here
          _masm->block_comment("Exception adapter block");
          emit_lir_list(handler->entry_code());
        } else {
handler->set_entry_lbl(handler->entry_block()->label());
        }
      }
    }
  }
}
void LIR_Assembler::emit_block(BlockBegin* block) {
  if (block->is_set(BlockBegin::backward_branch_target_flag)) {
    align_backward_branch_target(); 
  }

#ifndef PRODUCT
  if (PrintLIRWithAssembly) {
    // don't print Phi's
    InstructionPrinter ip(false);
    block->print(ip);
  }
#endif /* PRODUCT */

  assert(block->lir() != NULL, "must have LIR");

#ifndef PRODUCT
  stringStream st;
  st.print_cr(" block B%d [%d, %d]", block->block_id(), block->bci(), block->end()->bci());
  _masm->block_comment(st.as_string());
#endif

  emit_lir_list(block->lir());

}