ciInstanceKlass.hpp revision 0
0N/A/*
2362N/A * Copyright 1999-2007 Sun Microsystems, Inc. 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
2362N/A * published by the Free Software Foundation.
0N/A *
2362N/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 *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
2362N/A * have any questions.
2362N/A *
2362N/A */
0N/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
0N/A friend class ciEnv;
0N/A friend class ciMethod;
0N/A friend class ciField;
0N/A friend class ciBytecodeStream;
0N/A
0N/Aprivate:
0N/A bool _is_shared;
0N/A
0N/A jobject _loader;
0N/A jobject _protection_domain;
0N/A
0N/A bool _is_initialized;
0N/A bool _is_linked;
0N/A bool _has_finalizer;
0N/A bool _has_subklass;
0N/A ciFlags _flags;
0N/A jint _nonstatic_field_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
0N/A enum { implementors_limit = instanceKlass::implementors_limit };
0N/A ciInstanceKlass* _implementors[implementors_limit];
0N/A jint _nof_implementors;
0N/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
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
0N/A bool compute_shared_is_initialized();
0N/A bool compute_shared_is_linked();
0N/A bool compute_shared_has_subklass();
0N/A int compute_shared_nof_implementors();
0N/A int compute_nonstatic_fields();
0N/A GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
0N/A
0N/Apublic:
0N/A // Has this klass been initialized?
0N/A bool is_initialized() {
0N/A if (_is_shared && !_is_initialized) {
0N/A return is_loaded() && compute_shared_is_initialized();
0N/A }
0N/A return _is_initialized;
0N/A }
0N/A // Has this klass been linked?
0N/A bool is_linked() {
0N/A if (_is_shared && !_is_linked) {
0N/A return is_loaded() && compute_shared_is_linked();
0N/A }
0N/A return _is_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;
}
jint size_helper() {
return (Klass::layout_helper_size_in_bytes(layout_helper())
>> LogHeapWordSize);
}
jint nonstatic_field_size() {
assert(is_loaded(), "must be loaded");
return _nonstatic_field_size; }
ciInstanceKlass* super();
jint nof_implementors() {
assert(is_loaded(), "must be loaded");
if (_is_shared) return compute_shared_nof_implementors();
return _nof_implementors;
}
ciInstanceKlass* get_canonical_holder(int offset);
ciField* get_field_by_offset(int field_offset, bool is_static);
// total number of nonstatic fields (including inherited):
int nof_nonstatic_fields() {
if (_nonstatic_fields == NULL)
return compute_nonstatic_fields();
else
return _nonstatic_fields->length();
}
// nth nonstatic field (presented by ascending address)
ciField* nonstatic_field_at(int i) {
assert(_nonstatic_fields != NULL, "");
return _nonstatic_fields->at(i);
}
ciInstanceKlass* unique_concrete_subklass();
bool has_finalizable_subclass();
bool contains_field_offset(int offset) {
return (offset/wordSize) >= instanceOopDesc::header_size()
&& (offset/wordSize)-instanceOopDesc::header_size() < nonstatic_field_size();
}
// Get the instance of java.lang.Class corresponding to
// this klass. This instance is used for locking of
// synchronized static methods of this klass.
ciInstance* java_mirror();
// Java access flags
bool is_public () { return flags().is_public(); }
bool is_final () { return flags().is_final(); }
bool is_super () { return flags().is_super(); }
bool is_interface () { return flags().is_interface(); }
bool is_abstract () { return flags().is_abstract(); }
ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
// Note: To find a method from name and type strings, use ciSymbol::make,
// but consider adding to vmSymbols.hpp instead.
bool is_leaf_type();
ciInstanceKlass* implementor(int n);
// Is the defining class loader of this class the default loader?
bool uses_default_loader();
bool is_java_lang_Object();
// What kind of ciObject is this?
bool is_instance_klass() { return true; }
bool is_java_klass() { return true; }
};