< prev index next >

src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp

Print this page




  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, Handle method, TRAPS) {
  33   Unimplemented();
  34   return 0;





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


















  39 }
  40 
  41 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
  42   Unimplemented();














  43 }
  44 
  45 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
  46   Unimplemented();








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
















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



































  55 }
  56 
  57 void CodeInstaller::pd_relocate_poll(address pc, jint mark, TRAPS) {
  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, TRAPS) {
  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, 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 #ifdef _LP64
  48     int oop_index = _oop_recorder->find_index(value);
  49     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  50     _instructions->relocate(pc, rspec, 1);
  51     Unimplemented();
  52 #else
  53     JVMCI_ERROR("compressed oop on 32bit");
  54 #endif
  55   } else {
  56     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  57     move->set_data((intptr_t) value);
  58     int oop_index = _oop_recorder->find_index(value);
  59     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  60     _instructions->relocate(pc, rspec);
  61   }
  62 }
  63 
  64 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
  65   address pc = _instructions->start() + pc_offset;
  66   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
  67 #ifdef _LP64
  68     narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
  69     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
  70     Unimplemented();
  71 #else
  72     JVMCI_ERROR("compressed Klass* on 32bit");
  73 #endif
  74   } else {
  75     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  76     Metadata* reference = record_metadata_reference(constant, CHECK);
  77     move->set_data((intptr_t) reference);
  78     TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
  79   }
  80 }
  81 
  82 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
  83   address pc = _instructions->start() + pc_offset;
  84   NativeInstruction* inst = nativeInstruction_at(pc);
  85   if (inst->is_adr_aligned()) {
  86     address dest = _constants->start() + data_offset;
  87     _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
  88     TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
  89   } else {
  90     fatal("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
  91   }
  92 }
  93 
  94 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) {
  95   address pc = (address) inst;
  96   if (inst->is_call()) {
  97     NativeCall* call = nativeCall_at(pc);
  98     call->set_destination((address) foreign_call_destination);
  99     _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
 100   } else if (inst->is_jump()) {
 101     NativeJump* jump = nativeJump_at(pc);
 102     jump->set_jump_destination((address) foreign_call_destination);
 103     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 104   } else if (inst->is_general_jump()) {
 105     NativeGeneralJump* jump = nativeGeneralJump_at(pc);
 106     jump->set_jump_destination((address) foreign_call_destination);
 107     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 108   } else {
 109     JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc));
 110   }
 111   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 112 }
 113 
 114 void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) {
 115 #ifdef ASSERT
 116   Method* method = NULL;
 117   // we need to check, this might also be an unresolved method
 118   if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) {
 119     method = getMethodFromHotSpotMethod(hotspot_method());
 120   }
 121 #endif
 122   switch (_next_call_type) {
 123     case INLINE_INVOKE:
 124       break;
 125     case INVOKEVIRTUAL:
 126     case INVOKEINTERFACE: {
 127       assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
 128       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
 129       call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
 130       _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
 131       break;
 132     }
 133     case INVOKESTATIC: {
 134       assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
 135       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
 136       call->set_destination(SharedRuntime::get_resolve_static_call_stub());
 137       _instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
 138       break;
 139     }
 140     case INVOKESPECIAL: {
 141       assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
 142       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
 143       call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
 144       _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type);
 145       break;
 146     }
 147     default:
 148       JVMCI_ERROR("invalid _next_call_type value");
 149       break;
 150   }
 151 }
 152 
 153 void CodeInstaller::pd_relocate_poll(address pc, jint mark, TRAPS) {
 154   switch (mark) {
 155     case POLL_NEAR:
 156       JVMCI_ERROR("unimplemented");
 157       break;
 158     case POLL_FAR:
 159       _instructions->relocate(pc, relocInfo::poll_type);
 160       break;
 161     case POLL_RETURN_NEAR:
 162       JVMCI_ERROR("unimplemented");
 163       break;
 164     case POLL_RETURN_FAR:
 165       _instructions->relocate(pc, relocInfo::poll_return_type);
 166       break;
 167     default:
 168       JVMCI_ERROR("invalid mark value");
 169       break;
 170   }
 171 }
 172 
 173 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
 174 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) {
 175   if (jvmci_reg < RegisterImpl::number_of_registers) {
 176     return as_Register(jvmci_reg)->as_VMReg();
 177   } else {
 178     jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers;
 179     if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) {
 180       return as_FloatRegister(floatRegisterNumber)->as_VMReg();
 181     }
 182     JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg);
 183   }
 184 }
 185 
 186 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
 187   return !hotspotRegister->is_FloatRegister();
 188 }
< prev index next >