src/share/vm/code/compiledIC.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8014013 Sdiff src/share/vm/code

src/share/vm/code/compiledIC.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 144 
 145 
 146 bool CompiledIC::is_icholder_call() const {
 147   assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 148   return !_is_optimized && is_icholder_entry(ic_destination());
 149 }
 150 
 151 // Returns native address of 'call' instruction in inline-cache. Used by
 152 // the InlineCacheBuffer when it needs to find the stub.
 153 address CompiledIC::stub_address() const {
 154   assert(is_in_transition_state(), "should only be called when we are in a transition state");
 155   return _ic_call->destination();
 156 }
 157 
 158 
 159 //-----------------------------------------------------------------------------
 160 // High-level access to an inline cache. Guaranteed to be MT-safe.
 161 
 162 
 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(), "");
 167   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?");
 169 
 170   address entry;
 171   if (is_invoke_interface) {
 172     int index = klassItable::compute_itable_index(call_info->resolved_method()());
 173     entry = VtableStubs::create_stub(false, index, method());


 174     assert(entry != NULL, "entry not computed");



 175     InstanceKlass* k = call_info->resolved_method()->method_holder();
 176     assert(k->is_interface(), "sanity check");
 177     InlineCacheBuffer::create_transition_stub(this, k, entry);
 178   } else {
 179     // Can be different than method->vtable_index(), due to package-private etc.

 180     int vtable_index = call_info->vtable_index();
 181     entry = VtableStubs::create_stub(true, vtable_index, method());
 182     InlineCacheBuffer::create_transition_stub(this, method(), entry);

 183   }
 184 
 185   if (TraceICs) {
 186     ResourceMark rm;
 187     tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT,
 188                    instruction_address(), method->print_value_string(), entry);
 189   }
 190 
 191   // 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
 193   // 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
 195   // race because the IC entry was complete when we safepointed so
 196   // cleaning it immediately is harmless.
 197   // assert(is_megamorphic(), "sanity check");
 198 }
 199 
 200 
 201 // true if destination is megamorphic stub
 202 bool CompiledIC::is_megamorphic() const {
 203   assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 204   assert(!is_optimized(), "an optimized call cannot be megamorphic");
 205 
 206   // Cannot rely on cached_value. It is either an interface or a method.
 207   return VtableStubs::is_entry_point(ic_destination());
 208 }


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 144 
 145 
 146 bool CompiledIC::is_icholder_call() const {
 147   assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 148   return !_is_optimized && is_icholder_entry(ic_destination());
 149 }
 150 
 151 // Returns native address of 'call' instruction in inline-cache. Used by
 152 // the InlineCacheBuffer when it needs to find the stub.
 153 address CompiledIC::stub_address() const {
 154   assert(is_in_transition_state(), "should only be called when we are in a transition state");
 155   return _ic_call->destination();
 156 }
 157 
 158 
 159 //-----------------------------------------------------------------------------
 160 // High-level access to an inline cache. Guaranteed to be MT-safe.
 161 
 162 
 163 void CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) {


 164   assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 165   assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic");
 166   assert(is_call_to_compiled() || is_call_to_interpreted(), "going directly to megamorphic?");
 167 
 168   address entry;
 169   if (call_info->call_kind() == CallInfo::itable_call) {
 170     assert(bytecode == Bytecodes::_invokeinterface, "");
 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");
 175     int index = call_info->resolved_method()->itable_index();
 176     assert(index == itable_index, "CallInfo pre-computes this");
 177 #endif //ASSERT
 178     InstanceKlass* k = call_info->resolved_method()->method_holder();
 179     assert(k->verify_itable_index(itable_index), "sanity check");
 180     InlineCacheBuffer::create_transition_stub(this, k, entry);
 181   } else {
 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.
 184     int vtable_index = call_info->vtable_index();
 185     assert(call_info->resolved_klass()->verify_vtable_index(vtable_index), "sanity check");
 186     entry = VtableStubs::find_vtable_stub(vtable_index);
 187     InlineCacheBuffer::create_transition_stub(this, NULL, entry);
 188   }
 189 
 190   if (TraceICs) {
 191     ResourceMark rm;
 192     tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT,
 193                    instruction_address(), call_info->selected_method()->print_value_string(), entry);
 194   }
 195 
 196   // We can't check this anymore. With lazy deopt we could have already
 197   // cleaned this IC entry before we even return. This is possible if
 198   // we ran out of space in the inline cache buffer trying to do the
 199   // set_next and we safepointed to free up space. This is a benign
 200   // race because the IC entry was complete when we safepointed so
 201   // cleaning it immediately is harmless.
 202   // assert(is_megamorphic(), "sanity check");
 203 }
 204 
 205 
 206 // true if destination is megamorphic stub
 207 bool CompiledIC::is_megamorphic() const {
 208   assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 209   assert(!is_optimized(), "an optimized call cannot be megamorphic");
 210 
 211   // Cannot rely on cached_value. It is either an interface or a method.
 212   return VtableStubs::is_entry_point(ic_destination());
 213 }


src/share/vm/code/compiledIC.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File