< prev index next >

src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp

Print this page
rev 12320 : 8170106: AArch64: Multiple JVMCI issues
Reviewed-by: rschatz


  24 #include "jvmci/jvmciCodeInstaller.hpp"
  25 #include "jvmci/jvmciRuntime.hpp"
  26 #include "jvmci/jvmciCompilerToVM.hpp"
  27 #include "jvmci/jvmciJavaClasses.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/sharedRuntime.hpp"
  30 #include "vmreg_aarch64.inline.hpp"
  31 
  32 jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS) {
  33   if (inst->is_call() || inst->is_jump() || inst->is_blr()) {
  34     return pc_offset + NativeCall::instruction_size;
  35   } else if (inst->is_general_jump()) {
  36     return pc_offset + NativeGeneralJump::instruction_size;
  37   } else {
  38     JVMCI_ERROR_0("unsupported type of instruction for call site");
  39   }
  40 }
  41 
  42 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) {
  43   address pc = _instructions->start() + pc_offset;
  44   Handle obj = HotSpotObjectConstantImpl::object(constant);
  45   jobject value = JNIHandles::make_local(obj());

  46   if (HotSpotObjectConstantImpl::compressed(constant)) {
  47     int oop_index = _oop_recorder->find_index(value);
  48     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  49     _instructions->relocate(pc, rspec, 1);
  50     Unimplemented();
  51   } else {
  52     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  53     move->set_data((intptr_t) value);







  54     int oop_index = _oop_recorder->find_index(value);
  55     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  56     _instructions->relocate(pc, rspec);
  57   }
  58 }
  59 
  60 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
  61   address pc = _instructions->start() + pc_offset;
  62   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
  63     narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);

  64     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
  65     Unimplemented();
  66   } else {
  67     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  68     void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);
  69     move->set_data((intptr_t) reference);
  70     TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
  71   }
  72 }
  73 
  74 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) {
  75   address pc = _instructions->start() + pc_offset;
  76   NativeInstruction* inst = nativeInstruction_at(pc);
  77   if (inst->is_adr_aligned() || inst->is_ldr_literal()) {
  78     address dest = _constants->start() + data_offset;
  79     _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
  80     TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
  81   } else {
  82     JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
  83   }
  84 }
  85 


 150     case POLL_FAR:
 151       _instructions->relocate(pc, relocInfo::poll_type);
 152       break;
 153     case POLL_RETURN_NEAR:
 154       JVMCI_ERROR("unimplemented");
 155       break;
 156     case POLL_RETURN_FAR:
 157       _instructions->relocate(pc, relocInfo::poll_return_type);
 158       break;
 159     default:
 160       JVMCI_ERROR("invalid mark value");
 161       break;
 162   }
 163 }
 164 
 165 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
 166 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) {
 167   if (jvmci_reg < RegisterImpl::number_of_registers) {
 168     return as_Register(jvmci_reg)->as_VMReg();
 169   } else {
 170     jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers;
 171     if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) {
 172       return as_FloatRegister(floatRegisterNumber)->as_VMReg();
 173     }
 174     JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg);
 175   }
 176 }
 177 
 178 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
 179   return !hotspotRegister->is_FloatRegister();
 180 }


  24 #include "jvmci/jvmciCodeInstaller.hpp"
  25 #include "jvmci/jvmciRuntime.hpp"
  26 #include "jvmci/jvmciCompilerToVM.hpp"
  27 #include "jvmci/jvmciJavaClasses.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/sharedRuntime.hpp"
  30 #include "vmreg_aarch64.inline.hpp"
  31 
  32 jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS) {
  33   if (inst->is_call() || inst->is_jump() || inst->is_blr()) {
  34     return pc_offset + NativeCall::instruction_size;
  35   } else if (inst->is_general_jump()) {
  36     return pc_offset + NativeGeneralJump::instruction_size;
  37   } else {
  38     JVMCI_ERROR_0("unsupported type of instruction for call site");
  39   }
  40 }
  41 
  42 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) {
  43   address pc = _instructions->start() + pc_offset;
  44 #ifdef ASSERT
  45   {
  46     NativeInstruction *insn = nativeInstruction_at(pc);
  47     if (HotSpotObjectConstantImpl::compressed(constant)) {
  48       // Mov narrow constant: movz n << 16, movk
  49       assert(Instruction_aarch64::extract(insn->encoding(), 31, 21) == 0b11010010101 &&
  50              nativeInstruction_at(pc+4)->is_movk(), "wrong insn in patch");

  51     } else {
  52       // Move wide constant: movz n, movk, movk.
  53       assert(nativeInstruction_at(pc+4)->is_movk()
  54              && nativeInstruction_at(pc+8)->is_movk(), "wrong insn in patch");
  55     }
  56   }
  57 #endif // ASSERT
  58   Handle obj = HotSpotObjectConstantImpl::object(constant);
  59   jobject value = JNIHandles::make_local(obj());
  60   MacroAssembler::patch_oop(pc, (address)obj());
  61   int oop_index = _oop_recorder->find_index(value);
  62   RelocationHolder rspec = oop_Relocation::spec(oop_index);
  63   _instructions->relocate(pc, rspec);

  64 }
  65 
  66 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
  67   address pc = _instructions->start() + pc_offset;
  68   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
  69     narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
  70     MacroAssembler::patch_narrow_klass(pc, narrowOop);
  71     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);

  72   } else {
  73     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  74     void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);
  75     move->set_data((intptr_t) reference);
  76     TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
  77   }
  78 }
  79 
  80 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) {
  81   address pc = _instructions->start() + pc_offset;
  82   NativeInstruction* inst = nativeInstruction_at(pc);
  83   if (inst->is_adr_aligned() || inst->is_ldr_literal()) {
  84     address dest = _constants->start() + data_offset;
  85     _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
  86     TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
  87   } else {
  88     JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
  89   }
  90 }
  91 


 156     case POLL_FAR:
 157       _instructions->relocate(pc, relocInfo::poll_type);
 158       break;
 159     case POLL_RETURN_NEAR:
 160       JVMCI_ERROR("unimplemented");
 161       break;
 162     case POLL_RETURN_FAR:
 163       _instructions->relocate(pc, relocInfo::poll_return_type);
 164       break;
 165     default:
 166       JVMCI_ERROR("invalid mark value");
 167       break;
 168   }
 169 }
 170 
 171 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
 172 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) {
 173   if (jvmci_reg < RegisterImpl::number_of_registers) {
 174     return as_Register(jvmci_reg)->as_VMReg();
 175   } else {
 176     jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers_for_jvmci;
 177     if (floatRegisterNumber >= 0 && floatRegisterNumber < FloatRegisterImpl::number_of_registers) {
 178       return as_FloatRegister(floatRegisterNumber)->as_VMReg();
 179     }
 180     JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg);
 181   }
 182 }
 183 
 184 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
 185   return !hotspotRegister->is_FloatRegister();
 186 }
< prev index next >