src/share/vm/ci/ciInstanceKlass.hpp

Wed, 31 Jan 2018 19:24:57 -0500

author
dbuck
date
Wed, 31 Jan 2018 19:24:57 -0500
changeset 9289
427b2fb1944f
parent 8739
0b85ccd62409
child 8856
ac27a9c85bea
permissions
-rw-r--r--

8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
Reviewed-by: dcubed

duke@435 1 /*
coleenp@8739 2 * Copyright (c) 1999, 2016, 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
stefank@2314 25 #ifndef SHARE_VM_CI_CIINSTANCEKLASS_HPP
stefank@2314 26 #define SHARE_VM_CI_CIINSTANCEKLASS_HPP
stefank@2314 27
stefank@2314 28 #include "ci/ciConstantPoolCache.hpp"
stefank@2314 29 #include "ci/ciFlags.hpp"
stefank@2314 30 #include "ci/ciKlass.hpp"
stefank@2314 31 #include "ci/ciSymbol.hpp"
stefank@2314 32
duke@435 33 // ciInstanceKlass
duke@435 34 //
coleenp@4037 35 // This class represents a Klass* in the HotSpot virtual machine
coleenp@4037 36 // whose Klass part is an InstanceKlass. It may or may not
duke@435 37 // be loaded.
duke@435 38 class ciInstanceKlass : public ciKlass {
duke@435 39 CI_PACKAGE_ACCESS
twisti@1573 40 friend class ciBytecodeStream;
duke@435 41 friend class ciEnv;
twisti@1573 42 friend class ciExceptionHandler;
duke@435 43 friend class ciMethod;
duke@435 44 friend class ciField;
duke@435 45
duke@435 46 private:
duke@435 47 jobject _loader;
duke@435 48 jobject _protection_domain;
duke@435 49
coleenp@4037 50 InstanceKlass::ClassState _init_state; // state of class
coleenp@548 51 bool _is_shared;
duke@435 52 bool _has_finalizer;
duke@435 53 bool _has_subklass;
coleenp@548 54 bool _has_nonstatic_fields;
iveresov@6050 55 bool _has_default_methods;
coleenp@8739 56 bool _is_anonymous;
coleenp@548 57
duke@435 58 ciFlags _flags;
duke@435 59 jint _nonstatic_field_size;
kvn@479 60 jint _nonstatic_oop_map_size;
duke@435 61
duke@435 62 // Lazy fields get filled in only upon request.
duke@435 63 ciInstanceKlass* _super;
duke@435 64 ciInstance* _java_mirror;
duke@435 65
duke@435 66 ciConstantPoolCache* _field_cache; // cached map index->field
duke@435 67 GrowableArray<ciField*>* _nonstatic_fields;
duke@435 68
jiangli@3701 69 // The possible values of the _implementor fall into following three cases:
jiangli@3701 70 // NULL: no implementor.
jiangli@3701 71 // A ciInstanceKlass that's not itself: one implementor.
jiangli@3701 72 // Itsef: more than one implementors.
jiangli@3701 73 ciInstanceKlass* _implementor;
duke@435 74
kvn@479 75 GrowableArray<ciField*>* _non_static_fields;
kvn@479 76
duke@435 77 protected:
duke@435 78 ciInstanceKlass(KlassHandle h_k);
duke@435 79 ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
duke@435 80
coleenp@4037 81 InstanceKlass* get_instanceKlass() const {
coleenp@4037 82 return (InstanceKlass*)get_Klass();
duke@435 83 }
duke@435 84
duke@435 85 oop loader();
duke@435 86 jobject loader_handle();
duke@435 87
duke@435 88 oop protection_domain();
duke@435 89 jobject protection_domain_handle();
duke@435 90
duke@435 91 const char* type_string() { return "ciInstanceKlass"; }
duke@435 92
twisti@1573 93 bool is_in_package_impl(const char* packagename, int len);
twisti@1573 94
duke@435 95 void print_impl(outputStream* st);
duke@435 96
duke@435 97 ciConstantPoolCache* field_cache();
duke@435 98
duke@435 99 bool is_shared() { return _is_shared; }
duke@435 100
never@2000 101 void compute_shared_init_state();
duke@435 102 bool compute_shared_has_subklass();
duke@435 103 int compute_nonstatic_fields();
duke@435 104 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
duke@435 105
never@2000 106 // Update the init_state for shared klasses
coleenp@4037 107 void update_if_shared(InstanceKlass::ClassState expected) {
never@2000 108 if (_is_shared && _init_state != expected) {
never@2000 109 if (is_loaded()) compute_shared_init_state();
never@2000 110 }
never@2000 111 }
never@2000 112
duke@435 113 public:
duke@435 114 // Has this klass been initialized?
duke@435 115 bool is_initialized() {
coleenp@4037 116 update_if_shared(InstanceKlass::fully_initialized);
coleenp@4037 117 return _init_state == InstanceKlass::fully_initialized;
never@2000 118 }
never@2000 119 // Is this klass being initialized?
never@2000 120 bool is_being_initialized() {
coleenp@4037 121 update_if_shared(InstanceKlass::being_initialized);
coleenp@4037 122 return _init_state == InstanceKlass::being_initialized;
duke@435 123 }
duke@435 124 // Has this klass been linked?
duke@435 125 bool is_linked() {
coleenp@4037 126 update_if_shared(InstanceKlass::linked);
coleenp@4037 127 return _init_state >= InstanceKlass::linked;
duke@435 128 }
duke@435 129
duke@435 130 // General klass information.
duke@435 131 ciFlags flags() {
duke@435 132 assert(is_loaded(), "must be loaded");
duke@435 133 return _flags;
duke@435 134 }
duke@435 135 bool has_finalizer() {
duke@435 136 assert(is_loaded(), "must be loaded");
duke@435 137 return _has_finalizer; }
duke@435 138 bool has_subklass() {
duke@435 139 assert(is_loaded(), "must be loaded");
duke@435 140 if (_is_shared && !_has_subklass) {
duke@435 141 if (flags().is_final()) {
duke@435 142 return false;
duke@435 143 } else {
duke@435 144 return compute_shared_has_subklass();
duke@435 145 }
duke@435 146 }
duke@435 147 return _has_subklass;
duke@435 148 }
duke@435 149 jint size_helper() {
duke@435 150 return (Klass::layout_helper_size_in_bytes(layout_helper())
duke@435 151 >> LogHeapWordSize);
duke@435 152 }
duke@435 153 jint nonstatic_field_size() {
duke@435 154 assert(is_loaded(), "must be loaded");
duke@435 155 return _nonstatic_field_size; }
coleenp@548 156 jint has_nonstatic_fields() {
coleenp@548 157 assert(is_loaded(), "must be loaded");
coleenp@548 158 return _has_nonstatic_fields; }
kvn@479 159 jint nonstatic_oop_map_size() {
kvn@479 160 assert(is_loaded(), "must be loaded");
kvn@479 161 return _nonstatic_oop_map_size; }
duke@435 162 ciInstanceKlass* super();
jiangli@3701 163 jint nof_implementors() {
jiangli@3701 164 ciInstanceKlass* impl;
duke@435 165 assert(is_loaded(), "must be loaded");
jiangli@3701 166 impl = implementor();
jiangli@3701 167 if (impl == NULL) {
jiangli@3701 168 return 0;
jiangli@3701 169 } else if (impl != this) {
jiangli@3701 170 return 1;
jiangli@3701 171 } else {
jiangli@3701 172 return 2;
jiangli@3701 173 }
duke@435 174 }
duke@435 175
iveresov@6050 176 bool has_default_methods() {
iveresov@6050 177 assert(is_loaded(), "must be loaded");
iveresov@6050 178 return _has_default_methods;
iveresov@6050 179 }
iveresov@6050 180
coleenp@8739 181 bool is_anonymous() {
coleenp@8739 182 return _is_anonymous;
coleenp@8739 183 }
coleenp@8739 184
duke@435 185 ciInstanceKlass* get_canonical_holder(int offset);
duke@435 186 ciField* get_field_by_offset(int field_offset, bool is_static);
never@1515 187 ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
kvn@479 188
kvn@479 189 GrowableArray<ciField*>* non_static_fields();
kvn@479 190
duke@435 191 // total number of nonstatic fields (including inherited):
duke@435 192 int nof_nonstatic_fields() {
duke@435 193 if (_nonstatic_fields == NULL)
duke@435 194 return compute_nonstatic_fields();
duke@435 195 else
duke@435 196 return _nonstatic_fields->length();
duke@435 197 }
duke@435 198 // nth nonstatic field (presented by ascending address)
duke@435 199 ciField* nonstatic_field_at(int i) {
duke@435 200 assert(_nonstatic_fields != NULL, "");
duke@435 201 return _nonstatic_fields->at(i);
duke@435 202 }
duke@435 203
duke@435 204 ciInstanceKlass* unique_concrete_subklass();
duke@435 205 bool has_finalizable_subclass();
duke@435 206
duke@435 207 bool contains_field_offset(int offset) {
coleenp@548 208 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
duke@435 209 }
duke@435 210
duke@435 211 // Get the instance of java.lang.Class corresponding to
duke@435 212 // this klass. This instance is used for locking of
duke@435 213 // synchronized static methods of this klass.
duke@435 214 ciInstance* java_mirror();
duke@435 215
duke@435 216 // Java access flags
duke@435 217 bool is_public () { return flags().is_public(); }
duke@435 218 bool is_final () { return flags().is_final(); }
duke@435 219 bool is_super () { return flags().is_super(); }
duke@435 220 bool is_interface () { return flags().is_interface(); }
duke@435 221 bool is_abstract () { return flags().is_abstract(); }
duke@435 222
duke@435 223 ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
duke@435 224 // Note: To find a method from name and type strings, use ciSymbol::make,
duke@435 225 // but consider adding to vmSymbols.hpp instead.
duke@435 226
duke@435 227 bool is_leaf_type();
jiangli@3701 228 ciInstanceKlass* implementor();
duke@435 229
duke@435 230 // Is the defining class loader of this class the default loader?
kvn@5110 231 bool uses_default_loader() const;
duke@435 232
coleenp@4037 233 bool is_java_lang_Object() const;
duke@435 234
kvn@5110 235 BasicType box_klass_type() const;
kvn@5110 236 bool is_box_klass() const;
kvn@5110 237 bool is_boxed_value_offset(int offset) const;
kvn@5110 238
twisti@1573 239 // Is this klass in the given package?
twisti@1573 240 bool is_in_package(const char* packagename) {
twisti@1573 241 return is_in_package(packagename, (int) strlen(packagename));
twisti@1573 242 }
twisti@1573 243 bool is_in_package(const char* packagename, int len);
twisti@1573 244
duke@435 245 // What kind of ciObject is this?
coleenp@4037 246 bool is_instance_klass() const { return true; }
coleenp@4037 247 bool is_java_klass() const { return true; }
minqi@4267 248
roland@5914 249 virtual ciKlass* exact_klass() {
roland@5914 250 if (is_loaded() && is_final() && !is_interface()) {
roland@5914 251 return this;
roland@5914 252 }
roland@5914 253 return NULL;
roland@5914 254 }
roland@5914 255
coleenp@8739 256 ciInstanceKlass* host_klass();
coleenp@8739 257
minqi@4267 258 // Dump the current state of this klass for compilation replay.
minqi@4267 259 virtual void dump_replay_data(outputStream* out);
duke@435 260 };
stefank@2314 261
stefank@2314 262 #endif // SHARE_VM_CI_CIINSTANCEKLASS_HPP

mercurial