duke@435: /* coleenp@4037: * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP stefank@2314: #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP stefank@2314: stefank@2314: #include "oops/oop.hpp" stefank@2314: coleenp@4037: // A CompiledICHolder* is a helper object for the inline cache implementation. duke@435: // It holds an intermediate value (method+klass pair) used when converting from duke@435: // compiled to an interpreted call. duke@435: // coleenp@4037: // These are always allocated in the C heap and are freed during a coleenp@4037: // safepoint by the ICBuffer logic. It's unsafe to free them earlier coleenp@4037: // since they might be in use. coleenp@4037: // duke@435: duke@435: coleenp@4037: class CompiledICHolder : public CHeapObj { duke@435: friend class VMStructs; duke@435: private: coleenp@4037: static volatile int _live_count; // allocated coleenp@4037: static volatile int _live_not_claimed_count; // allocated but not yet in use so not coleenp@4037: // reachable by iterating over nmethods coleenp@4037: coleenp@4037: Method* _holder_method; coleenp@4037: Klass* _holder_klass; // to avoid name conflict with oopDesc::_klass coleenp@4037: CompiledICHolder* _next; coleenp@4037: duke@435: public: coleenp@4037: // Constructor coleenp@4037: CompiledICHolder(Method* method, Klass* klass) coleenp@4037: : _holder_method(method), _holder_klass(klass) { coleenp@4037: #ifdef ASSERT coleenp@4037: Atomic::inc(&_live_count); coleenp@4037: Atomic::inc(&_live_not_claimed_count); coleenp@4037: #endif coleenp@4037: } coleenp@4037: coleenp@4037: ~CompiledICHolder() { coleenp@4037: #ifdef ASSERT coleenp@4037: assert(_live_count > 0, "underflow"); coleenp@4037: Atomic::dec(&_live_count); coleenp@4037: #endif coleenp@4037: } coleenp@4037: coleenp@4037: static int live_count() { return _live_count; } coleenp@4037: static int live_not_claimed_count() { return _live_not_claimed_count; } coleenp@4037: duke@435: // accessors coleenp@4037: Method* holder_method() const { return _holder_method; } coleenp@4037: Klass* holder_klass() const { return _holder_klass; } duke@435: coleenp@4037: void set_holder_method(Method* m) { _holder_method = m; } coleenp@4037: void set_holder_klass(Klass* k) { _holder_klass = k; } duke@435: duke@435: // interpreter support (offsets in bytes) coleenp@4037: static int holder_method_offset() { return offset_of(CompiledICHolder, _holder_method); } coleenp@4037: static int holder_klass_offset() { return offset_of(CompiledICHolder, _holder_klass); } duke@435: coleenp@4037: CompiledICHolder* next() { return _next; } coleenp@4037: void set_next(CompiledICHolder* n) { _next = n; } coleenp@4037: coleenp@4037: // Verify coleenp@4037: void verify_on(outputStream* st); coleenp@4037: coleenp@4037: // Printing coleenp@4037: void print_on(outputStream* st) const; coleenp@4037: void print_value_on(outputStream* st) const; coleenp@4037: coleenp@4037: const char* internal_name() const { return "{compiledICHolder}"; } coleenp@4037: coleenp@4037: void claim() { coleenp@4037: #ifdef ASSERT coleenp@4037: Atomic::dec(&_live_not_claimed_count); coleenp@4037: #endif coleenp@4037: } duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP