annotate src/share/vm/oops/compiledICHolder.hpp @ 9057:b44df6c5942c

Added tag jdk8u232-ga for changeset 12177d88b89c
author andrew
date Tue, 15 Oct 2019 21:37:52 +0100
parents f8a45a60bc6b
children
rev   line source
duke@0 1 /*
poonam@8631 2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
stefank@1879 26 #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
stefank@1879 27
stefank@1879 28 #include "oops/oop.hpp"
poonam@8631 29 #include "oops/klass.hpp"
poonam@8631 30 #include "oops/method.hpp"
stefank@1879 31
coleenp@3602 32 // A CompiledICHolder* is a helper object for the inline cache implementation.
dbuck@8504 33 // It holds:
dbuck@8504 34 // (1) (method+klass pair) when converting from compiled to an interpreted call
dbuck@8504 35 // (2) (klass+klass pair) when calling itable stub from megamorphic compiled call
duke@0 36 //
coleenp@3602 37 // These are always allocated in the C heap and are freed during a
coleenp@3602 38 // safepoint by the ICBuffer logic. It's unsafe to free them earlier
coleenp@3602 39 // since they might be in use.
coleenp@3602 40 //
duke@0 41
duke@0 42
coleenp@3602 43 class CompiledICHolder : public CHeapObj<mtCompiler> {
duke@0 44 friend class VMStructs;
duke@0 45 private:
coleenp@3602 46 static volatile int _live_count; // allocated
coleenp@3602 47 static volatile int _live_not_claimed_count; // allocated but not yet in use so not
coleenp@3602 48 // reachable by iterating over nmethods
coleenp@3602 49
dbuck@8504 50 Metadata* _holder_metadata;
coleenp@3602 51 Klass* _holder_klass; // to avoid name conflict with oopDesc::_klass
coleenp@3602 52 CompiledICHolder* _next;
poonam@8631 53 bool _is_metadata_method;
coleenp@3602 54
duke@0 55 public:
coleenp@3602 56 // Constructor
poonam@8631 57 CompiledICHolder(Metadata* metadata, Klass* klass, bool is_method = true)
poonam@8631 58 : _holder_metadata(metadata), _holder_klass(klass), _is_metadata_method(is_method) {
coleenp@3602 59 #ifdef ASSERT
coleenp@3602 60 Atomic::inc(&_live_count);
coleenp@3602 61 Atomic::inc(&_live_not_claimed_count);
coleenp@3602 62 #endif
coleenp@3602 63 }
coleenp@3602 64
coleenp@3602 65 ~CompiledICHolder() {
coleenp@3602 66 #ifdef ASSERT
coleenp@3602 67 assert(_live_count > 0, "underflow");
coleenp@3602 68 Atomic::dec(&_live_count);
coleenp@3602 69 #endif
coleenp@3602 70 }
coleenp@3602 71
coleenp@3602 72 static int live_count() { return _live_count; }
coleenp@3602 73 static int live_not_claimed_count() { return _live_not_claimed_count; }
coleenp@3602 74
duke@0 75 // accessors
coleenp@3602 76 Klass* holder_klass() const { return _holder_klass; }
dbuck@8504 77 Metadata* holder_metadata() const { return _holder_metadata; }
duke@0 78
dbuck@8504 79 void set_holder_metadata(Metadata* m) { _holder_metadata = m; }
dbuck@8504 80 void set_holder_klass(Klass* k) { _holder_klass = k; }
duke@0 81
dbuck@8504 82 static int holder_metadata_offset() { return offset_of(CompiledICHolder, _holder_metadata); }
coleenp@3602 83 static int holder_klass_offset() { return offset_of(CompiledICHolder, _holder_klass); }
duke@0 84
coleenp@3602 85 CompiledICHolder* next() { return _next; }
coleenp@3602 86 void set_next(CompiledICHolder* n) { _next = n; }
coleenp@3602 87
poonam@8631 88 inline bool is_loader_alive(BoolObjectClosure* is_alive) {
poonam@8631 89 Klass* k = _is_metadata_method ? ((Method*)_holder_metadata)->method_holder() : (Klass*)_holder_metadata;
poonam@8631 90 if (!k->is_loader_alive(is_alive)) {
poonam@8631 91 return false;
poonam@8631 92 }
poonam@8631 93 if (!_holder_klass->is_loader_alive(is_alive)) {
poonam@8631 94 return false;
poonam@8631 95 }
poonam@8631 96 return true;
poonam@8631 97 }
dbuck@8504 98
coleenp@3602 99 // Verify
coleenp@3602 100 void verify_on(outputStream* st);
coleenp@3602 101
coleenp@3602 102 // Printing
coleenp@3602 103 void print_on(outputStream* st) const;
coleenp@3602 104 void print_value_on(outputStream* st) const;
coleenp@3602 105
coleenp@3602 106 const char* internal_name() const { return "{compiledICHolder}"; }
coleenp@3602 107
coleenp@3602 108 void claim() {
coleenp@3602 109 #ifdef ASSERT
coleenp@3602 110 Atomic::dec(&_live_not_claimed_count);
coleenp@3602 111 #endif
coleenp@3602 112 }
duke@0 113 };
stefank@1879 114
stefank@1879 115 #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP