< prev index next >

src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp

Print this page
rev 9228 : 8143072: Port JVMCI to AArch64
Summary: AArch64-specific code for JVMCI
Reviewed-by: duke


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  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, oop method) {
  33   Unimplemented();
  34   return 0;






  35 }
  36 
  37 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) {
  38   Unimplemented();








  39 }
  40 
  41 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
  42   Unimplemented();
  43 }
  44 
  45 void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
  46   Unimplemented();






  47 }
  48 
  49 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
  50   Unimplemented();













  51 }
  52 
  53 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
  54   Unimplemented();







































  55 }
  56 
  57 void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
  58   Unimplemented();
  59 }
  60 
  61 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
  62 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) {








  63   return NULL;

  64 }
  65 
  66 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
  67   return false;
  68 }


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  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, oop method) {
  33   address pc = _instructions->start() + pc_offset;
  34   if (inst->is_call() || inst->is_jump()) {
  35     assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size");
  36     return pc_offset + NativeCall::instruction_size;
  37   } else {
  38     // mov+call instruction pair
  39     return nativeMovConstReg_at(pc)->next_instruction_address() - pc;
  40   }
  41 }
  42 
  43 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) {
  44   address pc = _instructions->start() + pc_offset;
  45   Handle obj = HotSpotObjectConstantImpl::object(constant);
  46   jobject value = JNIHandles::make_local(obj());
  47 
  48   MacroAssembler::patch_oop(pc, (address)value);
  49   int oop_index = _oop_recorder->find_index(value);
  50   _instructions->relocate(pc, oop_Relocation::spec(oop_index));
  51 
  52   TRACE_jvmci_3("relocating (oop constant) at " PTR_FORMAT, p2i(pc));
  53 }
  54 
  55 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
  56   Unimplemented();
  57 }
  58 
  59 void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
  60   if (cb->is_nmethod()) {
  61     nmethod* nm = (nmethod*) cb;
  62     nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point());
  63   } else {
  64     nativeJump_at((address)inst)->set_jump_destination(cb->code_begin());
  65   }
  66   _instructions->relocate((address)inst, runtime_call_Relocation::spec());
  67 }
  68 
  69 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
  70   address pc = (address) inst;
  71   address dest = (address) foreign_call_destination;
  72   assert(inst->is_call(), "should be a call here");
  73   if (inst->is_call()) {
  74     address trampoline = nativeCall_at(pc)->get_trampoline();
  75     if (trampoline) {
  76       nativeCall_at(pc)->set_destination_mt_safe(dest, /* assert_lock */false);
  77       TRACE_jvmci_3("relocating trampoline (foreign call)  at " PTR_FORMAT, p2i(inst));
  78       return;
  79     }
  80   }
  81   assert(pc != (address) foreign_call_destination, "call instruction in an infinite loop");
  82   MacroAssembler::pd_patch_instruction(pc, dest);
  83   TRACE_jvmci_3("relocating (foreign call)  at " PTR_FORMAT, p2i(inst));
  84 }
  85 
  86 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
  87 #ifdef ASSERT
  88   Method* method = NULL;
  89   // we need to check, this might also be an unresolved method
  90   if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) {
  91     method = getMethodFromHotSpotMethod(hotspot_method);
  92   }
  93 #endif
  94   switch (_next_call_type) {
  95     case INLINE_INVOKE:
  96       break;
  97     case INVOKEVIRTUAL:
  98     case INVOKEINTERFACE: {
  99       assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
 100 
 101       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
 102       call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
 103       _instructions->relocate(call->instruction_address(),
 104                                              virtual_call_Relocation::spec(_invoke_mark_pc));
 105       break;
 106     }
 107     case INVOKESTATIC: {
 108       assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
 109 
 110       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
 111       call->set_destination(SharedRuntime::get_resolve_static_call_stub());
 112       _instructions->relocate(call->instruction_address(),
 113                                              relocInfo::static_call_type);
 114       break;
 115     }
 116     case INVOKESPECIAL: {
 117       assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
 118       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
 119       call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
 120       _instructions->relocate(call->instruction_address(),
 121                               relocInfo::opt_virtual_call_type);
 122       break;
 123     }
 124     default:
 125       break;
 126   }
 127 }
 128 
 129 void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
 130   MacroAssembler::pd_patch_instruction_size(pc, os::get_polling_page());
 131 }
 132 
 133 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
 134 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) {
 135   if (jvmci_reg < RegisterImpl::number_of_registers) {
 136     return as_Register(jvmci_reg)->as_VMReg();
 137   } else {
 138     jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers;
 139     if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) {
 140       return as_FloatRegister(floatRegisterNumber)->as_VMReg();
 141     }
 142     ShouldNotReachHere();
 143     return NULL;
 144   }
 145 }
 146 
 147 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
 148   return !(hotspotRegister->is_FloatRegister() || hotspotRegister->is_FloatRegister());
 149 }
< prev index next >