226 |
226 |
227 // There was no special inlining tactic, or it bailed out. |
227 // There was no special inlining tactic, or it bailed out. |
228 // Use a more generic tactic, like a simple call. |
228 // Use a more generic tactic, like a simple call. |
229 if (call_is_virtual) { |
229 if (call_is_virtual) { |
230 return CallGenerator::for_virtual_call(call_method, vtable_index); |
230 return CallGenerator::for_virtual_call(call_method, vtable_index); |
|
231 } else if (call_method->is_method_handle_invoke()) { |
|
232 if (jvms->method()->java_code_at_bci(jvms->bci()) == Bytecodes::_invokedynamic) |
|
233 return CallGenerator::for_dynamic_call(call_method); |
|
234 else |
|
235 // %%% if the target MH is a compile-time constant, we should try to inline it |
|
236 return CallGenerator::for_direct_call(call_method); |
231 } else { |
237 } else { |
232 // Class Hierarchy Analysis or Type Profile reveals a unique target, |
238 // Class Hierarchy Analysis or Type Profile reveals a unique target, |
233 // or it is a static or special call. |
239 // or it is a static or special call. |
234 return CallGenerator::for_direct_call(call_method, should_delay_inlining(call_method, jvms)); |
240 return CallGenerator::for_direct_call(call_method, should_delay_inlining(call_method, jvms)); |
235 } |
241 } |
297 // iter().get_method_holder_index() |
303 // iter().get_method_holder_index() |
298 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" ); |
304 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" ); |
299 // Interface classes can be loaded & linked and never get around to |
305 // Interface classes can be loaded & linked and never get around to |
300 // being initialized. Uncommon-trap for not-initialized static or |
306 // being initialized. Uncommon-trap for not-initialized static or |
301 // v-calls. Let interface calls happen. |
307 // v-calls. Let interface calls happen. |
302 ciInstanceKlass* holder_klass = dest_method->holder(); |
308 ciInstanceKlass* holder_klass = dest_method->holder(); |
303 if (!holder_klass->is_initialized() && |
309 if (!holder_klass->is_initialized() && |
304 !holder_klass->is_interface()) { |
310 !holder_klass->is_interface()) { |
305 uncommon_trap(Deoptimization::Reason_uninitialized, |
311 uncommon_trap(Deoptimization::Reason_uninitialized, |
306 Deoptimization::Action_reinterpret, |
312 Deoptimization::Action_reinterpret, |
307 holder_klass); |
|
308 return true; |
|
309 } |
|
310 if (dest_method->is_method_handle_invoke() |
|
311 && holder_klass->name() == ciSymbol::java_dyn_InvokeDynamic()) { |
|
312 // FIXME: NYI |
|
313 uncommon_trap(Deoptimization::Reason_unhandled, |
|
314 Deoptimization::Action_none, |
|
315 holder_klass); |
313 holder_klass); |
316 return true; |
314 return true; |
317 } |
315 } |
318 |
316 |
319 assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility"); |
317 assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility"); |
331 |
329 |
332 // Set frequently used booleans |
330 // Set frequently used booleans |
333 bool is_virtual = bc() == Bytecodes::_invokevirtual; |
331 bool is_virtual = bc() == Bytecodes::_invokevirtual; |
334 bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface; |
332 bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface; |
335 bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial; |
333 bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial; |
|
334 bool is_invokedynamic = bc() == Bytecodes::_invokedynamic; |
336 |
335 |
337 // Find target being called |
336 // Find target being called |
338 bool will_link; |
337 bool will_link; |
339 ciMethod* dest_method = iter().get_method(will_link); |
338 ciMethod* dest_method = iter().get_method(will_link); |
340 ciInstanceKlass* holder_klass = dest_method->holder(); |
339 ciInstanceKlass* holder_klass = dest_method->holder(); |
341 ciKlass* holder = iter().get_declared_method_holder(); |
340 ciKlass* holder = iter().get_declared_method_holder(); |
342 ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder); |
341 ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder); |
343 |
342 |
344 int nargs = dest_method->arg_size(); |
343 int nargs = dest_method->arg_size(); |
|
344 if (is_invokedynamic) nargs -= 1; |
345 |
345 |
346 // uncommon-trap when callee is unloaded, uninitialized or will not link |
346 // uncommon-trap when callee is unloaded, uninitialized or will not link |
347 // bailout when too many arguments for register representation |
347 // bailout when too many arguments for register representation |
348 if (!will_link || can_not_compile_call_site(dest_method, klass)) { |
348 if (!will_link || can_not_compile_call_site(dest_method, klass)) { |
349 #ifndef PRODUCT |
349 #ifndef PRODUCT |
353 } |
353 } |
354 #endif |
354 #endif |
355 return; |
355 return; |
356 } |
356 } |
357 assert(holder_klass->is_loaded(), ""); |
357 assert(holder_klass->is_loaded(), ""); |
358 assert(dest_method->is_static() == !has_receiver, "must match bc"); |
358 assert((dest_method->is_static() || is_invokedynamic) == !has_receiver , "must match bc"); |
359 // Note: this takes into account invokeinterface of methods declared in java/lang/Object, |
359 // Note: this takes into account invokeinterface of methods declared in java/lang/Object, |
360 // which should be invokevirtuals but according to the VM spec may be invokeinterfaces |
360 // which should be invokevirtuals but according to the VM spec may be invokeinterfaces |
361 assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc"); |
361 assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc"); |
362 // Note: In the absence of miranda methods, an abstract class K can perform |
362 // Note: In the absence of miranda methods, an abstract class K can perform |
363 // an invokevirtual directly on an interface method I.m if K implements I. |
363 // an invokevirtual directly on an interface method I.m if K implements I. |