void LIR_Assembler::process_debug_info(LIR_Op* op) {
    Instruction* src = op->source();
    if (src == NULL)  return;
    int pc_offset = code_offset();
    if (_pending_non_safepoint == src) {
        _pending_non_safepoint_offset = pc_offset;
        return;
    }
    ValueStack* vstack = debug_info(src);
    if (vstack == NULL)  return;
    if (_pending_non_safepoint != NULL) {
        // Got some old debug info.  Get rid of it.
        if (debug_info(_pending_non_safepoint) == vstack) {
            _pending_non_safepoint_offset = pc_offset;
            return;
        }
        if (_pending_non_safepoint_offset < pc_offset) {
            record_non_safepoint_debug_info();
        }
        _pending_non_safepoint = NULL;
    }
    // Remember the debug info.
    if (pc_offset > compilation()->debug_info_recorder()->last_pc_offset()) {
        _pending_non_safepoint = src;
        _pending_non_safepoint_offset = pc_offset;
    }
}
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_op0(LIR_Op0* op) {
  switch (op->code()) {
    case lir_word_align: {
      while (code_offset() % BytesPerWord != 0) {
        _masm->nop();
      }
      break;
    }

    case lir_nop:
      assert(op->info() == NULL, "not supported");
      _masm->nop();
      break;

    case lir_label:
      Unimplemented();
      break;

    case lir_build_frame:
      build_frame();
      break;

    case lir_std_entry:
      _masm->align(CodeEntryAlignment);
_masm->set_code_start();
      _masm->entry(_compilation->codeprofile());
      build_frame();
      break;

    case lir_osr_entry:
      Unimplemented();
      //osr_entry();
      break;

    case lir_breakpoint:
      breakpoint();
      break;

    case lir_membar:
      membar();
      break;

    case lir_membar_acquire:
      membar_acquire();
      break;

    case lir_membar_release:
      membar_release();
      break;

    case lir_get_thread:
      get_thread(op->result_opr());
      break;

    default: 
      ShouldNotReachHere();
      break;
  }
}
void LIR_Assembler::add_debug_info_for_branch(CodeEmitInfo* info) {
    int pc_offset = code_offset();
    flush_debug_info(pc_offset);
    info->record_debug_info(compilation()->debug_info_recorder(), pc_offset);
    if (info->exception_handlers() != NULL) {
        compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers());
    }
}
void LIR_Assembler::emit_code(BlockList* hir) {
    if (PrintLIR) {
        print_LIR(hir);
    }

    int n = hir->length();
    for (int i = 0; i < n; i++) {
        emit_block(hir->at(i));
        CHECK_BAILOUT();
    }

    flush_debug_info(code_offset());

    DEBUG_ONLY(check_no_unbound_labels());
}
void LIR_Assembler::emit_op1(LIR_Op1* op) {
    switch (op->code()) {
    case lir_move:
        if (op->move_kind() == lir_move_volatile) {
            assert(op->patch_code() == lir_patch_none, "can't patch volatiles");
            volatile_move_op(op->in_opr(), op->result_opr(), op->type(), op->info());
        } else {
            move_op(op->in_opr(), op->result_opr(), op->type(),
                    op->patch_code(), op->info(), op->pop_fpu_stack(),
                    op->move_kind() == lir_move_unaligned,
                    op->move_kind() == lir_move_wide);
        }
        break;

    case lir_roundfp: {
        LIR_OpRoundFP* round_op = op->as_OpRoundFP();
        roundfp_op(round_op->in_opr(), round_op->tmp(), round_op->result_opr(), round_op->pop_fpu_stack());
        break;
    }

    case lir_return:
        return_op(op->in_opr());
        break;

    case lir_safepoint:
        if (compilation()->debug_info_recorder()->last_pc_offset() == code_offset()) {
            _masm->nop();
        }
        safepoint_poll(op->in_opr(), op->info());
        break;

    case lir_fxch:
        fxch(op->in_opr()->as_jint());
        break;

    case lir_fld:
        fld(op->in_opr()->as_jint());
        break;

    case lir_ffree:
        ffree(op->in_opr()->as_jint());
        break;

    case lir_branch:
        break;

    case lir_push:
        push(op->in_opr());
        break;

    case lir_pop:
        pop(op->in_opr());
        break;

    case lir_neg:
        negate(op->in_opr(), op->result_opr());
        break;

    case lir_leal:
        leal(op->in_opr(), op->result_opr());
        break;

    case lir_null_check:
        if (GenerateCompilerNullChecks) {
            ImplicitNullCheckStub* stub = add_debug_info_for_null_check_here(op->info());

            if (op->in_opr()->is_single_cpu()) {
                _masm->null_check(op->in_opr()->as_register(), stub->entry());
            } else {
                Unimplemented();
            }
        }
        break;

    case lir_monaddr:
        monitor_address(op->in_opr()->as_constant_ptr()->as_jint(), op->result_opr());
        break;

#ifdef SPARC
    case lir_pack64:
        pack64(op->in_opr(), op->result_opr());
        break;

    case lir_unpack64:
        unpack64(op->in_opr(), op->result_opr());
        break;
#endif

    case lir_unwind:
        unwind_op(op->in_opr());
        break;

    default:
        Unimplemented();
        break;
    }
}
void LIR_Assembler::add_debug_info_for_div0_here(CodeEmitInfo* info) {
    add_debug_info_for_div0(code_offset(), info);
}
ImplicitNullCheckStub* LIR_Assembler::add_debug_info_for_null_check_here(CodeEmitInfo* cinfo) {
    return add_debug_info_for_null_check(code_offset(), cinfo);
}
Beispiel #10
0
 void add_call_info_here(CodeEmitInfo* info)                              { add_call_info(code_offset(), info); }
Beispiel #11
0
void LIR_Assembler::emit_op0(LIR_Op0* op) {
  switch (op->code()) {
    case lir_word_align: {
      while (code_offset() % BytesPerWord != 0) {
        _masm->nop();
      }
      break;
    }

    case lir_nop:
      assert(op->info() == NULL, "not supported");
      _masm->nop();
      break;

    case lir_label:
      Unimplemented();
      break;

    case lir_build_frame:
      build_frame();
      break;

    case lir_std_entry:
      // init offsets
      offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
      _masm->align(CodeEntryAlignment);
      if (needs_icache(compilation()->method())) {
        check_icache();
      }
      offsets()->set_value(CodeOffsets::Verified_Entry, _masm->offset());
      _masm->verified_entry();
      build_frame();
      offsets()->set_value(CodeOffsets::Frame_Complete, _masm->offset());
      break;

    case lir_osr_entry:
      offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
      osr_entry();
      break;

    case lir_24bit_FPU:
      set_24bit_FPU();
      break;

    case lir_reset_FPU:
      reset_FPU();
      break;

    case lir_breakpoint:
      breakpoint();
      break;

    case lir_fpop_raw:
      fpop();
      break;

    case lir_membar:
      membar();
      break;

    case lir_membar_acquire:
      membar_acquire();
      break;

    case lir_membar_release:
      membar_release();
      break;

    case lir_membar_loadload:
      membar_loadload();
      break;

    case lir_membar_storestore:
      membar_storestore();
      break;

    case lir_membar_loadstore:
      membar_loadstore();
      break;

    case lir_membar_storeload:
      membar_storeload();
      break;

    case lir_get_thread:
      get_thread(op->result_opr());
      break;

    default:
      ShouldNotReachHere();
      break;
  }
}
Beispiel #12
0
void LIR_Assembler::add_debug_info_for_null_check_here(CodeEmitInfo* cinfo) {
  add_debug_info_for_null_check(code_offset(), cinfo);
}
void LIR_Assembler::add_debug_info_for_branch(CodeEmitInfo* info) {
  masm()->add_dbg( code_offset(), info->debug_scope() );
  if (info->exception_handlers() != NULL) {
compilation()->add_exception_handlers_for_pco(code_offset(),info->exception_handlers());
  }
}