< prev index next >

src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp

Print this page




  49   if (HotSpotObjectConstantImpl::compressed(constant)) {
  50 #ifdef _LP64
  51     int oop_index = _oop_recorder->find_index(value);
  52     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  53     _instructions->relocate(pc, rspec, 1);
  54 #else
  55     fatal("compressed oop on 32bit");
  56 #endif
  57   } else {
  58     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  59     move->set_data((intptr_t) value);
  60 
  61     // We need two relocations:  one on the sethi and one on the add.
  62     int oop_index = _oop_recorder->find_index(value);
  63     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  64     _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec);
  65     _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec);
  66   }
  67 }
  68 



















  69 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
  70   address pc = _instructions->start() + pc_offset;
  71   NativeInstruction* inst = nativeInstruction_at(pc);
  72   NativeInstruction* inst1 = nativeInstruction_at(pc + 4);
  73   if(inst->is_sethi() && inst1->is_nop()) {
  74       address const_start = _constants->start();
  75       address dest = _constants->start() + data_offset;
  76       if(_constants_size > 0) {
  77         _instructions->relocate(pc + NativeMovConstReg::sethi_offset, internal_word_Relocation::spec((address) dest));
  78         _instructions->relocate(pc + NativeMovConstReg::add_offset, internal_word_Relocation::spec((address) dest));
  79       }
  80       TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
  81   }else {
  82     int const_size = align_size_up(_constants->end()-_constants->start(), CodeEntryAlignment);
  83     NativeMovRegMem* load = nativeMovRegMem_at(pc);
  84     // This offset must match with SPARCLoadConstantTableBaseOp.emitCode
  85     load->set_offset(- (const_size - data_offset + Assembler::min_simm13()));
  86     TRACE_jvmci_3("relocating ld at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
  87   }
  88 }
  89 
  90 void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
  91   fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp");
  92 }
  93 
  94 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
  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_sethi()) {
 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 {
 105     fatal(err_msg("unknown call or jump instruction at " PTR_FORMAT, p2i(pc)));
 106   }
 107   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 108 }
 109 
 110 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
 111 #ifdef ASSERT
 112   Method* method = NULL;
 113   // we need to check, this might also be an unresolved method


 151     case POLL_NEAR:
 152       fatal("unimplemented");
 153       break;
 154     case POLL_FAR:
 155       _instructions->relocate(pc, relocInfo::poll_type);
 156       break;
 157     case POLL_RETURN_NEAR:
 158       fatal("unimplemented");
 159       break;
 160     case POLL_RETURN_FAR:
 161       _instructions->relocate(pc, relocInfo::poll_return_type);
 162       break;
 163     default:
 164       fatal("invalid mark value");
 165       break;
 166   }
 167 }
 168 
 169 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
 170 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) {
 171   if (jvmci_reg < RegisterImpl::number_of_registers) {





 172     return as_Register(jvmci_reg)->as_VMReg();
 173   } else {
 174     jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers;
 175     floatRegisterNumber += MAX2(0, floatRegisterNumber-32); // Beginning with f32, only every second register is going to be addressed
 176     if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) {
 177       return as_FloatRegister(floatRegisterNumber)->as_VMReg();





 178     }
 179     ShouldNotReachHere();
 180     return NULL;
 181   }
 182 }
 183 
 184 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
 185   return !hotspotRegister->is_FloatRegister();
 186 }


  49   if (HotSpotObjectConstantImpl::compressed(constant)) {
  50 #ifdef _LP64
  51     int oop_index = _oop_recorder->find_index(value);
  52     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  53     _instructions->relocate(pc, rspec, 1);
  54 #else
  55     fatal("compressed oop on 32bit");
  56 #endif
  57   } else {
  58     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  59     move->set_data((intptr_t) value);
  60 
  61     // We need two relocations:  one on the sethi and one on the add.
  62     int oop_index = _oop_recorder->find_index(value);
  63     RelocationHolder rspec = oop_Relocation::spec(oop_index);
  64     _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec);
  65     _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec);
  66   }
  67 }
  68 
  69 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle& constant) {
  70   address pc = _instructions->start() + pc_offset;
  71   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
  72 #ifdef _LP64
  73     NativeMovConstReg32* move = nativeMovConstReg32_at(pc);
  74     narrowKlass narrowOop = record_narrow_metadata_reference(constant);
  75     move->set_data((intptr_t)narrowOop);
  76     TRACE_jvmci_3("relocating (narrow metaspace constant) at %p/%p", pc, narrowOop);
  77 #else
  78     fatal("compressed Klass* on 32bit");
  79 #endif
  80   } else {
  81     NativeMovConstReg* move = nativeMovConstReg_at(pc);
  82     Metadata* reference = record_metadata_reference(constant);
  83     move->set_data((intptr_t)reference);
  84     TRACE_jvmci_3("relocating (metaspace constant) at %p/%p", pc, reference);
  85   }
  86 }
  87 
  88 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
  89   address pc = _instructions->start() + pc_offset;
  90   NativeInstruction* inst = nativeInstruction_at(pc);
  91   NativeInstruction* inst1 = nativeInstruction_at(pc + 4);
  92   if(inst->is_sethi() && inst1->is_nop()) {
  93       address const_start = _constants->start();
  94       address dest = _constants->start() + data_offset;
  95       if(_constants_size > 0) {
  96         _instructions->relocate(pc + NativeMovConstReg::sethi_offset, internal_word_Relocation::spec((address) dest));
  97         _instructions->relocate(pc + NativeMovConstReg::add_offset, internal_word_Relocation::spec((address) dest));
  98       }
  99       TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
 100   }else {
 101     int const_size = align_size_up(_constants->end()-_constants->start(), CodeEntryAlignment);
 102     NativeMovRegMem* load = nativeMovRegMem_at(pc);
 103     // This offset must match with SPARCLoadConstantTableBaseOp.emitCode
 104     load->set_offset(- (const_size - data_offset + Assembler::min_simm13()));
 105     TRACE_jvmci_3("relocating ld at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
 106   }
 107 }
 108 




 109 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
 110   address pc = (address) inst;
 111   if (inst->is_call()) {
 112     NativeCall* call = nativeCall_at(pc);
 113     call->set_destination((address) foreign_call_destination);
 114     _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
 115   } else if (inst->is_sethi()) {
 116     NativeJump* jump = nativeJump_at(pc);
 117     jump->set_jump_destination((address) foreign_call_destination);
 118     _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
 119   } else {
 120     fatal(err_msg("unknown call or jump instruction at " PTR_FORMAT, p2i(pc)));
 121   }
 122   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 123 }
 124 
 125 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
 126 #ifdef ASSERT
 127   Method* method = NULL;
 128   // we need to check, this might also be an unresolved method


 166     case POLL_NEAR:
 167       fatal("unimplemented");
 168       break;
 169     case POLL_FAR:
 170       _instructions->relocate(pc, relocInfo::poll_type);
 171       break;
 172     case POLL_RETURN_NEAR:
 173       fatal("unimplemented");
 174       break;
 175     case POLL_RETURN_FAR:
 176       _instructions->relocate(pc, relocInfo::poll_return_type);
 177       break;
 178     default:
 179       fatal("invalid mark value");
 180       break;
 181   }
 182 }
 183 
 184 // convert JVMCI register indices (as used in oop maps) to HotSpot registers
 185 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) {
 186   // JVMCI Registers are numbered as follows:
 187   //   0..31: Thirty-two General Purpose registers (CPU Registers)
 188   //   32..63: Thirty-two single precision float registers
 189   //   64..95: Thirty-two double precision float registers
 190   //   96..111: Sixteen quad precision float registers
 191   if (jvmci_reg < 32) {
 192     return as_Register(jvmci_reg)->as_VMReg();
 193   } else {
 194     jint floatRegisterNumber;
 195     if(jvmci_reg < 64) { // Single precision
 196       floatRegisterNumber = jvmci_reg - 32;
 197     } else if(jvmci_reg < 96) {
 198       floatRegisterNumber = 2 * (jvmci_reg - 64);
 199     } else if(jvmci_reg < 112) {
 200       floatRegisterNumber = 4 * (jvmci_reg - 96);
 201     } else {
 202       fatal("Unknown jvmci register");
 203     }
 204     return as_FloatRegister(floatRegisterNumber)->as_VMReg();

 205   }
 206 }
 207 
 208 bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) {
 209   return !hotspotRegister->is_FloatRegister();
 210 }
< prev index next >