--- old/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp 2018-03-23 16:35:47.483805061 +0000 +++ new/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp 2018-03-23 16:35:46.883864381 +0000 @@ -34,6 +34,9 @@ return pc_offset + NativeCall::instruction_size; } else if (inst->is_general_jump()) { return pc_offset + NativeGeneralJump::instruction_size; + } else if (NativeInstruction::is_adrp_at((address)inst)) { + // adrp; add; blr + return pc_offset + 3 * NativeInstruction::instruction_size; } else { JVMCI_ERROR_0("unsupported type of instruction for call site"); } @@ -80,7 +83,8 @@ void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) { address pc = _instructions->start() + pc_offset; NativeInstruction* inst = nativeInstruction_at(pc); - if (inst->is_adr_aligned() || inst->is_ldr_literal()) { + if (inst->is_adr_aligned() || inst->is_ldr_literal() + || (NativeInstruction::maybe_cpool_ref(pc))) { address dest = _constants->start() + data_offset; _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS)); TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset); @@ -103,6 +107,10 @@ NativeGeneralJump* jump = nativeGeneralJump_at(pc); jump->set_jump_destination((address) foreign_call_destination); _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); + } else if (NativeInstruction::is_adrp_at((address)inst)) { + // adrp; add; blr + MacroAssembler::pd_patch_instruction_size((address)inst, + (address)foreign_call_destination); } else { JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc)); } @@ -125,21 +133,30 @@ assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); - call->trampoline_jump(cbuf, SharedRuntime::get_resolve_virtual_call_stub()); + // Don't create trampolines for immutable PIC. + if (!_immutable_pic_compilation) { + call->trampoline_jump(cbuf, SharedRuntime::get_resolve_virtual_call_stub()); + } break; } case INVOKESTATIC: { assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); - call->trampoline_jump(cbuf, SharedRuntime::get_resolve_static_call_stub()); + // Don't create trampolines for immutable PIC. + if (!_immutable_pic_compilation) { + call->trampoline_jump(cbuf, SharedRuntime::get_resolve_static_call_stub()); + } break; } case INVOKESPECIAL: { assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); - call->trampoline_jump(cbuf, SharedRuntime::get_resolve_opt_virtual_call_stub()); + // Don't create trampolines for immutable PIC. + if (!_immutable_pic_compilation) { + call->trampoline_jump(cbuf, SharedRuntime::get_resolve_opt_virtual_call_stub()); + } break; } default: