30 #include "vmreg_sparc.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()) { 34 return pc_offset + NativeCall::instruction_size; 35 } else if (inst->is_call_reg()) { 36 return pc_offset + NativeCallReg::instruction_size; 37 } else if (inst->is_sethi()) { 38 return pc_offset + NativeFarCall::instruction_size; 39 } else { 40 JVMCI_ERROR_0("unsupported type of instruction for call site"); 41 return 0; 42 } 43 } 44 45 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) { 46 address pc = _instructions->start() + pc_offset; 47 Handle obj(THREAD, HotSpotObjectConstantImpl::object(constant)); 48 jobject value = JNIHandles::make_local(obj()); 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 JVMCI_ERROR("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, TRAPS) { 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(_instructions, pc, constant, CHECK); 75 move->set_data((intptr_t)narrowOop); 76 TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); 77 #else 78 JVMCI_ERROR("compressed Klass* on 32bit"); 79 #endif 80 } else { 81 NativeMovConstReg* move = nativeMovConstReg_at(pc); 82 void* reference = record_metadata_reference(_instructions, pc, constant, CHECK); 83 move->set_data((intptr_t)reference); 84 TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); 85 } 86 } 87 88 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) { 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); | 30 #include "vmreg_sparc.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()) { 34 return pc_offset + NativeCall::instruction_size; 35 } else if (inst->is_call_reg()) { 36 return pc_offset + NativeCallReg::instruction_size; 37 } else if (inst->is_sethi()) { 38 return pc_offset + NativeFarCall::instruction_size; 39 } else { 40 JVMCI_ERROR_0("unsupported type of instruction for call site"); 41 return 0; 42 } 43 } 44 45 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) { 46 address pc = _instructions->start() + pc_offset; 47 Handle obj(THREAD, HotSpotObjectConstantImpl::object(constant)); 48 jobject value = JNIHandles::make_local(obj()); 49 if (HotSpotObjectConstantImpl::compressed(constant)) { 50 int oop_index = _oop_recorder->find_index(value); 51 RelocationHolder rspec = oop_Relocation::spec(oop_index); 52 _instructions->relocate(pc, rspec, 1); 53 } else { 54 NativeMovConstReg* move = nativeMovConstReg_at(pc); 55 move->set_data((intptr_t) value); 56 57 // We need two relocations: one on the sethi and one on the add. 58 int oop_index = _oop_recorder->find_index(value); 59 RelocationHolder rspec = oop_Relocation::spec(oop_index); 60 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); 61 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); 62 } 63 } 64 65 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) { 66 address pc = _instructions->start() + pc_offset; 67 if (HotSpotMetaspaceConstantImpl::compressed(constant)) { 68 NativeMovConstReg32* move = nativeMovConstReg32_at(pc); 69 narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK); 70 move->set_data((intptr_t)narrowOop); 71 TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); 72 } else { 73 NativeMovConstReg* move = nativeMovConstReg_at(pc); 74 void* reference = record_metadata_reference(_instructions, pc, constant, CHECK); 75 move->set_data((intptr_t)reference); 76 TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); 77 } 78 } 79 80 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) { 81 address pc = _instructions->start() + pc_offset; 82 NativeInstruction* inst = nativeInstruction_at(pc); 83 NativeInstruction* inst1 = nativeInstruction_at(pc + 4); 84 if(inst->is_sethi() && inst1->is_nop()) { 85 address const_start = _constants->start(); 86 address dest = _constants->start() + data_offset; 87 if(_constants_size > 0) { 88 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, internal_word_Relocation::spec((address) dest)); 89 _instructions->relocate(pc + NativeMovConstReg::add_offset, internal_word_Relocation::spec((address) dest)); 90 } 91 TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset); |