Wed, 29 Sep 2010 00:30:57 -0700
6987634: JSR 292 assert(start_bci() >= 0 && start_bci() < code_size()) failed: correct osr_bci argument
Reviewed-by: never, kvn
src/share/vm/opto/doCall.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/opto/doCall.cpp Mon Sep 27 20:44:18 2010 -0700 1.2 +++ b/src/share/vm/opto/doCall.cpp Wed Sep 29 00:30:57 2010 -0700 1.3 @@ -94,6 +94,60 @@ 1.4 if (cg != NULL) return cg; 1.5 } 1.6 1.7 + // Do MethodHandle calls. 1.8 + // NOTE: This must happen before normal inlining logic below since 1.9 + // MethodHandle.invoke* are native methods which obviously don't 1.10 + // have bytecodes and so normal inlining fails. 1.11 + if (call_method->is_method_handle_invoke()) { 1.12 + if (jvms->method()->java_code_at_bci(jvms->bci()) != Bytecodes::_invokedynamic) { 1.13 + GraphKit kit(jvms); 1.14 + Node* n = kit.argument(0); 1.15 + 1.16 + if (n->Opcode() == Op_ConP) { 1.17 + const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr(); 1.18 + ciObject* const_oop = oop_ptr->const_oop(); 1.19 + ciMethodHandle* method_handle = const_oop->as_method_handle(); 1.20 + 1.21 + // Set the actually called method to have access to the class 1.22 + // and signature in the MethodHandleCompiler. 1.23 + method_handle->set_callee(call_method); 1.24 + 1.25 + // Get an adapter for the MethodHandle. 1.26 + ciMethod* target_method = method_handle->get_method_handle_adapter(); 1.27 + 1.28 + CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); 1.29 + if (hit_cg != NULL && hit_cg->is_inline()) 1.30 + return hit_cg; 1.31 + } 1.32 + 1.33 + return CallGenerator::for_direct_call(call_method); 1.34 + } 1.35 + else { 1.36 + // Get the MethodHandle from the CallSite. 1.37 + ciMethod* caller_method = jvms->method(); 1.38 + ciBytecodeStream str(caller_method); 1.39 + str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. 1.40 + ciCallSite* call_site = str.get_call_site(); 1.41 + ciMethodHandle* method_handle = call_site->get_target(); 1.42 + 1.43 + // Set the actually called method to have access to the class 1.44 + // and signature in the MethodHandleCompiler. 1.45 + method_handle->set_callee(call_method); 1.46 + 1.47 + // Get an adapter for the MethodHandle. 1.48 + ciMethod* target_method = method_handle->get_invokedynamic_adapter(); 1.49 + 1.50 + CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); 1.51 + if (hit_cg != NULL && hit_cg->is_inline()) { 1.52 + CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method); 1.53 + return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor); 1.54 + } 1.55 + 1.56 + // If something failed, generate a normal dynamic call. 1.57 + return CallGenerator::for_dynamic_call(call_method); 1.58 + } 1.59 + } 1.60 + 1.61 // Do not inline strict fp into non-strict code, or the reverse 1.62 bool caller_method_is_strict = jvms->method()->is_strict(); 1.63 if( caller_method_is_strict ^ call_method->is_strict() ) { 1.64 @@ -216,57 +270,6 @@ 1.65 } 1.66 } 1.67 1.68 - // Do MethodHandle calls. 1.69 - if (call_method->is_method_handle_invoke()) { 1.70 - if (jvms->method()->java_code_at_bci(jvms->bci()) != Bytecodes::_invokedynamic) { 1.71 - GraphKit kit(jvms); 1.72 - Node* n = kit.argument(0); 1.73 - 1.74 - if (n->Opcode() == Op_ConP) { 1.75 - const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr(); 1.76 - ciObject* const_oop = oop_ptr->const_oop(); 1.77 - ciMethodHandle* method_handle = const_oop->as_method_handle(); 1.78 - 1.79 - // Set the actually called method to have access to the class 1.80 - // and signature in the MethodHandleCompiler. 1.81 - method_handle->set_callee(call_method); 1.82 - 1.83 - // Get an adapter for the MethodHandle. 1.84 - ciMethod* target_method = method_handle->get_method_handle_adapter(); 1.85 - 1.86 - CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); 1.87 - if (hit_cg != NULL && hit_cg->is_inline()) 1.88 - return hit_cg; 1.89 - } 1.90 - 1.91 - return CallGenerator::for_direct_call(call_method); 1.92 - } 1.93 - else { 1.94 - // Get the MethodHandle from the CallSite. 1.95 - ciMethod* caller_method = jvms->method(); 1.96 - ciBytecodeStream str(caller_method); 1.97 - str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. 1.98 - ciCallSite* call_site = str.get_call_site(); 1.99 - ciMethodHandle* method_handle = call_site->get_target(); 1.100 - 1.101 - // Set the actually called method to have access to the class 1.102 - // and signature in the MethodHandleCompiler. 1.103 - method_handle->set_callee(call_method); 1.104 - 1.105 - // Get an adapter for the MethodHandle. 1.106 - ciMethod* target_method = method_handle->get_invokedynamic_adapter(); 1.107 - 1.108 - CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); 1.109 - if (hit_cg != NULL && hit_cg->is_inline()) { 1.110 - CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method); 1.111 - return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor); 1.112 - } 1.113 - 1.114 - // If something failed, generate a normal dynamic call. 1.115 - return CallGenerator::for_dynamic_call(call_method); 1.116 - } 1.117 - } 1.118 - 1.119 // There was no special inlining tactic, or it bailed out. 1.120 // Use a more generic tactic, like a simple call. 1.121 if (call_is_virtual) {