< prev index next >

src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp

Print this page
rev 54117 : AArch64: 64-bit Literal Oops


  36   } else if (inst->is_general_jump()) {
  37     return pc_offset + NativeGeneralJump::instruction_size;
  38   } else if (NativeInstruction::is_adrp_at((address)inst)) {
  39     // adrp; add; blr
  40     return pc_offset + 3 * NativeInstruction::instruction_size;
  41   } else {
  42     JVMCI_ERROR_0("unsupported type of instruction for call site");
  43   }
  44 }
  45 
  46 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) {
  47   address pc = _instructions->start() + pc_offset;
  48 #ifdef ASSERT
  49   {
  50     NativeInstruction *insn = nativeInstruction_at(pc);
  51     if (HotSpotObjectConstantImpl::compressed(constant)) {
  52       // Mov narrow constant: movz n << 16, movk
  53       assert(Instruction_aarch64::extract(insn->encoding(), 31, 21) == 0b11010010101 &&
  54              nativeInstruction_at(pc+4)->is_movk(), "wrong insn in patch");
  55     } else {

  56       // Move wide constant: movz n, movk, movk.
  57       assert(nativeInstruction_at(pc+4)->is_movk()
  58              && nativeInstruction_at(pc+8)->is_movk(), "wrong insn in patch");








  59     }
  60   }
  61 #endif // ASSERT
  62   Handle obj(THREAD, HotSpotObjectConstantImpl::object(constant));
  63   jobject value = JNIHandles::make_local(obj());
  64   MacroAssembler::patch_oop(pc, (address)obj());
  65   int oop_index = _oop_recorder->find_index(value);
  66   RelocationHolder rspec = oop_Relocation::spec(oop_index);
  67   _instructions->relocate(pc, rspec);
  68 }
  69 
  70 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
  71   address pc = _instructions->start() + pc_offset;
  72   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
  73     narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
  74     MacroAssembler::patch_narrow_klass(pc, narrowOop);
  75     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
  76   } else {
  77     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  78     void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);


  88       || (NativeInstruction::maybe_cpool_ref(pc))) {
  89     address dest = _constants->start() + data_offset;
  90     _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
  91     TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
  92   } else {
  93     JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
  94   }
  95 }
  96 
  97 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) {
  98   address pc = (address) inst;
  99   if (inst->is_call()) {
 100     NativeCall* call = nativeCall_at(pc);
 101     call->set_destination((address) foreign_call_destination);
 102     _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
 103   } else if (inst->is_jump()) {
 104     NativeJump* jump = nativeJump_at(pc);
 105     jump->set_jump_destination((address) foreign_call_destination);
 106     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 107   } else if (inst->is_general_jump()) {


 108     NativeGeneralJump* jump = nativeGeneralJump_at(pc);
 109     jump->set_jump_destination((address) foreign_call_destination);
 110     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 111   } else if (NativeInstruction::is_adrp_at((address)inst)) {
 112     // adrp; add; blr
 113     MacroAssembler::pd_patch_instruction_size((address)inst,
 114                                               (address)foreign_call_destination);
 115   } else {
 116     JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc));
 117   }
 118   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 119 }
 120 
 121 void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle hotspot_method, jint pc_offset, TRAPS) {
 122 #ifdef ASSERT
 123   Method* method = NULL;
 124   // we need to check, this might also be an unresolved method
 125   if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) {
 126     method = getMethodFromHotSpotMethod(hotspot_method());
 127   }




  36   } else if (inst->is_general_jump()) {
  37     return pc_offset + NativeGeneralJump::instruction_size;
  38   } else if (NativeInstruction::is_adrp_at((address)inst)) {
  39     // adrp; add; blr
  40     return pc_offset + 3 * NativeInstruction::instruction_size;
  41   } else {
  42     JVMCI_ERROR_0("unsupported type of instruction for call site");
  43   }
  44 }
  45 
  46 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) {
  47   address pc = _instructions->start() + pc_offset;
  48 #ifdef ASSERT
  49   {
  50     NativeInstruction *insn = nativeInstruction_at(pc);
  51     if (HotSpotObjectConstantImpl::compressed(constant)) {
  52       // Mov narrow constant: movz n << 16, movk
  53       assert(Instruction_aarch64::extract(insn->encoding(), 31, 21) == 0b11010010101 &&
  54              nativeInstruction_at(pc+4)->is_movk(), "wrong insn in patch");
  55     } else {
  56       if (!Use64BitLiteralAddresses) {
  57         // Move wide constant: movz n, movk, movk.
  58         assert(nativeInstruction_at(pc+4)->is_movk()
  59                && nativeInstruction_at(pc+8)->is_movk(), "wrong insn in patch");
  60       } else {
  61         // Move wide constant: movz n, movk, movk, movk
  62         // JVMCI Would require code generated for it to use 64 bit literals and
  63         // it therefore disables Use64BitLiteralAddresses until support is enabled.
  64         assert(nativeInstruction_at(pc+4)->is_movk()
  65                && nativeInstruction_at(pc+8)->is_movk()
  66                && nativeInstruction_at(pc+12)->is_movk(), "wrong insn in patch");
  67       }
  68     }
  69   }
  70 #endif // ASSERT
  71   Handle obj(THREAD, HotSpotObjectConstantImpl::object(constant));
  72   jobject value = JNIHandles::make_local(obj());
  73   MacroAssembler::patch_oop(pc, (address)obj());
  74   int oop_index = _oop_recorder->find_index(value);
  75   RelocationHolder rspec = oop_Relocation::spec(oop_index);
  76   _instructions->relocate(pc, rspec);
  77 }
  78 
  79 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
  80   address pc = _instructions->start() + pc_offset;
  81   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
  82     narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
  83     MacroAssembler::patch_narrow_klass(pc, narrowOop);
  84     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
  85   } else {
  86     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  87     void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);


  97       || (NativeInstruction::maybe_cpool_ref(pc))) {
  98     address dest = _constants->start() + data_offset;
  99     _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
 100     TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
 101   } else {
 102     JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
 103   }
 104 }
 105 
 106 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) {
 107   address pc = (address) inst;
 108   if (inst->is_call()) {
 109     NativeCall* call = nativeCall_at(pc);
 110     call->set_destination((address) foreign_call_destination);
 111     _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
 112   } else if (inst->is_jump()) {
 113     NativeJump* jump = nativeJump_at(pc);
 114     jump->set_jump_destination((address) foreign_call_destination);
 115     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 116   } else if (inst->is_general_jump()) {
 117     // mov, movk, movk
 118     assert(!Use64BitLiteralAddresses, "64 bit literals not supported.");
 119     NativeGeneralJump* jump = nativeGeneralJump_at(pc);
 120     jump->set_jump_destination((address) foreign_call_destination);
 121     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 122   } else if (NativeInstruction::is_adrp_at((address)inst)) {
 123     // adrp; add; blr
 124     MacroAssembler::pd_patch_instruction_size((address)inst,
 125                                               (address)foreign_call_destination);
 126   } else {
 127     JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc));
 128   }
 129   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 130 }
 131 
 132 void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle hotspot_method, jint pc_offset, TRAPS) {
 133 #ifdef ASSERT
 134   Method* method = NULL;
 135   // we need to check, this might also be an unresolved method
 136   if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) {
 137     method = getMethodFromHotSpotMethod(hotspot_method());
 138   }


< prev index next >