Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/oops/compiledICHolder.hpp
32285 views
/*1* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP25#define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP2627#include "oops/oop.hpp"28#include "oops/klass.hpp"29#include "oops/method.hpp"3031// A CompiledICHolder* is a helper object for the inline cache implementation.32// It holds:33// (1) (method+klass pair) when converting from compiled to an interpreted call34// (2) (klass+klass pair) when calling itable stub from megamorphic compiled call35//36// These are always allocated in the C heap and are freed during a37// safepoint by the ICBuffer logic. It's unsafe to free them earlier38// since they might be in use.39//404142class CompiledICHolder : public CHeapObj<mtCompiler> {43friend class VMStructs;44private:45static volatile int _live_count; // allocated46static volatile int _live_not_claimed_count; // allocated but not yet in use so not47// reachable by iterating over nmethods4849Metadata* _holder_metadata;50Klass* _holder_klass; // to avoid name conflict with oopDesc::_klass51CompiledICHolder* _next;52bool _is_metadata_method;5354public:55// Constructor56CompiledICHolder(Metadata* metadata, Klass* klass, bool is_method = true)57: _holder_metadata(metadata), _holder_klass(klass), _is_metadata_method(is_method) {58#ifdef ASSERT59Atomic::inc(&_live_count);60Atomic::inc(&_live_not_claimed_count);61#endif62}6364~CompiledICHolder() {65#ifdef ASSERT66assert(_live_count > 0, "underflow");67Atomic::dec(&_live_count);68#endif69}7071static int live_count() { return _live_count; }72static int live_not_claimed_count() { return _live_not_claimed_count; }7374// accessors75Klass* holder_klass() const { return _holder_klass; }76Metadata* holder_metadata() const { return _holder_metadata; }7778void set_holder_metadata(Metadata* m) { _holder_metadata = m; }79void set_holder_klass(Klass* k) { _holder_klass = k; }8081static int holder_metadata_offset() { return offset_of(CompiledICHolder, _holder_metadata); }82static int holder_klass_offset() { return offset_of(CompiledICHolder, _holder_klass); }8384CompiledICHolder* next() { return _next; }85void set_next(CompiledICHolder* n) { _next = n; }8687inline bool is_loader_alive(BoolObjectClosure* is_alive) {88Klass* k = _is_metadata_method ? ((Method*)_holder_metadata)->method_holder() : (Klass*)_holder_metadata;89if (!k->is_loader_alive(is_alive)) {90return false;91}92if (!_holder_klass->is_loader_alive(is_alive)) {93return false;94}95return true;96}9798// Verify99void verify_on(outputStream* st);100101// Printing102void print_on(outputStream* st) const;103void print_value_on(outputStream* st) const;104105const char* internal_name() const { return "{compiledICHolder}"; }106107void claim() {108#ifdef ASSERT109Atomic::dec(&_live_not_claimed_count);110#endif111}112};113114#endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP115116117