159 //----------------------------------------------------------------------------- |
159 //----------------------------------------------------------------------------- |
160 // High-level access to an inline cache. Guaranteed to be MT-safe. |
160 // High-level access to an inline cache. Guaranteed to be MT-safe. |
161 |
161 |
162 |
162 |
163 void CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { |
163 void CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { |
164 methodHandle method = call_info->selected_method(); |
|
165 bool is_invoke_interface = (bytecode == Bytecodes::_invokeinterface && !call_info->has_vtable_index()); |
|
166 assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), ""); |
164 assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), ""); |
167 assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic"); |
165 assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic"); |
168 assert(is_call_to_compiled() || is_call_to_interpreted(), "going directly to megamorphic?"); |
166 assert(is_call_to_compiled() || is_call_to_interpreted(), "going directly to megamorphic?"); |
169 |
167 |
170 address entry; |
168 address entry; |
171 if (is_invoke_interface) { |
169 if (call_info->call_kind() == CallInfo::itable_call) { |
172 int index = klassItable::compute_itable_index(call_info->resolved_method()()); |
170 assert(bytecode == Bytecodes::_invokeinterface, ""); |
173 entry = VtableStubs::create_stub(false, index, method()); |
171 int itable_index = call_info->itable_index(); |
|
172 entry = VtableStubs::find_itable_stub(itable_index); |
|
173 #ifdef ASSERT |
174 assert(entry != NULL, "entry not computed"); |
174 assert(entry != NULL, "entry not computed"); |
|
175 int index = call_info->resolved_method()->itable_index(); |
|
176 assert(index == itable_index, "CallInfo pre-computes this"); |
|
177 #endif //ASSERT |
175 InstanceKlass* k = call_info->resolved_method()->method_holder(); |
178 InstanceKlass* k = call_info->resolved_method()->method_holder(); |
176 assert(k->is_interface(), "sanity check"); |
179 assert(k->verify_itable_index(itable_index), "sanity check"); |
177 InlineCacheBuffer::create_transition_stub(this, k, entry); |
180 InlineCacheBuffer::create_transition_stub(this, k, entry); |
178 } else { |
181 } else { |
179 // Can be different than method->vtable_index(), due to package-private etc. |
182 assert(call_info->call_kind() == CallInfo::vtable_call, "either itable or vtable"); |
|
183 // Can be different than selected_method->vtable_index(), due to package-private etc. |
180 int vtable_index = call_info->vtable_index(); |
184 int vtable_index = call_info->vtable_index(); |
181 entry = VtableStubs::create_stub(true, vtable_index, method()); |
185 assert(call_info->resolved_klass()->verify_vtable_index(vtable_index), "sanity check"); |
182 InlineCacheBuffer::create_transition_stub(this, method(), entry); |
186 entry = VtableStubs::find_vtable_stub(vtable_index); |
|
187 InlineCacheBuffer::create_transition_stub(this, NULL, entry); |
183 } |
188 } |
184 |
189 |
185 if (TraceICs) { |
190 if (TraceICs) { |
186 ResourceMark rm; |
191 ResourceMark rm; |
187 tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT, |
192 tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT, |
188 instruction_address(), method->print_value_string(), entry); |
193 instruction_address(), call_info->selected_method()->print_value_string(), entry); |
189 } |
194 } |
190 |
195 |
191 // We can't check this anymore. With lazy deopt we could have already |
196 // We can't check this anymore. With lazy deopt we could have already |
192 // cleaned this IC entry before we even return. This is possible if |
197 // cleaned this IC entry before we even return. This is possible if |
193 // we ran out of space in the inline cache buffer trying to do the |
198 // we ran out of space in the inline cache buffer trying to do the |