comparison src/share/vm/oops/instanceKlass.cpp @ 11173:6b0fd0964b87

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 31 Jul 2013 11:00:54 +0200
parents 836a62f43af9 825e6cb66923
children cefad50507d8
comparison
equal deleted inserted replaced
10912:4ea54634f03e 11173:6b0fd0964b87
46 #include "oops/method.hpp" 46 #include "oops/method.hpp"
47 #include "oops/oop.inline.hpp" 47 #include "oops/oop.inline.hpp"
48 #include "oops/symbol.hpp" 48 #include "oops/symbol.hpp"
49 #include "prims/jvmtiExport.hpp" 49 #include "prims/jvmtiExport.hpp"
50 #include "prims/jvmtiRedefineClassesTrace.hpp" 50 #include "prims/jvmtiRedefineClassesTrace.hpp"
51 #include "prims/jvmtiRedefineClasses.hpp"
51 #include "prims/methodComparator.hpp" 52 #include "prims/methodComparator.hpp"
52 #include "runtime/fieldDescriptor.hpp" 53 #include "runtime/fieldDescriptor.hpp"
53 #include "runtime/handles.inline.hpp" 54 #include "runtime/handles.inline.hpp"
54 #include "runtime/javaCalls.hpp" 55 #include "runtime/javaCalls.hpp"
55 #include "runtime/mutexLocker.hpp" 56 #include "runtime/mutexLocker.hpp"
289 set_annotations(NULL); 290 set_annotations(NULL);
290 set_jvmti_cached_class_field_map(NULL); 291 set_jvmti_cached_class_field_map(NULL);
291 set_initial_method_idnum(0); 292 set_initial_method_idnum(0);
292 _dependencies = NULL; 293 _dependencies = NULL;
293 set_jvmti_cached_class_field_map(NULL); 294 set_jvmti_cached_class_field_map(NULL);
294 set_cached_class_file(NULL, 0); 295 set_cached_class_file(NULL);
295 set_initial_method_idnum(0); 296 set_initial_method_idnum(0);
296 set_minor_version(0); 297 set_minor_version(0);
297 set_major_version(0); 298 set_major_version(0);
298 NOT_PRODUCT(_verify_count = 0;) 299 NOT_PRODUCT(_verify_count = 0;)
299 300
1317 } 1318 }
1318 1319
1319 void InstanceKlass::array_klasses_do(void f(Klass* k)) { 1320 void InstanceKlass::array_klasses_do(void f(Klass* k)) {
1320 if (array_klasses() != NULL) 1321 if (array_klasses() != NULL)
1321 ArrayKlass::cast(array_klasses())->array_klasses_do(f); 1322 ArrayKlass::cast(array_klasses())->array_klasses_do(f);
1322 }
1323
1324
1325 void InstanceKlass::with_array_klasses_do(void f(Klass* k)) {
1326 f(this);
1327 array_klasses_do(f);
1328 } 1323 }
1329 1324
1330 #ifdef ASSERT 1325 #ifdef ASSERT
1331 static int linear_search(Array<Method*>* methods, Symbol* name, Symbol* signature) { 1326 static int linear_search(Array<Method*>* methods, Symbol* name, Symbol* signature) {
1332 int len = methods->length(); 1327 int len = methods->length();
2361 delete _previous_versions; 2356 delete _previous_versions;
2362 _previous_versions = NULL; 2357 _previous_versions = NULL;
2363 } 2358 }
2364 2359
2365 // deallocate the cached class file 2360 // deallocate the cached class file
2366 if (_cached_class_file_bytes != NULL) { 2361 if (_cached_class_file != NULL) {
2367 os::free(_cached_class_file_bytes, mtClass); 2362 os::free(_cached_class_file, mtClass);
2368 _cached_class_file_bytes = NULL; 2363 _cached_class_file = NULL;
2369 _cached_class_file_len = 0;
2370 } 2364 }
2371 2365
2372 // Decrement symbol reference counts associated with the unloaded class. 2366 // Decrement symbol reference counts associated with the unloaded class.
2373 if (_name != NULL) _name->decrement_refcount(); 2367 if (_name != NULL) _name->decrement_refcount();
2374 // unreference array name derived from this class name (arrays of an unloaded 2368 // unreference array name derived from this class name (arrays of an unloaded
3086 public: 3080 public:
3087 virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); } 3081 virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); }
3088 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } 3082 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); }
3089 }; 3083 };
3090 3084
3091 void InstanceKlass::verify_on(outputStream* st) { 3085 void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) {
3092 Klass::verify_on(st);
3093 Thread *thread = Thread::current();
3094
3095 #ifndef PRODUCT 3086 #ifndef PRODUCT
3096 // Avoid redundant verifies 3087 // Avoid redundant verifies, this really should be in product.
3097 if (_verify_count == Universe::verify_count()) return; 3088 if (_verify_count == Universe::verify_count()) return;
3098 _verify_count = Universe::verify_count(); 3089 _verify_count = Universe::verify_count();
3099 #endif 3090 #endif
3100 // Verify that klass is present in SystemDictionary 3091
3101 if (is_loaded() && !is_anonymous()) { 3092 // Verify Klass
3093 Klass::verify_on(st, check_dictionary);
3094
3095 // Verify that klass is present in SystemDictionary if not already
3096 // verifying the SystemDictionary.
3097 if (is_loaded() && !is_anonymous() && check_dictionary) {
3102 Symbol* h_name = name(); 3098 Symbol* h_name = name();
3103 SystemDictionary::verify_obj_klass_present(h_name, class_loader_data()); 3099 SystemDictionary::verify_obj_klass_present(h_name, class_loader_data());
3104 } 3100 }
3105 3101
3106 // Verify static fields
3107 VerifyFieldClosure blk;
3108
3109 // Verify vtables 3102 // Verify vtables
3110 if (is_linked()) { 3103 if (is_linked()) {
3111 ResourceMark rm(thread); 3104 ResourceMark rm;
3112 // $$$ This used to be done only for m/s collections. Doing it 3105 // $$$ This used to be done only for m/s collections. Doing it
3113 // always seemed a valid generalization. (DLD -- 6/00) 3106 // always seemed a valid generalization. (DLD -- 6/00)
3114 vtable()->verify(st); 3107 vtable()->verify(st);
3115 } 3108 }
3116 3109
3117 // Verify first subklass 3110 // Verify first subklass
3118 if (subklass_oop() != NULL) { 3111 if (subklass_oop() != NULL) {
3119 guarantee(subklass_oop()->is_metadata(), "should be in metaspace");
3120 guarantee(subklass_oop()->is_klass(), "should be klass"); 3112 guarantee(subklass_oop()->is_klass(), "should be klass");
3121 } 3113 }
3122 3114
3123 // Verify siblings 3115 // Verify siblings
3124 Klass* super = this->super(); 3116 Klass* super = this->super();
3126 if (sib != NULL) { 3118 if (sib != NULL) {
3127 if (sib == this) { 3119 if (sib == this) {
3128 fatal(err_msg("subclass points to itself " PTR_FORMAT, sib)); 3120 fatal(err_msg("subclass points to itself " PTR_FORMAT, sib));
3129 } 3121 }
3130 3122
3131 guarantee(sib->is_metadata(), "should be in metaspace");
3132 guarantee(sib->is_klass(), "should be klass"); 3123 guarantee(sib->is_klass(), "should be klass");
3133 guarantee(sib->super() == super, "siblings should have same superklass"); 3124 guarantee(sib->super() == super, "siblings should have same superklass");
3134 } 3125 }
3135 3126
3136 // Verify implementor fields 3127 // Verify implementor fields
3162 3153
3163 // Verify methods 3154 // Verify methods
3164 if (methods() != NULL) { 3155 if (methods() != NULL) {
3165 Array<Method*>* methods = this->methods(); 3156 Array<Method*>* methods = this->methods();
3166 for (int j = 0; j < methods->length(); j++) { 3157 for (int j = 0; j < methods->length(); j++) {
3167 guarantee(methods->at(j)->is_metadata(), "should be in metaspace");
3168 guarantee(methods->at(j)->is_method(), "non-method in methods array"); 3158 guarantee(methods->at(j)->is_method(), "non-method in methods array");
3169 } 3159 }
3170 for (int j = 0; j < methods->length() - 1; j++) { 3160 for (int j = 0; j < methods->length() - 1; j++) {
3171 Method* m1 = methods->at(j); 3161 Method* m1 = methods->at(j);
3172 Method* m2 = methods->at(j + 1); 3162 Method* m2 = methods->at(j + 1);
3200 jni_ids()->verify(this); 3190 jni_ids()->verify(this);
3201 } 3191 }
3202 3192
3203 // Verify other fields 3193 // Verify other fields
3204 if (array_klasses() != NULL) { 3194 if (array_klasses() != NULL) {
3205 guarantee(array_klasses()->is_metadata(), "should be in metaspace");
3206 guarantee(array_klasses()->is_klass(), "should be klass"); 3195 guarantee(array_klasses()->is_klass(), "should be klass");
3207 } 3196 }
3208 if (constants() != NULL) { 3197 if (constants() != NULL) {
3209 guarantee(constants()->is_metadata(), "should be in metaspace");
3210 guarantee(constants()->is_constantPool(), "should be constant pool"); 3198 guarantee(constants()->is_constantPool(), "should be constant pool");
3211 } 3199 }
3212 const Klass* host = host_klass(); 3200 const Klass* host = host_klass();
3213 if (host != NULL) { 3201 if (host != NULL) {
3214 guarantee(host->is_metadata(), "should be in metaspace");
3215 guarantee(host->is_klass(), "should be klass"); 3202 guarantee(host->is_klass(), "should be klass");
3216 } 3203 }
3217 } 3204 }
3218 3205
3219 void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { 3206 void InstanceKlass::oop_verify_on(oop obj, outputStream* st) {
3541 } 3528 }
3542 } 3529 }
3543 return m; 3530 return m;
3544 } 3531 }
3545 3532
3533 jint InstanceKlass::get_cached_class_file_len() {
3534 return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file);
3535 }
3536
3537 unsigned char * InstanceKlass::get_cached_class_file_bytes() {
3538 return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file);
3539 }
3540
3546 3541
3547 // Construct a PreviousVersionNode entry for the array hung off 3542 // Construct a PreviousVersionNode entry for the array hung off
3548 // the InstanceKlass. 3543 // the InstanceKlass.
3549 PreviousVersionNode::PreviousVersionNode(ConstantPool* prev_constant_pool, 3544 PreviousVersionNode::PreviousVersionNode(ConstantPool* prev_constant_pool,
3550 bool prev_cp_is_weak, GrowableArray<Method*>* prev_EMCP_methods) { 3545 bool prev_cp_is_weak, GrowableArray<Method*>* prev_EMCP_methods) {