Path: blob/master/src/hotspot/share/oops/klass.inline.hpp
40951 views
/*1* Copyright (c) 2005, 2021, 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_OOPS_KLASS_INLINE_HPP25#define SHARE_OOPS_KLASS_INLINE_HPP2627#include "oops/klass.hpp"2829#include "classfile/classLoaderData.inline.hpp"30#include "oops/klassVtable.hpp"31#include "oops/markWord.hpp"3233// This loads the klass's holder as a phantom. This is useful when a weak Klass34// pointer has been "peeked" and then must be kept alive before it may35// be used safely. All uses of klass_holder need to apply the appropriate barriers,36// except during GC.37inline oop Klass::klass_holder() const {38return class_loader_data()->holder_phantom();39}4041inline bool Klass::is_non_strong_hidden() const {42return access_flags().is_hidden_class() &&43class_loader_data()->has_class_mirror_holder();44}4546// Iff the class loader (or mirror for non-strong hidden classes) is alive the47// Klass is considered alive. This is safe to call before the CLD is marked as48// unloading, and hence during concurrent class unloading.49inline bool Klass::is_loader_alive() const {50return class_loader_data()->is_alive();51}5253inline void Klass::set_prototype_header(markWord header) {54assert(!header.has_bias_pattern() || is_instance_klass(), "biased locking currently only supported for Java instances");55_prototype_header = header;56}5758inline oop Klass::java_mirror() const {59return _java_mirror.resolve();60}6162inline klassVtable Klass::vtable() const {63return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());64}6566inline oop Klass::class_loader() const {67return class_loader_data()->class_loader();68}6970inline vtableEntry* Klass::start_of_vtable() const {71return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset()));72}7374inline ByteSize Klass::vtable_start_offset() {75return in_ByteSize(InstanceKlass::header_size() * wordSize);76}7778#endif // SHARE_OOPS_KLASS_INLINE_HPP798081