src/share/vm/ci/ciInstanceKlass.hpp

Mon, 12 Nov 2012 14:03:53 -0800

author
minqi
date
Mon, 12 Nov 2012 14:03:53 -0800
changeset 4267
bd7a7ce2e264
parent 4037
da91efe96a93
child 5110
6f3fd5150b67
permissions
-rw-r--r--

6830717: replay of compilations would help with debugging
Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method.
Reviewed-by: kvn, twisti, sspitsyn
Contributed-by: yumin.qi@oracle.com

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

mercurial