comparison src/share/vm/code/compiledIC.cpp @ 14422:2b8e28fdf503

Merge
author kvn
date Tue, 05 Nov 2013 17:38:04 -0800
parents 891687731b59
children cefad50507d8 df832bd8edb9
comparison
equal deleted inserted replaced
14421:3068270ba476 14422:2b8e28fdf503
1 /* 1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
158 158
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 bool 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();
174 assert(entry != NULL, "entry not computed"); 172 entry = VtableStubs::find_itable_stub(itable_index);
173 if (entry == false) {
174 return false;
175 }
176 #ifdef ASSERT
177 int index = call_info->resolved_method()->itable_index();
178 assert(index == itable_index, "CallInfo pre-computes this");
179 #endif //ASSERT
175 InstanceKlass* k = call_info->resolved_method()->method_holder(); 180 InstanceKlass* k = call_info->resolved_method()->method_holder();
176 assert(k->is_interface(), "sanity check"); 181 assert(k->verify_itable_index(itable_index), "sanity check");
177 InlineCacheBuffer::create_transition_stub(this, k, entry); 182 InlineCacheBuffer::create_transition_stub(this, k, entry);
178 } else { 183 } else {
179 // Can be different than method->vtable_index(), due to package-private etc. 184 assert(call_info->call_kind() == CallInfo::vtable_call, "either itable or vtable");
185 // Can be different than selected_method->vtable_index(), due to package-private etc.
180 int vtable_index = call_info->vtable_index(); 186 int vtable_index = call_info->vtable_index();
181 entry = VtableStubs::create_stub(true, vtable_index, method()); 187 assert(call_info->resolved_klass()->verify_vtable_index(vtable_index), "sanity check");
182 InlineCacheBuffer::create_transition_stub(this, method(), entry); 188 entry = VtableStubs::find_vtable_stub(vtable_index);
189 if (entry == NULL) {
190 return false;
191 }
192 InlineCacheBuffer::create_transition_stub(this, NULL, entry);
183 } 193 }
184 194
185 if (TraceICs) { 195 if (TraceICs) {
186 ResourceMark rm; 196 ResourceMark rm;
187 tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT, 197 tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT,
188 instruction_address(), method->print_value_string(), entry); 198 instruction_address(), call_info->selected_method()->print_value_string(), entry);
189 } 199 }
190 200
191 // We can't check this anymore. With lazy deopt we could have already 201 // 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 202 // 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 203 // we ran out of space in the inline cache buffer trying to do the
194 // set_next and we safepointed to free up space. This is a benign 204 // set_next and we safepointed to free up space. This is a benign
195 // race because the IC entry was complete when we safepointed so 205 // race because the IC entry was complete when we safepointed so
196 // cleaning it immediately is harmless. 206 // cleaning it immediately is harmless.
197 // assert(is_megamorphic(), "sanity check"); 207 // assert(is_megamorphic(), "sanity check");
208 return true;
198 } 209 }
199 210
200 211
201 // true if destination is megamorphic stub 212 // true if destination is megamorphic stub
202 bool CompiledIC::is_megamorphic() const { 213 bool CompiledIC::is_megamorphic() const {