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 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "classfile/systemDictionary.hpp" 27 #include "code/codeCache.hpp" 28 #include "code/compiledIC.hpp" 29 #include "code/icBuffer.hpp" 30 #include "code/nmethod.hpp" 31 #include "code/vtableStubs.hpp" 32 #include "interpreter/interpreter.hpp" 33 #include "interpreter/linkResolver.hpp" 34 #include "memory/metadataFactory.hpp" 35 #include "memory/oopFactory.hpp" 36 #include "oops/method.hpp" 37 #include "oops/oop.inline.hpp" 38 #include "oops/symbol.hpp" 39 #include "runtime/icache.hpp" 40 #include "runtime/sharedRuntime.hpp" 41 #include "runtime/stubRoutines.hpp" 42 #include "utilities/events.hpp" 43 44 45 // Release the CompiledICHolder* associated with this call site is there is one. 46 void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { 47 // This call site might have become stale so inspect it carefully. 48 NativeCall* call = nativeCall_at(call_site->addr()); 49 if (is_icholder_entry(call->destination())) { 50 NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); 51 InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); 52 } 53 } 54 55 bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { 56 // This call site might have become stale so inspect it carefully. 57 NativeCall* call = nativeCall_at(call_site->addr()); 58 return is_icholder_entry(call->destination()); 59 } 60 61 //----------------------------------------------------------------------------- 62 // High-level access to an inline cache. Guaranteed to be MT-safe. 63 64 CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) 65 : _ic_call(call) 66 { 67 address ic_call = call->instruction_address(); 68 69 assert(ic_call != NULL, "ic_call address must be set"); 70 assert(nm != NULL, "must pass nmethod"); 71 assert(nm->contains(ic_call), "must be in nmethod"); 72 73 // Search for the ic_call at the given address. 74 RelocIterator iter(nm, ic_call, ic_call+1); 75 bool ret = iter.next(); 76 assert(ret == true, "relocInfo must exist at this address"); 77 assert(iter.addr() == ic_call, "must find ic_call"); 78 if (iter.type() == relocInfo::virtual_call_type) { 79 virtual_call_Relocation* r = iter.virtual_call_reloc(); 80 _is_optimized = false; 81 _value = nativeMovConstReg_at(r->cached_value()); 82 } else { 83 assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); 84 _is_optimized = true; 85 _value = NULL; 86 } 87 } 88 89 // ---------------------------------------------------------------------------- 90 91 void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { 92 ShouldNotReachHere(); // Only needed for COMPILER2. 93 } 94 95 uint CompiledStaticCall::to_interp_stub_size() { 96 ShouldNotReachHere(); // Only needed for COMPILER2. 97 return 0; 98 } 99 100 // Relocation entries for call stub, compiled java to interpreter. 101 uint CompiledStaticCall::reloc_to_interp_stub() { 102 ShouldNotReachHere(); // Only needed for COMPILER2. 103 return 0; 104 } 105 106 void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) { 107 ShouldNotReachHere(); // Only needed for COMPILER2. 108 } 109 110 void CompiledStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) { 111 ShouldNotReachHere(); // Only needed for COMPILER2. 112 } 113 114 //----------------------------------------------------------------------------- 115 // Non-product mode code. 116 #ifndef PRODUCT 117 118 void CompiledStaticCall::verify() { 119 ShouldNotReachHere(); // Only needed for COMPILER2. 120 } 121 122 #endif // !PRODUCT