Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/ci/ciInstanceKlass.hpp
32285 views
/*1* Copyright (c) 1999, 2016, 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_CI_CIINSTANCEKLASS_HPP25#define SHARE_VM_CI_CIINSTANCEKLASS_HPP2627#include "ci/ciConstantPoolCache.hpp"28#include "ci/ciFlags.hpp"29#include "ci/ciKlass.hpp"30#include "ci/ciSymbol.hpp"3132// ciInstanceKlass33//34// This class represents a Klass* in the HotSpot virtual machine35// whose Klass part is an InstanceKlass. It may or may not36// be loaded.37class ciInstanceKlass : public ciKlass {38CI_PACKAGE_ACCESS39friend class ciBytecodeStream;40friend class ciEnv;41friend class ciExceptionHandler;42friend class ciMethod;43friend class ciField;4445private:46jobject _loader;47jobject _protection_domain;4849InstanceKlass::ClassState _init_state; // state of class50bool _is_shared;51bool _has_finalizer;52bool _has_subklass;53bool _has_nonstatic_fields;54bool _has_default_methods;55bool _is_anonymous;5657ciFlags _flags;58jint _nonstatic_field_size;59jint _nonstatic_oop_map_size;6061// Lazy fields get filled in only upon request.62ciInstanceKlass* _super;63ciInstance* _java_mirror;6465ciConstantPoolCache* _field_cache; // cached map index->field66GrowableArray<ciField*>* _nonstatic_fields;6768// The possible values of the _implementor fall into following three cases:69// NULL: no implementor.70// A ciInstanceKlass that's not itself: one implementor.71// Itsef: more than one implementors.72ciInstanceKlass* _implementor;7374GrowableArray<ciField*>* _non_static_fields;7576protected:77ciInstanceKlass(KlassHandle h_k);78ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);7980InstanceKlass* get_instanceKlass() const {81return (InstanceKlass*)get_Klass();82}8384oop loader();85jobject loader_handle();8687oop protection_domain();88jobject protection_domain_handle();8990const char* type_string() { return "ciInstanceKlass"; }9192bool is_in_package_impl(const char* packagename, int len);9394void print_impl(outputStream* st);9596ciConstantPoolCache* field_cache();9798bool is_shared() { return _is_shared; }99100void compute_shared_init_state();101bool compute_shared_has_subklass();102int compute_nonstatic_fields();103GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);104105// Update the init_state for shared klasses106void update_if_shared(InstanceKlass::ClassState expected) {107if (_is_shared && _init_state != expected) {108if (is_loaded()) compute_shared_init_state();109}110}111112public:113// Has this klass been initialized?114bool is_initialized() {115update_if_shared(InstanceKlass::fully_initialized);116return _init_state == InstanceKlass::fully_initialized;117}118// Is this klass being initialized?119bool is_being_initialized() {120update_if_shared(InstanceKlass::being_initialized);121return _init_state == InstanceKlass::being_initialized;122}123// Has this klass been linked?124bool is_linked() {125update_if_shared(InstanceKlass::linked);126return _init_state >= InstanceKlass::linked;127}128129// General klass information.130ciFlags flags() {131assert(is_loaded(), "must be loaded");132return _flags;133}134bool has_finalizer() {135assert(is_loaded(), "must be loaded");136return _has_finalizer; }137bool has_subklass() {138assert(is_loaded(), "must be loaded");139if (_is_shared && !_has_subklass) {140if (flags().is_final()) {141return false;142} else {143return compute_shared_has_subklass();144}145}146return _has_subklass;147}148jint size_helper() {149return (Klass::layout_helper_size_in_bytes(layout_helper())150>> LogHeapWordSize);151}152jint nonstatic_field_size() {153assert(is_loaded(), "must be loaded");154return _nonstatic_field_size; }155jint has_nonstatic_fields() {156assert(is_loaded(), "must be loaded");157return _has_nonstatic_fields; }158jint nonstatic_oop_map_size() {159assert(is_loaded(), "must be loaded");160return _nonstatic_oop_map_size; }161ciInstanceKlass* super();162jint nof_implementors() {163ciInstanceKlass* impl;164assert(is_loaded(), "must be loaded");165impl = implementor();166if (impl == NULL) {167return 0;168} else if (impl != this) {169return 1;170} else {171return 2;172}173}174175bool has_default_methods() {176assert(is_loaded(), "must be loaded");177return _has_default_methods;178}179180bool is_anonymous() {181return _is_anonymous;182}183184ciInstanceKlass* get_canonical_holder(int offset);185ciField* get_field_by_offset(int field_offset, bool is_static);186ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);187188GrowableArray<ciField*>* non_static_fields();189190// total number of nonstatic fields (including inherited):191int nof_nonstatic_fields() {192if (_nonstatic_fields == NULL)193return compute_nonstatic_fields();194else195return _nonstatic_fields->length();196}197// nth nonstatic field (presented by ascending address)198ciField* nonstatic_field_at(int i) {199assert(_nonstatic_fields != NULL, "");200return _nonstatic_fields->at(i);201}202203ciInstanceKlass* unique_concrete_subklass();204bool has_finalizable_subclass();205206bool contains_field_offset(int offset) {207return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());208}209210// Get the instance of java.lang.Class corresponding to211// this klass. This instance is used for locking of212// synchronized static methods of this klass.213ciInstance* java_mirror();214215// Java access flags216bool is_public () { return flags().is_public(); }217bool is_final () { return flags().is_final(); }218bool is_super () { return flags().is_super(); }219bool is_interface () { return flags().is_interface(); }220bool is_abstract () { return flags().is_abstract(); }221222ciMethod* find_method(ciSymbol* name, ciSymbol* signature);223// Note: To find a method from name and type strings, use ciSymbol::make,224// but consider adding to vmSymbols.hpp instead.225226bool is_leaf_type();227ciInstanceKlass* implementor();228229// Is the defining class loader of this class the default loader?230bool uses_default_loader() const;231232bool is_java_lang_Object() const;233234BasicType box_klass_type() const;235bool is_box_klass() const;236bool is_boxed_value_offset(int offset) const;237238// Is this klass in the given package?239bool is_in_package(const char* packagename) {240return is_in_package(packagename, (int) strlen(packagename));241}242bool is_in_package(const char* packagename, int len);243244// What kind of ciObject is this?245bool is_instance_klass() const { return true; }246bool is_java_klass() const { return true; }247248virtual ciKlass* exact_klass() {249if (is_loaded() && is_final() && !is_interface()) {250return this;251}252return NULL;253}254255ciInstanceKlass* host_klass();256257// Dump the current state of this klass for compilation replay.258virtual void dump_replay_data(outputStream* out);259};260261#endif // SHARE_VM_CI_CIINSTANCEKLASS_HPP262263264