src/share/vm/prims/jvmtiRedefineClasses.cpp

changeset 9184
fbcbfd2753b5
parent 8720
6bed084fd02f
child 9203
53eec13fbaa5
child 9745
0e3d6188f198
equal deleted inserted replaced
9183:f95c67788f18 9184:fbcbfd2753b5
3433 cp_cache->adjust_method_entries(the_class, &trace_name_printed); 3433 cp_cache->adjust_method_entries(the_class, &trace_name_printed);
3434 } 3434 }
3435 } 3435 }
3436 3436
3437 // the previous versions' constant pool caches may need adjustment 3437 // the previous versions' constant pool caches may need adjustment
3438 PreviousVersionWalker pvw(_thread, ik); 3438 for (InstanceKlass* pv_node = ik->previous_versions();
3439 for (PreviousVersionNode * pv_node = pvw.next_previous_version(); 3439 pv_node != NULL;
3440 pv_node != NULL; pv_node = pvw.next_previous_version()) { 3440 pv_node = pv_node->previous_versions()) {
3441 other_cp = pv_node->prev_constant_pool(); 3441 cp_cache = pv_node->constants()->cache();
3442 cp_cache = other_cp->cache();
3443 if (cp_cache != NULL) { 3442 if (cp_cache != NULL) {
3444 cp_cache->adjust_method_entries(other_cp->pool_holder(), &trace_name_printed); 3443 cp_cache->adjust_method_entries(pv_node, &trace_name_printed);
3445 } 3444 }
3446 } 3445 }
3447 } 3446 }
3448 } 3447 }
3449 3448
3459 "should be replaced"); 3458 "should be replaced");
3460 } 3459 }
3461 } 3460 }
3462 } 3461 }
3463 3462
3464 void VM_RedefineClasses::check_methods_and_mark_as_obsolete( 3463 int VM_RedefineClasses::check_methods_and_mark_as_obsolete() {
3465 BitMap *emcp_methods, int * emcp_method_count_p) { 3464 int emcp_method_count = 0;
3466 *emcp_method_count_p = 0;
3467 int obsolete_count = 0; 3465 int obsolete_count = 0;
3468 int old_index = 0; 3466 int old_index = 0;
3469 for (int j = 0; j < _matching_methods_length; ++j, ++old_index) { 3467 for (int j = 0; j < _matching_methods_length; ++j, ++old_index) {
3470 Method* old_method = _matching_old_methods[j]; 3468 Method* old_method = _matching_old_methods[j];
3471 Method* new_method = _matching_new_methods[j]; 3469 Method* new_method = _matching_new_methods[j];
3535 // 3533 //
3536 // It looks like we will have to live with the limited savings 3534 // It looks like we will have to live with the limited savings
3537 // that we get from effectively overwriting the old methods 3535 // that we get from effectively overwriting the old methods
3538 // when the new methods are attached to the_class. 3536 // when the new methods are attached to the_class.
3539 3537
3540 // track which methods are EMCP for add_previous_version() call 3538 // Count number of methods that are EMCP. The method will be marked
3541 emcp_methods->set_bit(old_index); 3539 // old but not obsolete if it is EMCP.
3542 (*emcp_method_count_p)++; 3540 emcp_method_count++;
3543 3541
3544 // An EMCP method is _not_ obsolete. An obsolete method has a 3542 // An EMCP method is _not_ obsolete. An obsolete method has a
3545 // different jmethodID than the current method. An EMCP method 3543 // different jmethodID than the current method. An EMCP method
3546 // has the same jmethodID as the current method. Having the 3544 // has the same jmethodID as the current method. Having the
3547 // same jmethodID for all EMCP versions of a method allows for 3545 // same jmethodID for all EMCP versions of a method allows for
3587 // EMCP methods. 3585 // EMCP methods.
3588 RC_TRACE(0x00000100, ("mark deleted %s(%s) as obsolete", 3586 RC_TRACE(0x00000100, ("mark deleted %s(%s) as obsolete",
3589 old_method->name()->as_C_string(), 3587 old_method->name()->as_C_string(),
3590 old_method->signature()->as_C_string())); 3588 old_method->signature()->as_C_string()));
3591 } 3589 }
3592 assert((*emcp_method_count_p + obsolete_count) == _old_methods->length(), 3590 assert((emcp_method_count + obsolete_count) == _old_methods->length(),
3593 "sanity check"); 3591 "sanity check");
3594 RC_TRACE(0x00000100, ("EMCP_cnt=%d, obsolete_cnt=%d", *emcp_method_count_p, 3592 RC_TRACE(0x00000100, ("EMCP_cnt=%d, obsolete_cnt=%d", emcp_method_count,
3595 obsolete_count)); 3593 obsolete_count));
3594 return emcp_method_count;
3596 } 3595 }
3597 3596
3598 // This internal class transfers the native function registration from old methods 3597 // This internal class transfers the native function registration from old methods
3599 // to new methods. It is designed to handle both the simple case of unchanged 3598 // to new methods. It is designed to handle both the simple case of unchanged
3600 // native methods and the complex cases of native method prefixes being added and/or 3599 // native methods and the complex cases of native method prefixes being added and/or
3971 // vtable's class and "the new class". 3970 // vtable's class and "the new class".
3972 3971
3973 old_constants->set_pool_holder(scratch_class()); 3972 old_constants->set_pool_holder(scratch_class());
3974 #endif 3973 #endif
3975 3974
3976 // track which methods are EMCP for add_previous_version() call below 3975 // track number of methods that are EMCP for add_previous_version() call below
3977 BitMap emcp_methods(_old_methods->length()); 3976 int emcp_method_count = check_methods_and_mark_as_obsolete();
3978 int emcp_method_count = 0;
3979 emcp_methods.clear(); // clears 0..(length() - 1)
3980 check_methods_and_mark_as_obsolete(&emcp_methods, &emcp_method_count);
3981 transfer_old_native_function_registrations(the_class); 3977 transfer_old_native_function_registrations(the_class);
3982 3978
3983 // The class file bytes from before any retransformable agents mucked 3979 // The class file bytes from before any retransformable agents mucked
3984 // with them was cached on the scratch class, move to the_class. 3980 // with them was cached on the scratch class, move to the_class.
3985 // Note: we still want to do this if nothing needed caching since it 3981 // Note: we still want to do this if nothing needed caching since it
4062 the_class->set_enclosing_method_indices( 4058 the_class->set_enclosing_method_indices(
4063 scratch_class->enclosing_method_class_index(), 4059 scratch_class->enclosing_method_class_index(),
4064 scratch_class->enclosing_method_method_index()); 4060 scratch_class->enclosing_method_method_index());
4065 scratch_class->set_enclosing_method_indices(old_class_idx, old_method_idx); 4061 scratch_class->set_enclosing_method_indices(old_class_idx, old_method_idx);
4066 4062
4063 the_class->set_has_been_redefined();
4064
4067 // keep track of previous versions of this class 4065 // keep track of previous versions of this class
4068 the_class->add_previous_version(scratch_class, &emcp_methods, 4066 the_class->add_previous_version(scratch_class, emcp_method_count);
4069 emcp_method_count);
4070 4067
4071 RC_TIMER_STOP(_timer_rsc_phase1); 4068 RC_TIMER_STOP(_timer_rsc_phase1);
4072 RC_TIMER_START(_timer_rsc_phase2); 4069 RC_TIMER_START(_timer_rsc_phase2);
4073 4070
4074 // Adjust constantpool caches and vtables for all classes 4071 // Adjust constantpool caches and vtables for all classes

mercurial