src/share/vm/ci/ciInstanceKlass.hpp

Mon, 12 Jul 2010 10:58:25 -0700

author
never
date
Mon, 12 Jul 2010 10:58:25 -0700
changeset 2000
3941674cc7fa
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6958668: repeated uncommon trapping for new of klass which is being initialized
Reviewed-by: kvn, jrose

duke@435 1 /*
never@2000 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * 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
twisti@1573 32 friend class ciBytecodeStream;
duke@435 33 friend class ciEnv;
twisti@1573 34 friend class ciExceptionHandler;
duke@435 35 friend class ciMethod;
duke@435 36 friend class ciField;
duke@435 37
duke@435 38 private:
duke@435 39 jobject _loader;
duke@435 40 jobject _protection_domain;
duke@435 41
never@2000 42 instanceKlass::ClassState _init_state; // state of class
coleenp@548 43 bool _is_shared;
duke@435 44 bool _has_finalizer;
duke@435 45 bool _has_subklass;
coleenp@548 46 bool _has_nonstatic_fields;
coleenp@548 47
duke@435 48 ciFlags _flags;
duke@435 49 jint _nonstatic_field_size;
kvn@479 50 jint _nonstatic_oop_map_size;
duke@435 51
duke@435 52 // Lazy fields get filled in only upon request.
duke@435 53 ciInstanceKlass* _super;
duke@435 54 ciInstance* _java_mirror;
duke@435 55
duke@435 56 ciConstantPoolCache* _field_cache; // cached map index->field
duke@435 57 GrowableArray<ciField*>* _nonstatic_fields;
duke@435 58
duke@435 59 enum { implementors_limit = instanceKlass::implementors_limit };
duke@435 60 ciInstanceKlass* _implementors[implementors_limit];
duke@435 61 jint _nof_implementors;
duke@435 62
kvn@479 63 GrowableArray<ciField*>* _non_static_fields;
kvn@479 64
duke@435 65 protected:
duke@435 66 ciInstanceKlass(KlassHandle h_k);
duke@435 67 ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
duke@435 68
duke@435 69 instanceKlass* get_instanceKlass() const {
duke@435 70 return (instanceKlass*)get_Klass();
duke@435 71 }
duke@435 72
duke@435 73 oop loader();
duke@435 74 jobject loader_handle();
duke@435 75
duke@435 76 oop protection_domain();
duke@435 77 jobject protection_domain_handle();
duke@435 78
duke@435 79 const char* type_string() { return "ciInstanceKlass"; }
duke@435 80
twisti@1573 81 bool is_in_package_impl(const char* packagename, int len);
twisti@1573 82
duke@435 83 void print_impl(outputStream* st);
duke@435 84
duke@435 85 ciConstantPoolCache* field_cache();
duke@435 86
duke@435 87 bool is_shared() { return _is_shared; }
duke@435 88
never@2000 89 void compute_shared_init_state();
duke@435 90 bool compute_shared_has_subklass();
duke@435 91 int compute_shared_nof_implementors();
duke@435 92 int compute_nonstatic_fields();
duke@435 93 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
duke@435 94
never@2000 95 // Update the init_state for shared klasses
never@2000 96 void update_if_shared(instanceKlass::ClassState expected) {
never@2000 97 if (_is_shared && _init_state != expected) {
never@2000 98 if (is_loaded()) compute_shared_init_state();
never@2000 99 }
never@2000 100 }
never@2000 101
duke@435 102 public:
duke@435 103 // Has this klass been initialized?
duke@435 104 bool is_initialized() {
never@2000 105 update_if_shared(instanceKlass::fully_initialized);
never@2000 106 return _init_state == instanceKlass::fully_initialized;
never@2000 107 }
never@2000 108 // Is this klass being initialized?
never@2000 109 bool is_being_initialized() {
never@2000 110 update_if_shared(instanceKlass::being_initialized);
never@2000 111 return _init_state == instanceKlass::being_initialized;
duke@435 112 }
duke@435 113 // Has this klass been linked?
duke@435 114 bool is_linked() {
never@2000 115 update_if_shared(instanceKlass::linked);
never@2000 116 return _init_state >= instanceKlass::linked;
duke@435 117 }
duke@435 118
duke@435 119 // General klass information.
duke@435 120 ciFlags flags() {
duke@435 121 assert(is_loaded(), "must be loaded");
duke@435 122 return _flags;
duke@435 123 }
duke@435 124 bool has_finalizer() {
duke@435 125 assert(is_loaded(), "must be loaded");
duke@435 126 return _has_finalizer; }
duke@435 127 bool has_subklass() {
duke@435 128 assert(is_loaded(), "must be loaded");
duke@435 129 if (_is_shared && !_has_subklass) {
duke@435 130 if (flags().is_final()) {
duke@435 131 return false;
duke@435 132 } else {
duke@435 133 return compute_shared_has_subklass();
duke@435 134 }
duke@435 135 }
duke@435 136 return _has_subklass;
duke@435 137 }
duke@435 138 jint size_helper() {
duke@435 139 return (Klass::layout_helper_size_in_bytes(layout_helper())
duke@435 140 >> LogHeapWordSize);
duke@435 141 }
duke@435 142 jint nonstatic_field_size() {
duke@435 143 assert(is_loaded(), "must be loaded");
duke@435 144 return _nonstatic_field_size; }
coleenp@548 145 jint has_nonstatic_fields() {
coleenp@548 146 assert(is_loaded(), "must be loaded");
coleenp@548 147 return _has_nonstatic_fields; }
kvn@479 148 jint nonstatic_oop_map_size() {
kvn@479 149 assert(is_loaded(), "must be loaded");
kvn@479 150 return _nonstatic_oop_map_size; }
duke@435 151 ciInstanceKlass* super();
duke@435 152 jint nof_implementors() {
duke@435 153 assert(is_loaded(), "must be loaded");
duke@435 154 if (_is_shared) return compute_shared_nof_implementors();
duke@435 155 return _nof_implementors;
duke@435 156 }
duke@435 157
duke@435 158 ciInstanceKlass* get_canonical_holder(int offset);
duke@435 159 ciField* get_field_by_offset(int field_offset, bool is_static);
never@1515 160 ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
kvn@479 161
kvn@479 162 GrowableArray<ciField*>* non_static_fields();
kvn@479 163
duke@435 164 // total number of nonstatic fields (including inherited):
duke@435 165 int nof_nonstatic_fields() {
duke@435 166 if (_nonstatic_fields == NULL)
duke@435 167 return compute_nonstatic_fields();
duke@435 168 else
duke@435 169 return _nonstatic_fields->length();
duke@435 170 }
duke@435 171 // nth nonstatic field (presented by ascending address)
duke@435 172 ciField* nonstatic_field_at(int i) {
duke@435 173 assert(_nonstatic_fields != NULL, "");
duke@435 174 return _nonstatic_fields->at(i);
duke@435 175 }
duke@435 176
duke@435 177 ciInstanceKlass* unique_concrete_subklass();
duke@435 178 bool has_finalizable_subclass();
duke@435 179
duke@435 180 bool contains_field_offset(int offset) {
coleenp@548 181 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
duke@435 182 }
duke@435 183
duke@435 184 // Get the instance of java.lang.Class corresponding to
duke@435 185 // this klass. This instance is used for locking of
duke@435 186 // synchronized static methods of this klass.
duke@435 187 ciInstance* java_mirror();
duke@435 188
duke@435 189 // Java access flags
duke@435 190 bool is_public () { return flags().is_public(); }
duke@435 191 bool is_final () { return flags().is_final(); }
duke@435 192 bool is_super () { return flags().is_super(); }
duke@435 193 bool is_interface () { return flags().is_interface(); }
duke@435 194 bool is_abstract () { return flags().is_abstract(); }
duke@435 195
duke@435 196 ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
duke@435 197 // Note: To find a method from name and type strings, use ciSymbol::make,
duke@435 198 // but consider adding to vmSymbols.hpp instead.
duke@435 199
duke@435 200 bool is_leaf_type();
duke@435 201 ciInstanceKlass* implementor(int n);
duke@435 202
duke@435 203 // Is the defining class loader of this class the default loader?
duke@435 204 bool uses_default_loader();
duke@435 205
duke@435 206 bool is_java_lang_Object();
duke@435 207
twisti@1573 208 // Is this klass in the given package?
twisti@1573 209 bool is_in_package(const char* packagename) {
twisti@1573 210 return is_in_package(packagename, (int) strlen(packagename));
twisti@1573 211 }
twisti@1573 212 bool is_in_package(const char* packagename, int len);
twisti@1573 213
duke@435 214 // What kind of ciObject is this?
duke@435 215 bool is_instance_klass() { return true; }
duke@435 216 bool is_java_klass() { return true; }
duke@435 217 };

mercurial