Mercurial > hg > graal-jvmci-8
comparison src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp @ 22711:316e768645c0
8139589: [JVMCI] throw exceptions in faulty code installation operations
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 29 Oct 2015 15:21:55 +0100 |
parents | 37505a836aaf |
children | 510846133438 |
comparison
equal
deleted
inserted
replaced
22710:7e7573382a23 | 22711:316e768645c0 |
---|---|
25 #include "jvmci/jvmciRuntime.hpp" | 25 #include "jvmci/jvmciRuntime.hpp" |
26 #include "jvmci/jvmciCompilerToVM.hpp" | 26 #include "jvmci/jvmciCompilerToVM.hpp" |
27 #include "jvmci/jvmciJavaClasses.hpp" | 27 #include "jvmci/jvmciJavaClasses.hpp" |
28 #include "vmreg_sparc.inline.hpp" | 28 #include "vmreg_sparc.inline.hpp" |
29 | 29 |
30 jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { | 30 jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS) { |
31 if (inst->is_call() || inst->is_jump()) { | 31 if (inst->is_call() || inst->is_jump()) { |
32 return pc_offset + NativeCall::instruction_size; | 32 return pc_offset + NativeCall::instruction_size; |
33 } else if (inst->is_call_reg()) { | 33 } else if (inst->is_call_reg()) { |
34 return pc_offset + NativeCallReg::instruction_size; | 34 return pc_offset + NativeCallReg::instruction_size; |
35 } else if (inst->is_sethi()) { | 35 } else if (inst->is_sethi()) { |
36 return pc_offset + NativeFarCall::instruction_size; | 36 return pc_offset + NativeFarCall::instruction_size; |
37 } else { | 37 } else { |
38 fatal("unsupported type of instruction for call site"); | 38 JVMCI_ERROR_0("unsupported type of instruction for call site"); |
39 return 0; | 39 return 0; |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) { | 43 void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) { |
44 address pc = _instructions->start() + pc_offset; | 44 address pc = _instructions->start() + pc_offset; |
45 Handle obj = HotSpotObjectConstantImpl::object(constant); | 45 Handle obj = HotSpotObjectConstantImpl::object(constant); |
46 jobject value = JNIHandles::make_local(obj()); | 46 jobject value = JNIHandles::make_local(obj()); |
47 if (HotSpotObjectConstantImpl::compressed(constant)) { | 47 if (HotSpotObjectConstantImpl::compressed(constant)) { |
48 #ifdef _LP64 | 48 #ifdef _LP64 |
49 int oop_index = _oop_recorder->find_index(value); | 49 int oop_index = _oop_recorder->find_index(value); |
50 RelocationHolder rspec = oop_Relocation::spec(oop_index); | 50 RelocationHolder rspec = oop_Relocation::spec(oop_index); |
51 _instructions->relocate(pc, rspec, 1); | 51 _instructions->relocate(pc, rspec, 1); |
52 #else | 52 #else |
53 fatal("compressed oop on 32bit"); | 53 JVMCI_ERROR("compressed oop on 32bit"); |
54 #endif | 54 #endif |
55 } else { | 55 } else { |
56 NativeMovConstReg* move = nativeMovConstReg_at(pc); | 56 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
57 move->set_data((intptr_t) value); | 57 move->set_data((intptr_t) value); |
58 | 58 |
62 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); | 62 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); |
63 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); | 63 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle& constant) { | 67 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) { |
68 address pc = _instructions->start() + pc_offset; | 68 address pc = _instructions->start() + pc_offset; |
69 if (HotSpotMetaspaceConstantImpl::compressed(constant)) { | 69 if (HotSpotMetaspaceConstantImpl::compressed(constant)) { |
70 #ifdef _LP64 | 70 #ifdef _LP64 |
71 NativeMovConstReg32* move = nativeMovConstReg32_at(pc); | 71 NativeMovConstReg32* move = nativeMovConstReg32_at(pc); |
72 narrowKlass narrowOop = record_narrow_metadata_reference(constant); | 72 narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK); |
73 move->set_data((intptr_t)narrowOop); | 73 move->set_data((intptr_t)narrowOop); |
74 TRACE_jvmci_3("relocating (narrow metaspace constant) at %p/%p", pc, narrowOop); | 74 TRACE_jvmci_3("relocating (narrow metaspace constant) at %p/%p", pc, narrowOop); |
75 #else | 75 #else |
76 fatal("compressed Klass* on 32bit"); | 76 JVMCI_ERROR("compressed Klass* on 32bit"); |
77 #endif | 77 #endif |
78 } else { | 78 } else { |
79 NativeMovConstReg* move = nativeMovConstReg_at(pc); | 79 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
80 Metadata* reference = record_metadata_reference(constant); | 80 Metadata* reference = record_metadata_reference(constant, CHECK); |
81 move->set_data((intptr_t)reference); | 81 move->set_data((intptr_t)reference); |
82 TRACE_jvmci_3("relocating (metaspace constant) at %p/%p", pc, reference); | 82 TRACE_jvmci_3("relocating (metaspace constant) at %p/%p", pc, reference); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
102 load->set_offset(- (const_size - data_offset + Assembler::min_simm13())); | 102 load->set_offset(- (const_size - data_offset + Assembler::min_simm13())); |
103 TRACE_jvmci_3("relocating ld at %p (+%d) with destination at %d", pc, pc_offset, data_offset); | 103 TRACE_jvmci_3("relocating ld at %p (+%d) with destination at %d", pc, pc_offset, data_offset); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { | 107 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) { |
108 address pc = (address) inst; | 108 address pc = (address) inst; |
109 if (inst->is_call()) { | 109 if (inst->is_call()) { |
110 NativeCall* call = nativeCall_at(pc); | 110 NativeCall* call = nativeCall_at(pc); |
111 call->set_destination((address) foreign_call_destination); | 111 call->set_destination((address) foreign_call_destination); |
112 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); | 112 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); |
113 } else if (inst->is_sethi()) { | 113 } else if (inst->is_sethi()) { |
114 NativeJump* jump = nativeJump_at(pc); | 114 NativeJump* jump = nativeJump_at(pc); |
115 jump->set_jump_destination((address) foreign_call_destination); | 115 jump->set_jump_destination((address) foreign_call_destination); |
116 _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); | 116 _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); |
117 } else { | 117 } else { |
118 fatal(err_msg("unknown call or jump instruction at %p", pc)); | 118 JVMCI_ERROR(err_msg("unknown call or jump instruction at " PTR_FORMAT, p2i(pc))); |
119 } | 119 } |
120 TRACE_jvmci_3("relocating (foreign call) at %p", inst); | 120 TRACE_jvmci_3("relocating (foreign call) at %p", inst); |
121 } | 121 } |
122 | 122 |
123 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { | 123 void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) { |
124 #ifdef ASSERT | 124 #ifdef ASSERT |
125 Method* method = NULL; | 125 Method* method = NULL; |
126 // we need to check, this might also be an unresolved method | 126 // we need to check, this might also be an unresolved method |
127 if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { | 127 if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { |
128 method = getMethodFromHotSpotMethod(hotspot_method); | 128 method = getMethodFromHotSpotMethod(hotspot_method()); |
129 } | 129 } |
130 #endif | 130 #endif |
131 switch (_next_call_type) { | 131 switch (_next_call_type) { |
132 case INLINE_INVOKE: | 132 case INLINE_INVOKE: |
133 break; | 133 break; |
152 call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); | 152 call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); |
153 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); | 153 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); |
154 break; | 154 break; |
155 } | 155 } |
156 default: | 156 default: |
157 fatal("invalid _next_call_type value"); | 157 JVMCI_ERROR("invalid _next_call_type value"); |
158 break; | 158 break; |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 void CodeInstaller::pd_relocate_poll(address pc, jint mark) { | 162 void CodeInstaller::pd_relocate_poll(address pc, jint mark, TRAPS) { |
163 switch (mark) { | 163 switch (mark) { |
164 case POLL_NEAR: | 164 case POLL_NEAR: |
165 fatal("unimplemented"); | 165 JVMCI_ERROR("unimplemented"); |
166 break; | 166 break; |
167 case POLL_FAR: | 167 case POLL_FAR: |
168 _instructions->relocate(pc, relocInfo::poll_type); | 168 _instructions->relocate(pc, relocInfo::poll_type); |
169 break; | 169 break; |
170 case POLL_RETURN_NEAR: | 170 case POLL_RETURN_NEAR: |
171 fatal("unimplemented"); | 171 JVMCI_ERROR("unimplemented"); |
172 break; | 172 break; |
173 case POLL_RETURN_FAR: | 173 case POLL_RETURN_FAR: |
174 _instructions->relocate(pc, relocInfo::poll_return_type); | 174 _instructions->relocate(pc, relocInfo::poll_return_type); |
175 break; | 175 break; |
176 default: | 176 default: |
177 fatal("invalid mark value"); | 177 JVMCI_ERROR("invalid mark value"); |
178 break; | 178 break; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 // convert JVMCI register indices (as used in oop maps) to HotSpot registers | 182 // convert JVMCI register indices (as used in oop maps) to HotSpot registers |
183 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) { | 183 VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) { |
184 // JVMCI Registers are numbered as follows: | 184 // JVMCI Registers are numbered as follows: |
185 // 0..31: Thirty-two General Purpose registers (CPU Registers) | 185 // 0..31: Thirty-two General Purpose registers (CPU Registers) |
186 // 32..63: Thirty-two single precision float registers | 186 // 32..63: Thirty-two single precision float registers |
187 // 64..95: Thirty-two double precision float registers | 187 // 64..95: Thirty-two double precision float registers |
188 // 96..111: Sixteen quad precision float registers | 188 // 96..111: Sixteen quad precision float registers |
195 } else if(jvmci_reg < 96) { | 195 } else if(jvmci_reg < 96) { |
196 floatRegisterNumber = 2 * (jvmci_reg - 64); | 196 floatRegisterNumber = 2 * (jvmci_reg - 64); |
197 } else if(jvmci_reg < 112) { | 197 } else if(jvmci_reg < 112) { |
198 floatRegisterNumber = 4 * (jvmci_reg - 96); | 198 floatRegisterNumber = 4 * (jvmci_reg - 96); |
199 } else { | 199 } else { |
200 fatal("Unknown jvmci register"); | 200 JVMCI_ERROR_NULL(err_msg("invalid register number: %d", jvmci_reg)); |
201 } | 201 } |
202 return as_FloatRegister(floatRegisterNumber)->as_VMReg(); | 202 return as_FloatRegister(floatRegisterNumber)->as_VMReg(); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |