src/share/vm/prims/jvmtiRedefineClasses.cpp

Print this page




3416     // updated. We can simply start with the previous version(s) in
3417     // that case.
3418     constantPoolHandle other_cp;
3419     ConstantPoolCache* cp_cache;
3420 
3421     if (ik != _the_class_oop) {
3422       // this klass' constant pool cache may need adjustment
3423       other_cp = constantPoolHandle(ik->constants());
3424       cp_cache = other_cp->cache();
3425       if (cp_cache != NULL) {
3426         cp_cache->adjust_method_entries(the_class, &trace_name_printed);
3427       }
3428     }
3429 
3430     // the previous versions' constant pool caches may need adjustment
3431     for (InstanceKlass* pv_node = ik->previous_versions();
3432          pv_node != NULL;
3433          pv_node = pv_node->previous_versions()) {
3434       cp_cache = pv_node->constants()->cache();
3435       if (cp_cache != NULL) {
3436         cp_cache->adjust_method_entries(_matching_old_methods,
3437                                         _matching_new_methods,
3438                                         _matching_methods_length,
3439                                         &trace_name_printed);
3440       }
3441     }
3442   }
3443 }
3444 
3445 // Clean method data for this class
3446 void VM_RedefineClasses::MethodDataCleaner::do_klass(Klass* k) {
3447   if (k->oop_is_instance()) {
3448     InstanceKlass *ik = InstanceKlass::cast(k);
3449     // Clean MethodData of this class's methods so they don't refer to
3450     // old methods that are no longer running.
3451     Array<Method*>* methods = ik->methods();
3452     int num_methods = methods->length();
3453     for (int index = 0; index < num_methods; ++index) {
3454       if (methods->at(index)->method_data() != NULL) {
3455         methods->at(index)->method_data()->clean_weak_method_links();
3456       }
3457     }
3458   }
3459 }


4069     scratch_class->enclosing_method_method_index());
4070   scratch_class->set_enclosing_method_indices(old_class_idx, old_method_idx);
4071 
4072   the_class->set_has_been_redefined();
4073 
4074   // keep track of previous versions of this class
4075   the_class->add_previous_version(scratch_class, emcp_method_count);
4076 
4077   RC_TIMER_STOP(_timer_rsc_phase1);
4078   RC_TIMER_START(_timer_rsc_phase2);
4079 
4080   // Adjust constantpool caches and vtables for all classes
4081   // that reference methods of the evolved class.
4082   AdjustCpoolCacheAndVtable adjust_cpool_cache_and_vtable(THREAD);
4083   ClassLoaderDataGraph::classes_do(&adjust_cpool_cache_and_vtable);
4084 
4085   // JSR-292 support
4086   MemberNameTable* mnt = the_class->member_names();
4087   if (mnt != NULL) {
4088     bool trace_name_printed = false;
4089     mnt->adjust_method_entries(_matching_old_methods,
4090                                _matching_new_methods,
4091                                _matching_methods_length,
4092                                &trace_name_printed);
4093   }
4094 
4095   // Fix Resolution Error table also to remove old constant pools
4096   SystemDictionary::delete_resolution_error(old_constants);
4097 
4098   if (the_class->oop_map_cache() != NULL) {
4099     // Flush references to any obsolete methods from the oop map cache
4100     // so that obsolete methods are not pinned.
4101     the_class->oop_map_cache()->flush_obsolete_entries();
4102   }
4103 
4104   // increment the classRedefinedCount field in the_class and in any
4105   // direct and indirect subclasses of the_class
4106   increment_class_counter((InstanceKlass *)the_class(), THREAD);
4107 
4108   // RC_TRACE macro has an embedded ResourceMark
4109   RC_TRACE_WITH_THREAD(0x00000001, THREAD,
4110     ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
4111     the_class->external_name(),
4112     java_lang_Class::classRedefinedCount(the_class_mirror),




3416     // updated. We can simply start with the previous version(s) in
3417     // that case.
3418     constantPoolHandle other_cp;
3419     ConstantPoolCache* cp_cache;
3420 
3421     if (ik != _the_class_oop) {
3422       // this klass' constant pool cache may need adjustment
3423       other_cp = constantPoolHandle(ik->constants());
3424       cp_cache = other_cp->cache();
3425       if (cp_cache != NULL) {
3426         cp_cache->adjust_method_entries(the_class, &trace_name_printed);
3427       }
3428     }
3429 
3430     // the previous versions' constant pool caches may need adjustment
3431     for (InstanceKlass* pv_node = ik->previous_versions();
3432          pv_node != NULL;
3433          pv_node = pv_node->previous_versions()) {
3434       cp_cache = pv_node->constants()->cache();
3435       if (cp_cache != NULL) {
3436         cp_cache->adjust_method_entries(pv_node, &trace_name_printed);



3437       }
3438     }
3439   }
3440 }
3441 
3442 // Clean method data for this class
3443 void VM_RedefineClasses::MethodDataCleaner::do_klass(Klass* k) {
3444   if (k->oop_is_instance()) {
3445     InstanceKlass *ik = InstanceKlass::cast(k);
3446     // Clean MethodData of this class's methods so they don't refer to
3447     // old methods that are no longer running.
3448     Array<Method*>* methods = ik->methods();
3449     int num_methods = methods->length();
3450     for (int index = 0; index < num_methods; ++index) {
3451       if (methods->at(index)->method_data() != NULL) {
3452         methods->at(index)->method_data()->clean_weak_method_links();
3453       }
3454     }
3455   }
3456 }


4066     scratch_class->enclosing_method_method_index());
4067   scratch_class->set_enclosing_method_indices(old_class_idx, old_method_idx);
4068 
4069   the_class->set_has_been_redefined();
4070 
4071   // keep track of previous versions of this class
4072   the_class->add_previous_version(scratch_class, emcp_method_count);
4073 
4074   RC_TIMER_STOP(_timer_rsc_phase1);
4075   RC_TIMER_START(_timer_rsc_phase2);
4076 
4077   // Adjust constantpool caches and vtables for all classes
4078   // that reference methods of the evolved class.
4079   AdjustCpoolCacheAndVtable adjust_cpool_cache_and_vtable(THREAD);
4080   ClassLoaderDataGraph::classes_do(&adjust_cpool_cache_and_vtable);
4081 
4082   // JSR-292 support
4083   MemberNameTable* mnt = the_class->member_names();
4084   if (mnt != NULL) {
4085     bool trace_name_printed = false;
4086     mnt->adjust_method_entries(the_class(), &trace_name_printed);



4087   }
4088 
4089   // Fix Resolution Error table also to remove old constant pools
4090   SystemDictionary::delete_resolution_error(old_constants);
4091 
4092   if (the_class->oop_map_cache() != NULL) {
4093     // Flush references to any obsolete methods from the oop map cache
4094     // so that obsolete methods are not pinned.
4095     the_class->oop_map_cache()->flush_obsolete_entries();
4096   }
4097 
4098   // increment the classRedefinedCount field in the_class and in any
4099   // direct and indirect subclasses of the_class
4100   increment_class_counter((InstanceKlass *)the_class(), THREAD);
4101 
4102   // RC_TRACE macro has an embedded ResourceMark
4103   RC_TRACE_WITH_THREAD(0x00000001, THREAD,
4104     ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
4105     the_class->external_name(),
4106     java_lang_Class::classRedefinedCount(the_class_mirror),