60 #endif |
60 #endif |
61 |
61 |
62 CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual, |
62 CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual, |
63 JVMState* jvms, bool allow_inline, |
63 JVMState* jvms, bool allow_inline, |
64 float prof_factor) { |
64 float prof_factor) { |
65 CallGenerator* cg; |
65 CallGenerator* cg; |
|
66 ciMethod* caller = jvms->method(); |
|
67 int bci = jvms->bci(); |
|
68 Bytecodes::Code bytecode = caller->java_code_at_bci(bci); |
66 guarantee(call_method != NULL, "failed method resolution"); |
69 guarantee(call_method != NULL, "failed method resolution"); |
67 |
70 |
68 // Dtrace currently doesn't work unless all calls are vanilla |
71 // Dtrace currently doesn't work unless all calls are vanilla |
69 if (env()->dtrace_method_probes()) { |
72 if (env()->dtrace_method_probes()) { |
70 allow_inline = false; |
73 allow_inline = false; |
71 } |
74 } |
72 |
75 |
73 // Note: When we get profiling during stage-1 compiles, we want to pull |
76 // Note: When we get profiling during stage-1 compiles, we want to pull |
74 // from more specific profile data which pertains to this inlining. |
77 // from more specific profile data which pertains to this inlining. |
75 // Right now, ignore the information in jvms->caller(), and do method[bci]. |
78 // Right now, ignore the information in jvms->caller(), and do method[bci]. |
76 ciCallProfile profile = jvms->method()->call_profile_at_bci(jvms->bci()); |
79 ciCallProfile profile = caller->call_profile_at_bci(bci); |
77 Bytecodes::Code bytecode = jvms->method()->java_code_at_bci(jvms->bci()); |
|
78 |
80 |
79 // See how many times this site has been invoked. |
81 // See how many times this site has been invoked. |
80 int site_count = profile.count(); |
82 int site_count = profile.count(); |
81 int receiver_count = -1; |
83 int receiver_count = -1; |
82 if (call_is_virtual && UseTypeProfile && profile.has_receiver(0)) { |
84 if (call_is_virtual && UseTypeProfile && profile.has_receiver(0)) { |
124 if (n->Opcode() == Op_ConP) { |
126 if (n->Opcode() == Op_ConP) { |
125 const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr(); |
127 const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr(); |
126 ciObject* const_oop = oop_ptr->const_oop(); |
128 ciObject* const_oop = oop_ptr->const_oop(); |
127 ciMethodHandle* method_handle = const_oop->as_method_handle(); |
129 ciMethodHandle* method_handle = const_oop->as_method_handle(); |
128 |
130 |
129 // Set the actually called method to have access to the class |
131 // Set the callee to have access to the class and signature in |
130 // and signature in the MethodHandleCompiler. |
132 // the MethodHandleCompiler. |
131 method_handle->set_callee(call_method); |
133 method_handle->set_callee(call_method); |
|
134 method_handle->set_caller(caller); |
132 method_handle->set_call_profile(&profile); |
135 method_handle->set_call_profile(&profile); |
133 |
136 |
134 // Get an adapter for the MethodHandle. |
137 // Get an adapter for the MethodHandle. |
135 ciMethod* target_method = method_handle->get_method_handle_adapter(); |
138 ciMethod* target_method = method_handle->get_method_handle_adapter(); |
136 if (target_method != NULL) { |
139 if (target_method != NULL) { |
148 ciBytecodeStream str(caller_method); |
151 ciBytecodeStream str(caller_method); |
149 str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. |
152 str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. |
150 ciCallSite* call_site = str.get_call_site(); |
153 ciCallSite* call_site = str.get_call_site(); |
151 ciMethodHandle* method_handle = call_site->get_target(); |
154 ciMethodHandle* method_handle = call_site->get_target(); |
152 |
155 |
153 // Set the actually called method to have access to the class |
156 // Set the callee to have access to the class and signature in |
154 // and signature in the MethodHandleCompiler. |
157 // the MethodHandleCompiler. |
155 method_handle->set_callee(call_method); |
158 method_handle->set_callee(call_method); |
|
159 method_handle->set_caller(caller); |
156 method_handle->set_call_profile(&profile); |
160 method_handle->set_call_profile(&profile); |
157 |
161 |
158 // Get an adapter for the MethodHandle. |
162 // Get an adapter for the MethodHandle. |
159 ciMethod* target_method = method_handle->get_invokedynamic_adapter(); |
163 ciMethod* target_method = method_handle->get_invokedynamic_adapter(); |
160 if (target_method != NULL) { |
164 if (target_method != NULL) { |