comparison src/share/vm/opto/doCall.cpp @ 1823:8aa5fd5d2046

6987634: JSR 292 assert(start_bci() >= 0 && start_bci() < code_size()) failed: correct osr_bci argument Reviewed-by: never, kvn
author twisti
date Wed, 29 Sep 2010 00:30:57 -0700
parents 3941674cc7fa
children f95d63e2154a
comparison
equal deleted inserted replaced
1822:1375bc8922e4 1823:8aa5fd5d2046
90 // We do this before the strict f.p. check below because the 90 // We do this before the strict f.p. check below because the
91 // intrinsics handle strict f.p. correctly. 91 // intrinsics handle strict f.p. correctly.
92 if (allow_inline) { 92 if (allow_inline) {
93 cg = find_intrinsic(call_method, call_is_virtual); 93 cg = find_intrinsic(call_method, call_is_virtual);
94 if (cg != NULL) return cg; 94 if (cg != NULL) return cg;
95 }
96
97 // Do MethodHandle calls.
98 // NOTE: This must happen before normal inlining logic below since
99 // MethodHandle.invoke* are native methods which obviously don't
100 // have bytecodes and so normal inlining fails.
101 if (call_method->is_method_handle_invoke()) {
102 if (jvms->method()->java_code_at_bci(jvms->bci()) != Bytecodes::_invokedynamic) {
103 GraphKit kit(jvms);
104 Node* n = kit.argument(0);
105
106 if (n->Opcode() == Op_ConP) {
107 const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr();
108 ciObject* const_oop = oop_ptr->const_oop();
109 ciMethodHandle* method_handle = const_oop->as_method_handle();
110
111 // Set the actually called method to have access to the class
112 // and signature in the MethodHandleCompiler.
113 method_handle->set_callee(call_method);
114
115 // Get an adapter for the MethodHandle.
116 ciMethod* target_method = method_handle->get_method_handle_adapter();
117
118 CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
119 if (hit_cg != NULL && hit_cg->is_inline())
120 return hit_cg;
121 }
122
123 return CallGenerator::for_direct_call(call_method);
124 }
125 else {
126 // Get the MethodHandle from the CallSite.
127 ciMethod* caller_method = jvms->method();
128 ciBytecodeStream str(caller_method);
129 str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci.
130 ciCallSite* call_site = str.get_call_site();
131 ciMethodHandle* method_handle = call_site->get_target();
132
133 // Set the actually called method to have access to the class
134 // and signature in the MethodHandleCompiler.
135 method_handle->set_callee(call_method);
136
137 // Get an adapter for the MethodHandle.
138 ciMethod* target_method = method_handle->get_invokedynamic_adapter();
139
140 CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
141 if (hit_cg != NULL && hit_cg->is_inline()) {
142 CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method);
143 return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor);
144 }
145
146 // If something failed, generate a normal dynamic call.
147 return CallGenerator::for_dynamic_call(call_method);
148 }
95 } 149 }
96 150
97 // Do not inline strict fp into non-strict code, or the reverse 151 // Do not inline strict fp into non-strict code, or the reverse
98 bool caller_method_is_strict = jvms->method()->is_strict(); 152 bool caller_method_is_strict = jvms->method()->is_strict();
99 if( caller_method_is_strict ^ call_method->is_strict() ) { 153 if( caller_method_is_strict ^ call_method->is_strict() ) {
214 } 268 }
215 } 269 }
216 } 270 }
217 } 271 }
218 272
219 // Do MethodHandle calls.
220 if (call_method->is_method_handle_invoke()) {
221 if (jvms->method()->java_code_at_bci(jvms->bci()) != Bytecodes::_invokedynamic) {
222 GraphKit kit(jvms);
223 Node* n = kit.argument(0);
224
225 if (n->Opcode() == Op_ConP) {
226 const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr();
227 ciObject* const_oop = oop_ptr->const_oop();
228 ciMethodHandle* method_handle = const_oop->as_method_handle();
229
230 // Set the actually called method to have access to the class
231 // and signature in the MethodHandleCompiler.
232 method_handle->set_callee(call_method);
233
234 // Get an adapter for the MethodHandle.
235 ciMethod* target_method = method_handle->get_method_handle_adapter();
236
237 CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
238 if (hit_cg != NULL && hit_cg->is_inline())
239 return hit_cg;
240 }
241
242 return CallGenerator::for_direct_call(call_method);
243 }
244 else {
245 // Get the MethodHandle from the CallSite.
246 ciMethod* caller_method = jvms->method();
247 ciBytecodeStream str(caller_method);
248 str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci.
249 ciCallSite* call_site = str.get_call_site();
250 ciMethodHandle* method_handle = call_site->get_target();
251
252 // Set the actually called method to have access to the class
253 // and signature in the MethodHandleCompiler.
254 method_handle->set_callee(call_method);
255
256 // Get an adapter for the MethodHandle.
257 ciMethod* target_method = method_handle->get_invokedynamic_adapter();
258
259 CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
260 if (hit_cg != NULL && hit_cg->is_inline()) {
261 CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method);
262 return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor);
263 }
264
265 // If something failed, generate a normal dynamic call.
266 return CallGenerator::for_dynamic_call(call_method);
267 }
268 }
269
270 // There was no special inlining tactic, or it bailed out. 273 // There was no special inlining tactic, or it bailed out.
271 // Use a more generic tactic, like a simple call. 274 // Use a more generic tactic, like a simple call.
272 if (call_is_virtual) { 275 if (call_is_virtual) {
273 return CallGenerator::for_virtual_call(call_method, vtable_index); 276 return CallGenerator::for_virtual_call(call_method, vtable_index);
274 } else { 277 } else {