Mercurial > hg > truffle
comparison src/share/vm/opto/doCall.cpp @ 1162:d749b1813f40
Merge
author | trims |
---|---|
date | Fri, 15 Jan 2010 14:25:44 -0800 |
parents | c3b315a0d58a |
children | 87684f1a88b5 |
comparison
equal
deleted
inserted
replaced
1130:1bc68593a110 | 1162:d749b1813f40 |
---|---|
41 tty->print_cr(" (%d bytes)", prof_method->code_size()); | 41 tty->print_cr(" (%d bytes)", prof_method->code_size()); |
42 } | 42 } |
43 } | 43 } |
44 #endif | 44 #endif |
45 | 45 |
46 CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual, JVMState* jvms, bool allow_inline, float prof_factor) { | 46 CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual, |
47 JVMState* jvms, bool allow_inline, | |
48 float prof_factor) { | |
47 CallGenerator* cg; | 49 CallGenerator* cg; |
48 | 50 |
49 // Dtrace currently doesn't work unless all calls are vanilla | 51 // Dtrace currently doesn't work unless all calls are vanilla |
50 if (env()->dtrace_method_probes()) { | 52 if (env()->dtrace_method_probes()) { |
51 allow_inline = false; | 53 allow_inline = false; |
114 } else { | 116 } else { |
115 // Make a disembodied, stateless ILT. | 117 // Make a disembodied, stateless ILT. |
116 // TO DO: When UseOldInlining is removed, copy the ILT code elsewhere. | 118 // TO DO: When UseOldInlining is removed, copy the ILT code elsewhere. |
117 float site_invoke_ratio = prof_factor; | 119 float site_invoke_ratio = prof_factor; |
118 // Note: ilt is for the root of this parse, not the present call site. | 120 // Note: ilt is for the root of this parse, not the present call site. |
119 ilt = new InlineTree(this, jvms->method(), jvms->caller(), site_invoke_ratio); | 121 ilt = new InlineTree(this, jvms->method(), jvms->caller(), site_invoke_ratio, 0); |
120 } | 122 } |
121 WarmCallInfo scratch_ci; | 123 WarmCallInfo scratch_ci; |
122 if (!UseOldInlining) | 124 if (!UseOldInlining) |
123 scratch_ci.init(jvms, call_method, profile, prof_factor); | 125 scratch_ci.init(jvms, call_method, profile, prof_factor); |
124 WarmCallInfo* ci = ilt->ok_to_inline(call_method, jvms, profile, &scratch_ci); | 126 WarmCallInfo* ci = ilt->ok_to_inline(call_method, jvms, profile, &scratch_ci); |
222 } | 224 } |
223 } | 225 } |
224 } | 226 } |
225 } | 227 } |
226 | 228 |
229 // Do MethodHandle calls. | |
230 if (call_method->is_method_handle_invoke()) { | |
231 if (jvms->method()->java_code_at_bci(jvms->bci()) != Bytecodes::_invokedynamic) { | |
232 GraphKit kit(jvms); | |
233 Node* n = kit.argument(0); | |
234 | |
235 if (n->Opcode() == Op_ConP) { | |
236 const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr(); | |
237 ciObject* const_oop = oop_ptr->const_oop(); | |
238 ciMethodHandle* method_handle = const_oop->as_method_handle(); | |
239 | |
240 // Set the actually called method to have access to the class | |
241 // and signature in the MethodHandleCompiler. | |
242 method_handle->set_callee(call_method); | |
243 | |
244 // Get an adapter for the MethodHandle. | |
245 ciMethod* target_method = method_handle->get_method_handle_adapter(); | |
246 | |
247 CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); | |
248 if (hit_cg != NULL && hit_cg->is_inline()) | |
249 return hit_cg; | |
250 } | |
251 | |
252 return CallGenerator::for_direct_call(call_method); | |
253 } | |
254 else { | |
255 // Get the MethodHandle from the CallSite. | |
256 ciMethod* caller_method = jvms->method(); | |
257 ciBytecodeStream str(caller_method); | |
258 str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. | |
259 ciCallSite* call_site = str.get_call_site(); | |
260 ciMethodHandle* method_handle = call_site->get_target(); | |
261 | |
262 // Set the actually called method to have access to the class | |
263 // and signature in the MethodHandleCompiler. | |
264 method_handle->set_callee(call_method); | |
265 | |
266 // Get an adapter for the MethodHandle. | |
267 ciMethod* target_method = method_handle->get_invokedynamic_adapter(); | |
268 | |
269 CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); | |
270 if (hit_cg != NULL && hit_cg->is_inline()) { | |
271 CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method); | |
272 return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor); | |
273 } | |
274 | |
275 // If something failed, generate a normal dynamic call. | |
276 return CallGenerator::for_dynamic_call(call_method); | |
277 } | |
278 } | |
279 | |
227 // There was no special inlining tactic, or it bailed out. | 280 // There was no special inlining tactic, or it bailed out. |
228 // Use a more generic tactic, like a simple call. | 281 // Use a more generic tactic, like a simple call. |
229 if (call_is_virtual) { | 282 if (call_is_virtual) { |
230 return CallGenerator::for_virtual_call(call_method, vtable_index); | 283 return CallGenerator::for_virtual_call(call_method, vtable_index); |
231 } else { | 284 } else { |
297 // iter().get_method_holder_index() | 350 // iter().get_method_holder_index() |
298 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" ); | 351 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" ); |
299 // Interface classes can be loaded & linked and never get around to | 352 // Interface classes can be loaded & linked and never get around to |
300 // being initialized. Uncommon-trap for not-initialized static or | 353 // being initialized. Uncommon-trap for not-initialized static or |
301 // v-calls. Let interface calls happen. | 354 // v-calls. Let interface calls happen. |
302 ciInstanceKlass* holder_klass = dest_method->holder(); | 355 ciInstanceKlass* holder_klass = dest_method->holder(); |
303 if (!holder_klass->is_initialized() && | 356 if (!holder_klass->is_initialized() && |
304 !holder_klass->is_interface()) { | 357 !holder_klass->is_interface()) { |
305 uncommon_trap(Deoptimization::Reason_uninitialized, | 358 uncommon_trap(Deoptimization::Reason_uninitialized, |
306 Deoptimization::Action_reinterpret, | 359 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_Dynamic()) { | |
312 // FIXME: NYI | |
313 uncommon_trap(Deoptimization::Reason_unhandled, | |
314 Deoptimization::Action_none, | |
315 holder_klass); | 360 holder_klass); |
316 return true; | 361 return true; |
317 } | 362 } |
318 | 363 |
319 assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility"); | 364 assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility"); |
331 | 376 |
332 // Set frequently used booleans | 377 // Set frequently used booleans |
333 bool is_virtual = bc() == Bytecodes::_invokevirtual; | 378 bool is_virtual = bc() == Bytecodes::_invokevirtual; |
334 bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface; | 379 bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface; |
335 bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial; | 380 bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial; |
381 bool is_invokedynamic = bc() == Bytecodes::_invokedynamic; | |
336 | 382 |
337 // Find target being called | 383 // Find target being called |
338 bool will_link; | 384 bool will_link; |
339 ciMethod* dest_method = iter().get_method(will_link); | 385 ciMethod* dest_method = iter().get_method(will_link); |
340 ciInstanceKlass* holder_klass = dest_method->holder(); | 386 ciInstanceKlass* holder_klass = dest_method->holder(); |
341 ciKlass* holder = iter().get_declared_method_holder(); | 387 ciKlass* holder = iter().get_declared_method_holder(); |
342 ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder); | 388 ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder); |
343 | 389 |
344 int nargs = dest_method->arg_size(); | 390 int nargs = dest_method->arg_size(); |
391 if (is_invokedynamic) nargs -= 1; | |
345 | 392 |
346 // uncommon-trap when callee is unloaded, uninitialized or will not link | 393 // uncommon-trap when callee is unloaded, uninitialized or will not link |
347 // bailout when too many arguments for register representation | 394 // bailout when too many arguments for register representation |
348 if (!will_link || can_not_compile_call_site(dest_method, klass)) { | 395 if (!will_link || can_not_compile_call_site(dest_method, klass)) { |
349 #ifndef PRODUCT | 396 #ifndef PRODUCT |
353 } | 400 } |
354 #endif | 401 #endif |
355 return; | 402 return; |
356 } | 403 } |
357 assert(holder_klass->is_loaded(), ""); | 404 assert(holder_klass->is_loaded(), ""); |
358 assert(dest_method->is_static() == !has_receiver, "must match bc"); | 405 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, | 406 // 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 | 407 // 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"); | 408 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 | 409 // 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. | 410 // an invokevirtual directly on an interface method I.m if K implements I. |