1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/oops/compiledICHolder.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,101 @@ 1.4 +/* 1.5 + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP 1.29 +#define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP 1.30 + 1.31 +#include "oops/oop.hpp" 1.32 + 1.33 +// A CompiledICHolder* is a helper object for the inline cache implementation. 1.34 +// It holds an intermediate value (method+klass pair) used when converting from 1.35 +// compiled to an interpreted call. 1.36 +// 1.37 +// These are always allocated in the C heap and are freed during a 1.38 +// safepoint by the ICBuffer logic. It's unsafe to free them earlier 1.39 +// since they might be in use. 1.40 +// 1.41 + 1.42 + 1.43 +class CompiledICHolder : public CHeapObj<mtCompiler> { 1.44 + friend class VMStructs; 1.45 + private: 1.46 + static volatile int _live_count; // allocated 1.47 + static volatile int _live_not_claimed_count; // allocated but not yet in use so not 1.48 + // reachable by iterating over nmethods 1.49 + 1.50 + Method* _holder_method; 1.51 + Klass* _holder_klass; // to avoid name conflict with oopDesc::_klass 1.52 + CompiledICHolder* _next; 1.53 + 1.54 + public: 1.55 + // Constructor 1.56 + CompiledICHolder(Method* method, Klass* klass) 1.57 + : _holder_method(method), _holder_klass(klass) { 1.58 +#ifdef ASSERT 1.59 + Atomic::inc(&_live_count); 1.60 + Atomic::inc(&_live_not_claimed_count); 1.61 +#endif 1.62 + } 1.63 + 1.64 + ~CompiledICHolder() { 1.65 +#ifdef ASSERT 1.66 + assert(_live_count > 0, "underflow"); 1.67 + Atomic::dec(&_live_count); 1.68 +#endif 1.69 + } 1.70 + 1.71 + static int live_count() { return _live_count; } 1.72 + static int live_not_claimed_count() { return _live_not_claimed_count; } 1.73 + 1.74 + // accessors 1.75 + Method* holder_method() const { return _holder_method; } 1.76 + Klass* holder_klass() const { return _holder_klass; } 1.77 + 1.78 + void set_holder_method(Method* m) { _holder_method = m; } 1.79 + void set_holder_klass(Klass* k) { _holder_klass = k; } 1.80 + 1.81 + // interpreter support (offsets in bytes) 1.82 + static int holder_method_offset() { return offset_of(CompiledICHolder, _holder_method); } 1.83 + static int holder_klass_offset() { return offset_of(CompiledICHolder, _holder_klass); } 1.84 + 1.85 + CompiledICHolder* next() { return _next; } 1.86 + void set_next(CompiledICHolder* n) { _next = n; } 1.87 + 1.88 + // Verify 1.89 + void verify_on(outputStream* st); 1.90 + 1.91 + // Printing 1.92 + void print_on(outputStream* st) const; 1.93 + void print_value_on(outputStream* st) const; 1.94 + 1.95 + const char* internal_name() const { return "{compiledICHolder}"; } 1.96 + 1.97 + void claim() { 1.98 +#ifdef ASSERT 1.99 + Atomic::dec(&_live_not_claimed_count); 1.100 +#endif 1.101 + } 1.102 +}; 1.103 + 1.104 +#endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP