src/share/vm/ci/ciInstanceKlass.hpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 479
52fed2ec0afb
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // ciInstanceKlass
duke@435 26 //
duke@435 27 // This class represents a klassOop in the HotSpot virtual machine
duke@435 28 // whose Klass part is an instanceKlass. It may or may not
duke@435 29 // be loaded.
duke@435 30 class ciInstanceKlass : public ciKlass {
duke@435 31 CI_PACKAGE_ACCESS
duke@435 32 friend class ciEnv;
duke@435 33 friend class ciMethod;
duke@435 34 friend class ciField;
duke@435 35 friend class ciBytecodeStream;
duke@435 36
duke@435 37 private:
duke@435 38 bool _is_shared;
duke@435 39
duke@435 40 jobject _loader;
duke@435 41 jobject _protection_domain;
duke@435 42
duke@435 43 bool _is_initialized;
duke@435 44 bool _is_linked;
duke@435 45 bool _has_finalizer;
duke@435 46 bool _has_subklass;
duke@435 47 ciFlags _flags;
duke@435 48 jint _nonstatic_field_size;
duke@435 49
duke@435 50 // Lazy fields get filled in only upon request.
duke@435 51 ciInstanceKlass* _super;
duke@435 52 ciInstance* _java_mirror;
duke@435 53
duke@435 54 ciConstantPoolCache* _field_cache; // cached map index->field
duke@435 55 GrowableArray<ciField*>* _nonstatic_fields;
duke@435 56
duke@435 57 enum { implementors_limit = instanceKlass::implementors_limit };
duke@435 58 ciInstanceKlass* _implementors[implementors_limit];
duke@435 59 jint _nof_implementors;
duke@435 60
duke@435 61 protected:
duke@435 62 ciInstanceKlass(KlassHandle h_k);
duke@435 63 ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
duke@435 64
duke@435 65 instanceKlass* get_instanceKlass() const {
duke@435 66 return (instanceKlass*)get_Klass();
duke@435 67 }
duke@435 68
duke@435 69 oop loader();
duke@435 70 jobject loader_handle();
duke@435 71
duke@435 72 oop protection_domain();
duke@435 73 jobject protection_domain_handle();
duke@435 74
duke@435 75 const char* type_string() { return "ciInstanceKlass"; }
duke@435 76
duke@435 77 void print_impl(outputStream* st);
duke@435 78
duke@435 79 ciConstantPoolCache* field_cache();
duke@435 80
duke@435 81 bool is_shared() { return _is_shared; }
duke@435 82
duke@435 83 bool compute_shared_is_initialized();
duke@435 84 bool compute_shared_is_linked();
duke@435 85 bool compute_shared_has_subklass();
duke@435 86 int compute_shared_nof_implementors();
duke@435 87 int compute_nonstatic_fields();
duke@435 88 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
duke@435 89
duke@435 90 public:
duke@435 91 // Has this klass been initialized?
duke@435 92 bool is_initialized() {
duke@435 93 if (_is_shared && !_is_initialized) {
duke@435 94 return is_loaded() && compute_shared_is_initialized();
duke@435 95 }
duke@435 96 return _is_initialized;
duke@435 97 }
duke@435 98 // Has this klass been linked?
duke@435 99 bool is_linked() {
duke@435 100 if (_is_shared && !_is_linked) {
duke@435 101 return is_loaded() && compute_shared_is_linked();
duke@435 102 }
duke@435 103 return _is_linked;
duke@435 104 }
duke@435 105
duke@435 106 // General klass information.
duke@435 107 ciFlags flags() {
duke@435 108 assert(is_loaded(), "must be loaded");
duke@435 109 return _flags;
duke@435 110 }
duke@435 111 bool has_finalizer() {
duke@435 112 assert(is_loaded(), "must be loaded");
duke@435 113 return _has_finalizer; }
duke@435 114 bool has_subklass() {
duke@435 115 assert(is_loaded(), "must be loaded");
duke@435 116 if (_is_shared && !_has_subklass) {
duke@435 117 if (flags().is_final()) {
duke@435 118 return false;
duke@435 119 } else {
duke@435 120 return compute_shared_has_subklass();
duke@435 121 }
duke@435 122 }
duke@435 123 return _has_subklass;
duke@435 124 }
duke@435 125 jint size_helper() {
duke@435 126 return (Klass::layout_helper_size_in_bytes(layout_helper())
duke@435 127 >> LogHeapWordSize);
duke@435 128 }
duke@435 129 jint nonstatic_field_size() {
duke@435 130 assert(is_loaded(), "must be loaded");
duke@435 131 return _nonstatic_field_size; }
duke@435 132 ciInstanceKlass* super();
duke@435 133 jint nof_implementors() {
duke@435 134 assert(is_loaded(), "must be loaded");
duke@435 135 if (_is_shared) return compute_shared_nof_implementors();
duke@435 136 return _nof_implementors;
duke@435 137 }
duke@435 138
duke@435 139 ciInstanceKlass* get_canonical_holder(int offset);
duke@435 140 ciField* get_field_by_offset(int field_offset, bool is_static);
duke@435 141 // total number of nonstatic fields (including inherited):
duke@435 142 int nof_nonstatic_fields() {
duke@435 143 if (_nonstatic_fields == NULL)
duke@435 144 return compute_nonstatic_fields();
duke@435 145 else
duke@435 146 return _nonstatic_fields->length();
duke@435 147 }
duke@435 148 // nth nonstatic field (presented by ascending address)
duke@435 149 ciField* nonstatic_field_at(int i) {
duke@435 150 assert(_nonstatic_fields != NULL, "");
duke@435 151 return _nonstatic_fields->at(i);
duke@435 152 }
duke@435 153
duke@435 154 ciInstanceKlass* unique_concrete_subklass();
duke@435 155 bool has_finalizable_subclass();
duke@435 156
duke@435 157 bool contains_field_offset(int offset) {
duke@435 158 return (offset/wordSize) >= instanceOopDesc::header_size()
duke@435 159 && (offset/wordSize)-instanceOopDesc::header_size() < nonstatic_field_size();
duke@435 160 }
duke@435 161
duke@435 162 // Get the instance of java.lang.Class corresponding to
duke@435 163 // this klass. This instance is used for locking of
duke@435 164 // synchronized static methods of this klass.
duke@435 165 ciInstance* java_mirror();
duke@435 166
duke@435 167 // Java access flags
duke@435 168 bool is_public () { return flags().is_public(); }
duke@435 169 bool is_final () { return flags().is_final(); }
duke@435 170 bool is_super () { return flags().is_super(); }
duke@435 171 bool is_interface () { return flags().is_interface(); }
duke@435 172 bool is_abstract () { return flags().is_abstract(); }
duke@435 173
duke@435 174 ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
duke@435 175 // Note: To find a method from name and type strings, use ciSymbol::make,
duke@435 176 // but consider adding to vmSymbols.hpp instead.
duke@435 177
duke@435 178 bool is_leaf_type();
duke@435 179 ciInstanceKlass* implementor(int n);
duke@435 180
duke@435 181 // Is the defining class loader of this class the default loader?
duke@435 182 bool uses_default_loader();
duke@435 183
duke@435 184 bool is_java_lang_Object();
duke@435 185
duke@435 186 // What kind of ciObject is this?
duke@435 187 bool is_instance_klass() { return true; }
duke@435 188 bool is_java_klass() { return true; }
duke@435 189 };

mercurial