src/share/vm/ci/ciInstanceKlass.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_CI_CIINSTANCEKLASS_HPP
aoqi@0 26 #define SHARE_VM_CI_CIINSTANCEKLASS_HPP
aoqi@0 27
aoqi@0 28 #include "ci/ciConstantPoolCache.hpp"
aoqi@0 29 #include "ci/ciFlags.hpp"
aoqi@0 30 #include "ci/ciKlass.hpp"
aoqi@0 31 #include "ci/ciSymbol.hpp"
aoqi@0 32
aoqi@0 33 // ciInstanceKlass
aoqi@0 34 //
aoqi@0 35 // This class represents a Klass* in the HotSpot virtual machine
aoqi@0 36 // whose Klass part is an InstanceKlass. It may or may not
aoqi@0 37 // be loaded.
aoqi@0 38 class ciInstanceKlass : public ciKlass {
aoqi@0 39 CI_PACKAGE_ACCESS
aoqi@0 40 friend class ciBytecodeStream;
aoqi@0 41 friend class ciEnv;
aoqi@0 42 friend class ciExceptionHandler;
aoqi@0 43 friend class ciMethod;
aoqi@0 44 friend class ciField;
aoqi@0 45
aoqi@0 46 private:
aoqi@0 47 jobject _loader;
aoqi@0 48 jobject _protection_domain;
aoqi@0 49
aoqi@0 50 InstanceKlass::ClassState _init_state; // state of class
aoqi@0 51 bool _is_shared;
aoqi@0 52 bool _has_finalizer;
aoqi@0 53 bool _has_subklass;
aoqi@0 54 bool _has_nonstatic_fields;
aoqi@0 55 bool _has_default_methods;
aoqi@0 56
aoqi@0 57 ciFlags _flags;
aoqi@0 58 jint _nonstatic_field_size;
aoqi@0 59 jint _nonstatic_oop_map_size;
aoqi@0 60
aoqi@0 61 // Lazy fields get filled in only upon request.
aoqi@0 62 ciInstanceKlass* _super;
aoqi@0 63 ciInstance* _java_mirror;
aoqi@0 64
aoqi@0 65 ciConstantPoolCache* _field_cache; // cached map index->field
aoqi@0 66 GrowableArray<ciField*>* _nonstatic_fields;
aoqi@0 67
aoqi@0 68 // The possible values of the _implementor fall into following three cases:
aoqi@0 69 // NULL: no implementor.
aoqi@0 70 // A ciInstanceKlass that's not itself: one implementor.
aoqi@0 71 // Itsef: more than one implementors.
aoqi@0 72 ciInstanceKlass* _implementor;
aoqi@0 73
aoqi@0 74 GrowableArray<ciField*>* _non_static_fields;
aoqi@0 75
aoqi@0 76 protected:
aoqi@0 77 ciInstanceKlass(KlassHandle h_k);
aoqi@0 78 ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
aoqi@0 79
aoqi@0 80 InstanceKlass* get_instanceKlass() const {
aoqi@0 81 return (InstanceKlass*)get_Klass();
aoqi@0 82 }
aoqi@0 83
aoqi@0 84 oop loader();
aoqi@0 85 jobject loader_handle();
aoqi@0 86
aoqi@0 87 oop protection_domain();
aoqi@0 88 jobject protection_domain_handle();
aoqi@0 89
aoqi@0 90 const char* type_string() { return "ciInstanceKlass"; }
aoqi@0 91
aoqi@0 92 bool is_in_package_impl(const char* packagename, int len);
aoqi@0 93
aoqi@0 94 void print_impl(outputStream* st);
aoqi@0 95
aoqi@0 96 ciConstantPoolCache* field_cache();
aoqi@0 97
aoqi@0 98 bool is_shared() { return _is_shared; }
aoqi@0 99
aoqi@0 100 void compute_shared_init_state();
aoqi@0 101 bool compute_shared_has_subklass();
aoqi@0 102 int compute_nonstatic_fields();
aoqi@0 103 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
aoqi@0 104
aoqi@0 105 // Update the init_state for shared klasses
aoqi@0 106 void update_if_shared(InstanceKlass::ClassState expected) {
aoqi@0 107 if (_is_shared && _init_state != expected) {
aoqi@0 108 if (is_loaded()) compute_shared_init_state();
aoqi@0 109 }
aoqi@0 110 }
aoqi@0 111
aoqi@0 112 public:
aoqi@0 113 // Has this klass been initialized?
aoqi@0 114 bool is_initialized() {
aoqi@0 115 update_if_shared(InstanceKlass::fully_initialized);
aoqi@0 116 return _init_state == InstanceKlass::fully_initialized;
aoqi@0 117 }
aoqi@0 118 // Is this klass being initialized?
aoqi@0 119 bool is_being_initialized() {
aoqi@0 120 update_if_shared(InstanceKlass::being_initialized);
aoqi@0 121 return _init_state == InstanceKlass::being_initialized;
aoqi@0 122 }
aoqi@0 123 // Has this klass been linked?
aoqi@0 124 bool is_linked() {
aoqi@0 125 update_if_shared(InstanceKlass::linked);
aoqi@0 126 return _init_state >= InstanceKlass::linked;
aoqi@0 127 }
aoqi@0 128
aoqi@0 129 // General klass information.
aoqi@0 130 ciFlags flags() {
aoqi@0 131 assert(is_loaded(), "must be loaded");
aoqi@0 132 return _flags;
aoqi@0 133 }
aoqi@0 134 bool has_finalizer() {
aoqi@0 135 assert(is_loaded(), "must be loaded");
aoqi@0 136 return _has_finalizer; }
aoqi@0 137 bool has_subklass() {
aoqi@0 138 assert(is_loaded(), "must be loaded");
aoqi@0 139 if (_is_shared && !_has_subklass) {
aoqi@0 140 if (flags().is_final()) {
aoqi@0 141 return false;
aoqi@0 142 } else {
aoqi@0 143 return compute_shared_has_subklass();
aoqi@0 144 }
aoqi@0 145 }
aoqi@0 146 return _has_subklass;
aoqi@0 147 }
aoqi@0 148 jint size_helper() {
aoqi@0 149 return (Klass::layout_helper_size_in_bytes(layout_helper())
aoqi@0 150 >> LogHeapWordSize);
aoqi@0 151 }
aoqi@0 152 jint nonstatic_field_size() {
aoqi@0 153 assert(is_loaded(), "must be loaded");
aoqi@0 154 return _nonstatic_field_size; }
aoqi@0 155 jint has_nonstatic_fields() {
aoqi@0 156 assert(is_loaded(), "must be loaded");
aoqi@0 157 return _has_nonstatic_fields; }
aoqi@0 158 jint nonstatic_oop_map_size() {
aoqi@0 159 assert(is_loaded(), "must be loaded");
aoqi@0 160 return _nonstatic_oop_map_size; }
aoqi@0 161 ciInstanceKlass* super();
aoqi@0 162 jint nof_implementors() {
aoqi@0 163 ciInstanceKlass* impl;
aoqi@0 164 assert(is_loaded(), "must be loaded");
aoqi@0 165 impl = implementor();
aoqi@0 166 if (impl == NULL) {
aoqi@0 167 return 0;
aoqi@0 168 } else if (impl != this) {
aoqi@0 169 return 1;
aoqi@0 170 } else {
aoqi@0 171 return 2;
aoqi@0 172 }
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 bool has_default_methods() {
aoqi@0 176 assert(is_loaded(), "must be loaded");
aoqi@0 177 return _has_default_methods;
aoqi@0 178 }
aoqi@0 179
aoqi@0 180 ciInstanceKlass* get_canonical_holder(int offset);
aoqi@0 181 ciField* get_field_by_offset(int field_offset, bool is_static);
aoqi@0 182 ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
aoqi@0 183
aoqi@0 184 GrowableArray<ciField*>* non_static_fields();
aoqi@0 185
aoqi@0 186 // total number of nonstatic fields (including inherited):
aoqi@0 187 int nof_nonstatic_fields() {
aoqi@0 188 if (_nonstatic_fields == NULL)
aoqi@0 189 return compute_nonstatic_fields();
aoqi@0 190 else
aoqi@0 191 return _nonstatic_fields->length();
aoqi@0 192 }
aoqi@0 193 // nth nonstatic field (presented by ascending address)
aoqi@0 194 ciField* nonstatic_field_at(int i) {
aoqi@0 195 assert(_nonstatic_fields != NULL, "");
aoqi@0 196 return _nonstatic_fields->at(i);
aoqi@0 197 }
aoqi@0 198
aoqi@0 199 ciInstanceKlass* unique_concrete_subklass();
aoqi@0 200 bool has_finalizable_subclass();
aoqi@0 201
aoqi@0 202 bool contains_field_offset(int offset) {
aoqi@0 203 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
aoqi@0 204 }
aoqi@0 205
aoqi@0 206 // Get the instance of java.lang.Class corresponding to
aoqi@0 207 // this klass. This instance is used for locking of
aoqi@0 208 // synchronized static methods of this klass.
aoqi@0 209 ciInstance* java_mirror();
aoqi@0 210
aoqi@0 211 // Java access flags
aoqi@0 212 bool is_public () { return flags().is_public(); }
aoqi@0 213 bool is_final () { return flags().is_final(); }
aoqi@0 214 bool is_super () { return flags().is_super(); }
aoqi@0 215 bool is_interface () { return flags().is_interface(); }
aoqi@0 216 bool is_abstract () { return flags().is_abstract(); }
aoqi@0 217
aoqi@0 218 ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
aoqi@0 219 // Note: To find a method from name and type strings, use ciSymbol::make,
aoqi@0 220 // but consider adding to vmSymbols.hpp instead.
aoqi@0 221
aoqi@0 222 bool is_leaf_type();
aoqi@0 223 ciInstanceKlass* implementor();
aoqi@0 224
aoqi@0 225 // Is the defining class loader of this class the default loader?
aoqi@0 226 bool uses_default_loader() const;
aoqi@0 227
aoqi@0 228 bool is_java_lang_Object() const;
aoqi@0 229
aoqi@0 230 BasicType box_klass_type() const;
aoqi@0 231 bool is_box_klass() const;
aoqi@0 232 bool is_boxed_value_offset(int offset) const;
aoqi@0 233
aoqi@0 234 // Is this klass in the given package?
aoqi@0 235 bool is_in_package(const char* packagename) {
aoqi@0 236 return is_in_package(packagename, (int) strlen(packagename));
aoqi@0 237 }
aoqi@0 238 bool is_in_package(const char* packagename, int len);
aoqi@0 239
aoqi@0 240 // What kind of ciObject is this?
aoqi@0 241 bool is_instance_klass() const { return true; }
aoqi@0 242 bool is_java_klass() const { return true; }
aoqi@0 243
aoqi@0 244 virtual ciKlass* exact_klass() {
aoqi@0 245 if (is_loaded() && is_final() && !is_interface()) {
aoqi@0 246 return this;
aoqi@0 247 }
aoqi@0 248 return NULL;
aoqi@0 249 }
aoqi@0 250
aoqi@0 251 // Dump the current state of this klass for compilation replay.
aoqi@0 252 virtual void dump_replay_data(outputStream* out);
aoqi@0 253 };
aoqi@0 254
aoqi@0 255 #endif // SHARE_VM_CI_CIINSTANCEKLASS_HPP

mercurial