Mercurial > hg > truffle
comparison src/share/vm/interpreter/linkResolver.cpp @ 6822:f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
Reviewed-by: jrose, kvn
author | twisti |
---|---|
date | Mon, 01 Oct 2012 14:50:10 -0700 |
parents | d17383603741 |
children | 4735d2c84362 77443715ec55 |
comparison
equal
deleted
inserted
replaced
6811:1b582b1bf7cb | 6822:f6b0eb4e44cf |
---|---|
97 assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); | 97 assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); |
98 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK); | 98 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK); |
99 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); | 99 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
100 } | 100 } |
101 | 101 |
102 void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, TRAPS) { | 102 void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS) { |
103 if (resolved_method.is_null()) { | 103 if (resolved_method.is_null()) { |
104 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); | 104 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); |
105 } | 105 } |
106 KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass(); | 106 KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass(); |
107 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || | 107 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || |
108 resolved_method->is_compiled_lambda_form(), | 108 resolved_method->is_compiled_lambda_form(), |
109 "linkMethod must return one of these"); | 109 "linkMethod must return one of these"); |
110 int vtable_index = Method::nonvirtual_vtable_index; | 110 int vtable_index = Method::nonvirtual_vtable_index; |
111 assert(resolved_method->vtable_index() == vtable_index, ""); | 111 assert(resolved_method->vtable_index() == vtable_index, ""); |
112 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK); | 112 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK); |
113 _resolved_appendix = resolved_appendix; | 113 _resolved_appendix = resolved_appendix; |
114 _resolved_method_type = resolved_method_type; | |
114 } | 115 } |
115 | 116 |
116 void CallInfo::set_common(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { | 117 void CallInfo::set_common(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { |
117 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); | 118 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); |
118 _resolved_klass = resolved_klass; | 119 _resolved_klass = resolved_klass; |
219 } | 220 } |
220 | 221 |
221 void LinkResolver::lookup_polymorphic_method(methodHandle& result, | 222 void LinkResolver::lookup_polymorphic_method(methodHandle& result, |
222 KlassHandle klass, Symbol* name, Symbol* full_signature, | 223 KlassHandle klass, Symbol* name, Symbol* full_signature, |
223 KlassHandle current_klass, | 224 KlassHandle current_klass, |
224 Handle* appendix_result_or_null, | 225 Handle *appendix_result_or_null, |
226 Handle *method_type_result, | |
225 TRAPS) { | 227 TRAPS) { |
226 vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name); | 228 vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name); |
227 if (TraceMethodHandles) { | 229 if (TraceMethodHandles) { |
228 tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s", | 230 tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s", |
229 vmIntrinsics::name_at(iid), klass->external_name(), | 231 vmIntrinsics::name_at(iid), klass->external_name(), |
273 CHECK); | 275 CHECK); |
274 } | 276 } |
275 } | 277 } |
276 | 278 |
277 Handle appendix; | 279 Handle appendix; |
280 Handle method_type; | |
278 result = SystemDictionary::find_method_handle_invoker(name, | 281 result = SystemDictionary::find_method_handle_invoker(name, |
279 full_signature, | 282 full_signature, |
280 current_klass, | 283 current_klass, |
281 &appendix, | 284 &appendix, |
285 &method_type, | |
282 CHECK); | 286 CHECK); |
283 if (TraceMethodHandles) { | 287 if (TraceMethodHandles) { |
284 tty->print("lookup_polymorphic_method => (via Java) "); | 288 tty->print("lookup_polymorphic_method => (via Java) "); |
285 result->print_on(tty); | 289 result->print_on(tty); |
286 tty->print(" lookup_polymorphic_method => appendix = "); | 290 tty->print(" lookup_polymorphic_method => appendix = "); |
305 err_msg("%d != %d", actual_size_of_params, expected_size_of_params)); | 309 err_msg("%d != %d", actual_size_of_params, expected_size_of_params)); |
306 #endif //ASSERT | 310 #endif //ASSERT |
307 | 311 |
308 assert(appendix_result_or_null != NULL, ""); | 312 assert(appendix_result_or_null != NULL, ""); |
309 (*appendix_result_or_null) = appendix; | 313 (*appendix_result_or_null) = appendix; |
314 (*method_type_result) = method_type; | |
310 return; | 315 return; |
311 } | 316 } |
312 } | 317 } |
313 } | 318 } |
314 } | 319 } |
417 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); | 422 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); |
418 | 423 |
419 if (resolved_method.is_null()) { | 424 if (resolved_method.is_null()) { |
420 // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc | 425 // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
421 lookup_polymorphic_method(resolved_method, resolved_klass, method_name, method_signature, | 426 lookup_polymorphic_method(resolved_method, resolved_klass, method_name, method_signature, |
422 current_klass, (Handle*)NULL, THREAD); | 427 current_klass, (Handle*)NULL, (Handle*)NULL, THREAD); |
423 if (HAS_PENDING_EXCEPTION) { | 428 if (HAS_PENDING_EXCEPTION) { |
424 nested_exception = Handle(THREAD, PENDING_EXCEPTION); | 429 nested_exception = Handle(THREAD, PENDING_EXCEPTION); |
425 CLEAR_PENDING_EXCEPTION; | 430 CLEAR_PENDING_EXCEPTION; |
426 } | 431 } |
427 } | 432 } |
1205 TRAPS) { | 1210 TRAPS) { |
1206 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar | 1211 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar |
1207 assert(resolved_klass() == SystemDictionary::MethodHandle_klass(), ""); | 1212 assert(resolved_klass() == SystemDictionary::MethodHandle_klass(), ""); |
1208 assert(MethodHandles::is_signature_polymorphic_name(method_name), ""); | 1213 assert(MethodHandles::is_signature_polymorphic_name(method_name), ""); |
1209 methodHandle resolved_method; | 1214 methodHandle resolved_method; |
1210 Handle resolved_appendix; | 1215 Handle resolved_appendix; |
1216 Handle resolved_method_type; | |
1211 lookup_polymorphic_method(resolved_method, resolved_klass, | 1217 lookup_polymorphic_method(resolved_method, resolved_klass, |
1212 method_name, method_signature, | 1218 method_name, method_signature, |
1213 current_klass, &resolved_appendix, CHECK); | 1219 current_klass, &resolved_appendix, &resolved_method_type, CHECK); |
1214 result.set_handle(resolved_method, resolved_appendix, CHECK); | 1220 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
1215 } | 1221 } |
1216 | 1222 |
1217 | 1223 |
1218 void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { | 1224 void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { |
1219 assert(EnableInvokeDynamic, ""); | 1225 assert(EnableInvokeDynamic, ""); |
1220 pool->set_invokedynamic(); // mark header to flag active call sites | 1226 pool->set_invokedynamic(); // mark header to flag active call sites |
1221 | 1227 |
1222 //resolve_pool(<resolved_klass>, method_name, method_signature, current_klass, pool, index, CHECK); | 1228 //resolve_pool(<resolved_klass>, method_name, method_signature, current_klass, pool, index, CHECK); |
1223 Symbol* method_name = pool->name_ref_at(index); | 1229 Symbol* method_name = pool->name_ref_at(index); |
1224 Symbol* method_signature = pool->signature_ref_at(index); | 1230 Symbol* method_signature = pool->signature_ref_at(index); |
1225 KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); | 1231 KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); |
1226 | 1232 |
1227 // Resolve the bootstrap specifier (BSM + optional arguments). | 1233 // Resolve the bootstrap specifier (BSM + optional arguments). |
1234 assert(bsm_info != NULL, ""); | 1240 assert(bsm_info != NULL, ""); |
1235 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. | 1241 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. |
1236 bootstrap_specifier = Handle(THREAD, bsm_info); | 1242 bootstrap_specifier = Handle(THREAD, bsm_info); |
1237 } | 1243 } |
1238 if (!cpce->is_f1_null()) { | 1244 if (!cpce->is_f1_null()) { |
1239 methodHandle method(THREAD, cpce->f1_as_method()); | 1245 methodHandle method( THREAD, cpce->f1_as_method()); |
1240 Handle appendix(THREAD, cpce->appendix_if_resolved(pool)); | 1246 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
1241 result.set_handle(method, appendix, CHECK); | 1247 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
1248 result.set_handle(method, appendix, method_type, CHECK); | |
1242 return; | 1249 return; |
1243 } | 1250 } |
1244 | 1251 |
1245 if (TraceMethodHandles) { | 1252 if (TraceMethodHandles) { |
1246 tty->print_cr("resolve_invokedynamic #%d %s %s", | 1253 tty->print_cr("resolve_invokedynamic #%d %s %s", |
1258 KlassHandle current_klass, | 1265 KlassHandle current_klass, |
1259 TRAPS) { | 1266 TRAPS) { |
1260 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) | 1267 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) |
1261 // The appendix argument is likely to be a freshly-created CallSite. | 1268 // The appendix argument is likely to be a freshly-created CallSite. |
1262 Handle resolved_appendix; | 1269 Handle resolved_appendix; |
1270 Handle resolved_method_type; | |
1263 methodHandle resolved_method = | 1271 methodHandle resolved_method = |
1264 SystemDictionary::find_dynamic_call_site_invoker(current_klass, | 1272 SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
1265 bootstrap_specifier, | 1273 bootstrap_specifier, |
1266 method_name, method_signature, | 1274 method_name, method_signature, |
1267 &resolved_appendix, | 1275 &resolved_appendix, |
1276 &resolved_method_type, | |
1268 THREAD); | 1277 THREAD); |
1269 if (HAS_PENDING_EXCEPTION) { | 1278 if (HAS_PENDING_EXCEPTION) { |
1270 if (TraceMethodHandles) { | 1279 if (TraceMethodHandles) { |
1271 tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, PENDING_EXCEPTION); | 1280 tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, PENDING_EXCEPTION); |
1272 PENDING_EXCEPTION->print(); | 1281 PENDING_EXCEPTION->print(); |
1282 // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. | 1291 // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. |
1283 Handle nested_exception(THREAD, PENDING_EXCEPTION); | 1292 Handle nested_exception(THREAD, PENDING_EXCEPTION); |
1284 CLEAR_PENDING_EXCEPTION; | 1293 CLEAR_PENDING_EXCEPTION; |
1285 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) | 1294 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) |
1286 } | 1295 } |
1287 result.set_handle(resolved_method, resolved_appendix, CHECK); | 1296 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
1288 } | 1297 } |
1289 | 1298 |
1290 //------------------------------------------------------------------------------------------------------------------------ | 1299 //------------------------------------------------------------------------------------------------------------------------ |
1291 #ifndef PRODUCT | 1300 #ifndef PRODUCT |
1292 | 1301 |