0N/A/*
3669N/A * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_CI_CIINSTANCEKLASS_HPP
1879N/A#define SHARE_VM_CI_CIINSTANCEKLASS_HPP
1879N/A
1879N/A#include "ci/ciConstantPoolCache.hpp"
1879N/A#include "ci/ciFlags.hpp"
1879N/A#include "ci/ciInstanceKlassKlass.hpp"
1879N/A#include "ci/ciKlass.hpp"
1879N/A#include "ci/ciSymbol.hpp"
1879N/A
0N/A// ciInstanceKlass
0N/A//
0N/A// This class represents a klassOop in the HotSpot virtual machine
0N/A// whose Klass part is an instanceKlass. It may or may not
0N/A// be loaded.
0N/Aclass ciInstanceKlass : public ciKlass {
0N/A CI_PACKAGE_ACCESS
1138N/A friend class ciBytecodeStream;
0N/A friend class ciEnv;
1138N/A friend class ciExceptionHandler;
0N/A friend class ciMethod;
0N/A friend class ciField;
0N/A
0N/Aprivate:
0N/A jobject _loader;
0N/A jobject _protection_domain;
0N/A
1565N/A instanceKlass::ClassState _init_state; // state of class
113N/A bool _is_shared;
0N/A bool _has_finalizer;
0N/A bool _has_subklass;
113N/A bool _has_nonstatic_fields;
113N/A
0N/A ciFlags _flags;
0N/A jint _nonstatic_field_size;
44N/A jint _nonstatic_oop_map_size;
0N/A
0N/A // Lazy fields get filled in only upon request.
0N/A ciInstanceKlass* _super;
0N/A ciInstance* _java_mirror;
0N/A
0N/A ciConstantPoolCache* _field_cache; // cached map index->field
0N/A GrowableArray<ciField*>* _nonstatic_fields;
0N/A
3669N/A // The possible values of the _implementor fall into following three cases:
3669N/A // NULL: no implementor.
3669N/A // A ciInstanceKlass that's not itself: one implementor.
3669N/A // Itsef: more than one implementors.
3669N/A ciInstanceKlass* _implementor;
0N/A
44N/A GrowableArray<ciField*>* _non_static_fields;
44N/A
0N/Aprotected:
0N/A ciInstanceKlass(KlassHandle h_k);
0N/A ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
0N/A
0N/A instanceKlass* get_instanceKlass() const {
0N/A return (instanceKlass*)get_Klass();
0N/A }
0N/A
0N/A oop loader();
0N/A jobject loader_handle();
0N/A
0N/A oop protection_domain();
0N/A jobject protection_domain_handle();
0N/A
0N/A const char* type_string() { return "ciInstanceKlass"; }
0N/A
1138N/A bool is_in_package_impl(const char* packagename, int len);
1138N/A
0N/A void print_impl(outputStream* st);
0N/A
0N/A ciConstantPoolCache* field_cache();
0N/A
0N/A bool is_shared() { return _is_shared; }
0N/A
1565N/A void compute_shared_init_state();
0N/A bool compute_shared_has_subklass();
0N/A int compute_nonstatic_fields();
0N/A GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
0N/A
1565N/A // Update the init_state for shared klasses
1565N/A void update_if_shared(instanceKlass::ClassState expected) {
1565N/A if (_is_shared && _init_state != expected) {
1565N/A if (is_loaded()) compute_shared_init_state();
1565N/A }
1565N/A }
1565N/A
0N/Apublic:
0N/A // Has this klass been initialized?
0N/A bool is_initialized() {
1565N/A update_if_shared(instanceKlass::fully_initialized);
1565N/A return _init_state == instanceKlass::fully_initialized;
1565N/A }
1565N/A // Is this klass being initialized?
1565N/A bool is_being_initialized() {
1565N/A update_if_shared(instanceKlass::being_initialized);
1565N/A return _init_state == instanceKlass::being_initialized;
0N/A }
0N/A // Has this klass been linked?
0N/A bool is_linked() {
1565N/A update_if_shared(instanceKlass::linked);
1565N/A return _init_state >= instanceKlass::linked;
0N/A }
0N/A
0N/A // General klass information.
0N/A ciFlags flags() {
0N/A assert(is_loaded(), "must be loaded");
0N/A return _flags;
0N/A }
0N/A bool has_finalizer() {
0N/A assert(is_loaded(), "must be loaded");
0N/A return _has_finalizer; }
0N/A bool has_subklass() {
0N/A assert(is_loaded(), "must be loaded");
0N/A if (_is_shared && !_has_subklass) {
0N/A if (flags().is_final()) {
0N/A return false;
0N/A } else {
0N/A return compute_shared_has_subklass();
0N/A }
0N/A }
0N/A return _has_subklass;
0N/A }
0N/A jint size_helper() {
0N/A return (Klass::layout_helper_size_in_bytes(layout_helper())
0N/A >> LogHeapWordSize);
0N/A }
0N/A jint nonstatic_field_size() {
0N/A assert(is_loaded(), "must be loaded");
0N/A return _nonstatic_field_size; }
113N/A jint has_nonstatic_fields() {
113N/A assert(is_loaded(), "must be loaded");
113N/A return _has_nonstatic_fields; }
44N/A jint nonstatic_oop_map_size() {
44N/A assert(is_loaded(), "must be loaded");
44N/A return _nonstatic_oop_map_size; }
0N/A ciInstanceKlass* super();
3669N/A jint nof_implementors() {
3669N/A ciInstanceKlass* impl;
0N/A assert(is_loaded(), "must be loaded");
3669N/A impl = implementor();
3669N/A if (impl == NULL) {
3669N/A return 0;
3669N/A } else if (impl != this) {
3669N/A return 1;
3669N/A } else {
3669N/A return 2;
3669N/A }
0N/A }
0N/A
0N/A ciInstanceKlass* get_canonical_holder(int offset);
0N/A ciField* get_field_by_offset(int field_offset, bool is_static);
1080N/A ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
44N/A
44N/A GrowableArray<ciField*>* non_static_fields();
44N/A
0N/A // total number of nonstatic fields (including inherited):
0N/A int nof_nonstatic_fields() {
0N/A if (_nonstatic_fields == NULL)
0N/A return compute_nonstatic_fields();
0N/A else
0N/A return _nonstatic_fields->length();
0N/A }
0N/A // nth nonstatic field (presented by ascending address)
0N/A ciField* nonstatic_field_at(int i) {
0N/A assert(_nonstatic_fields != NULL, "");
0N/A return _nonstatic_fields->at(i);
0N/A }
0N/A
0N/A ciInstanceKlass* unique_concrete_subklass();
0N/A bool has_finalizable_subclass();
0N/A
0N/A bool contains_field_offset(int offset) {
113N/A return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
0N/A }
0N/A
0N/A // Get the instance of java.lang.Class corresponding to
0N/A // this klass. This instance is used for locking of
0N/A // synchronized static methods of this klass.
0N/A ciInstance* java_mirror();
0N/A
0N/A // Java access flags
0N/A bool is_public () { return flags().is_public(); }
0N/A bool is_final () { return flags().is_final(); }
0N/A bool is_super () { return flags().is_super(); }
0N/A bool is_interface () { return flags().is_interface(); }
0N/A bool is_abstract () { return flags().is_abstract(); }
0N/A
0N/A ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
0N/A // Note: To find a method from name and type strings, use ciSymbol::make,
0N/A // but consider adding to vmSymbols.hpp instead.
0N/A
0N/A bool is_leaf_type();
3669N/A ciInstanceKlass* implementor();
0N/A
0N/A // Is the defining class loader of this class the default loader?
0N/A bool uses_default_loader();
0N/A
0N/A bool is_java_lang_Object();
0N/A
1138N/A // Is this klass in the given package?
1138N/A bool is_in_package(const char* packagename) {
1138N/A return is_in_package(packagename, (int) strlen(packagename));
1138N/A }
1138N/A bool is_in_package(const char* packagename, int len);
1138N/A
0N/A // What kind of ciObject is this?
0N/A bool is_instance_klass() { return true; }
0N/A bool is_java_klass() { return true; }
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_CI_CIINSTANCEKLASS_HPP