50 Array<Method*>* VM_RedefineClasses::_new_methods = NULL;
51 Method** VM_RedefineClasses::_matching_old_methods = NULL;
52 Method** VM_RedefineClasses::_matching_new_methods = NULL;
53 Method** VM_RedefineClasses::_deleted_methods = NULL;
54 Method** VM_RedefineClasses::_added_methods = NULL;
55 int VM_RedefineClasses::_matching_methods_length = 0;
56 int VM_RedefineClasses::_deleted_methods_length = 0;
57 int VM_RedefineClasses::_added_methods_length = 0;
58 Klass* VM_RedefineClasses::_the_class_oop = NULL;
59
60
61 VM_RedefineClasses::VM_RedefineClasses(jint class_count,
62 const jvmtiClassDefinition *class_defs,
63 JvmtiClassLoadKind class_load_kind) {
64 _class_count = class_count;
65 _class_defs = class_defs;
66 _class_load_kind = class_load_kind;
67 _res = JVMTI_ERROR_NONE;
68 }
69
70 bool VM_RedefineClasses::doit_prologue() {
71 if (_class_count == 0) {
72 _res = JVMTI_ERROR_NONE;
73 return false;
74 }
75 if (_class_defs == NULL) {
76 _res = JVMTI_ERROR_NULL_POINTER;
77 return false;
78 }
79 for (int i = 0; i < _class_count; i++) {
80 if (_class_defs[i].klass == NULL) {
81 _res = JVMTI_ERROR_INVALID_CLASS;
82 return false;
83 }
84 if (_class_defs[i].class_byte_count == 0) {
85 _res = JVMTI_ERROR_INVALID_CLASS_FORMAT;
86 return false;
87 }
88 if (_class_defs[i].class_bytes == NULL) {
89 _res = JVMTI_ERROR_NULL_POINTER;
90 return false;
91 }
92 }
93
94 // Start timer after all the sanity checks; not quite accurate, but
95 // better than adding a bunch of stop() calls.
96 RC_TIMER_START(_timer_vm_op_prologue);
97
98 // We first load new class versions in the prologue, because somewhere down the
99 // call chain it is required that the current thread is a Java thread.
100 _res = load_new_class_versions(Thread::current());
101 if (_res != JVMTI_ERROR_NONE) {
102 // free any successfully created classes, since none are redefined
103 for (int i = 0; i < _class_count; i++) {
104 if (_scratch_classes[i] != NULL) {
105 ClassLoaderData* cld = _scratch_classes[i]->class_loader_data();
106 // Free the memory for this class at class unloading time. Not before
107 // because CMS might think this is still live.
108 cld->add_to_deallocate_list((InstanceKlass*)_scratch_classes[i]);
109 }
110 }
111 // Free os::malloc allocated memory in load_new_class_version.
112 os::free(_scratch_classes);
113 RC_TIMER_STOP(_timer_vm_op_prologue);
114 return false;
115 }
116
117 RC_TIMER_STOP(_timer_vm_op_prologue);
118 return true;
119 }
120
121 void VM_RedefineClasses::doit() {
122 Thread *thread = Thread::current();
123
124 if (UseSharedSpaces) {
125 // Sharing is enabled so we remap the shared readonly space to
126 // shared readwrite, private just in case we need to redefine
127 // a shared class. We do the remap during the doit() phase of
128 // the safepoint to be safer.
129 if (!MetaspaceShared::remap_shared_readonly_as_readwrite()) {
130 RC_TRACE_WITH_THREAD(0x00000001, thread,
131 ("failed to remap shared readonly space to readwrite, private"));
132 _res = JVMTI_ERROR_INTERNAL;
133 return;
153 SystemDictionary::notice_modification();
154
155 // Set flag indicating that some invariants are no longer true.
156 // See jvmtiExport.hpp for detailed explanation.
157 JvmtiExport::set_has_redefined_a_class();
158
159 // check_class() is optionally called for product bits, but is
160 // always called for non-product bits.
161 #ifdef PRODUCT
162 if (RC_TRACE_ENABLED(0x00004000)) {
163 #endif
164 RC_TRACE_WITH_THREAD(0x00004000, thread, ("calling check_class"));
165 CheckClass check_class(thread);
166 ClassLoaderDataGraph::classes_do(&check_class);
167 #ifdef PRODUCT
168 }
169 #endif
170 }
171
172 void VM_RedefineClasses::doit_epilogue() {
173 // Free os::malloc allocated memory.
174 os::free(_scratch_classes);
175
176 // Reset the_class_oop to null for error printing.
177 _the_class_oop = NULL;
178
179 if (RC_TRACE_ENABLED(0x00000004)) {
180 // Used to have separate timers for "doit" and "all", but the timer
181 // overhead skewed the measurements.
182 jlong doit_time = _timer_rsc_phase1.milliseconds() +
183 _timer_rsc_phase2.milliseconds();
184 jlong all_time = _timer_vm_op_prologue.milliseconds() + doit_time;
185
186 RC_TRACE(0x00000004, ("vm_op: all=" UINT64_FORMAT
187 " prologue=" UINT64_FORMAT " doit=" UINT64_FORMAT, all_time,
188 _timer_vm_op_prologue.milliseconds(), doit_time));
189 RC_TRACE(0x00000004,
190 ("redefine_single_class: phase1=" UINT64_FORMAT " phase2=" UINT64_FORMAT,
191 _timer_rsc_phase1.milliseconds(), _timer_rsc_phase2.milliseconds()));
192 }
944 os::malloc(sizeof(Klass*) * _class_count, mtClass);
945 if (_scratch_classes == NULL) {
946 return JVMTI_ERROR_OUT_OF_MEMORY;
947 }
948 // Zero initialize the _scratch_classes array.
949 for (int i = 0; i < _class_count; i++) {
950 _scratch_classes[i] = NULL;
951 }
952
953 ResourceMark rm(THREAD);
954
955 JvmtiThreadState *state = JvmtiThreadState::state_for(JavaThread::current());
956 // state can only be NULL if the current thread is exiting which
957 // should not happen since we're trying to do a RedefineClasses
958 guarantee(state != NULL, "exiting thread calling load_new_class_versions");
959 for (int i = 0; i < _class_count; i++) {
960 // Create HandleMark so that any handles created while loading new class
961 // versions are deleted. Constant pools are deallocated while merging
962 // constant pools
963 HandleMark hm(THREAD);
964
965 oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass);
966 // classes for primitives cannot be redefined
967 if (!is_modifiable_class(mirror)) {
968 return JVMTI_ERROR_UNMODIFIABLE_CLASS;
969 }
970 Klass* the_class_oop = java_lang_Class::as_Klass(mirror);
971 instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop);
972 Symbol* the_class_sym = the_class->name();
973
974 // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
975 RC_TRACE_WITH_THREAD(0x00000001, THREAD,
976 ("loading name=%s kind=%d (avail_mem=" UINT64_FORMAT "K)",
977 the_class->external_name(), _class_load_kind,
978 os::available_memory() >> 10));
979
980 ClassFileStream st((u1*) _class_defs[i].class_bytes,
981 _class_defs[i].class_byte_count, (char *)"__VM_RedefineClasses__");
982
983 // Parse the stream.
984 Handle the_class_loader(THREAD, the_class->class_loader());
985 Handle protection_domain(THREAD, the_class->protection_domain());
986 // Set redefined class handle in JvmtiThreadState class.
987 // This redefined class is sent to agent event handler for class file
988 // load hook event.
989 state->set_class_being_redefined(&the_class, _class_load_kind);
990
991 Klass* k = SystemDictionary::parse_stream(the_class_sym,
3838
3839
3840 // Install the redefinition of a class:
3841 // - house keeping (flushing breakpoints and caches, deoptimizing
3842 // dependent compiled code)
3843 // - replacing parts in the_class with parts from scratch_class
3844 // - adding a weak reference to track the obsolete but interesting
3845 // parts of the_class
3846 // - adjusting constant pool caches and vtables in other classes
3847 // that refer to methods in the_class. These adjustments use the
3848 // ClassLoaderDataGraph::classes_do() facility which only allows
3849 // a helper method to be specified. The interesting parameters
3850 // that we would like to pass to the helper method are saved in
3851 // static global fields in the VM operation.
3852 void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
3853 Klass* scratch_class_oop, TRAPS) {
3854
3855 HandleMark hm(THREAD); // make sure handles from this call are freed
3856 RC_TIMER_START(_timer_rsc_phase1);
3857
3858 instanceKlassHandle scratch_class(scratch_class_oop);
3859
3860 oop the_class_mirror = JNIHandles::resolve_non_null(the_jclass);
3861 Klass* the_class_oop = java_lang_Class::as_Klass(the_class_mirror);
3862 instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop);
3863
3864 // Remove all breakpoints in methods of this class
3865 JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints();
3866 jvmti_breakpoints.clearall_in_class_at_safepoint(the_class_oop);
3867
3868 // Deoptimize all compiled code that depends on this class
3869 flush_dependent_code(the_class, THREAD);
3870
3871 _old_methods = the_class->methods();
3872 _new_methods = scratch_class->methods();
3873 _the_class_oop = the_class_oop;
3874 compute_added_deleted_matching_methods();
3875 update_jmethod_ids();
3876
3877 // Attach new constant pool to the original klass. The original
3878 // klass still refers to the old constant pool (for now).
3879 scratch_class->constants()->set_pool_holder(the_class());
3880
3881 #if 0
3882 // In theory, with constant pool merging in place we should be able
3883 // to save space by using the new, merged constant pool in place of
3884 // the old constant pool(s). By "pool(s)" I mean the constant pool in
3885 // the klass version we are replacing now and any constant pool(s) in
3886 // previous versions of klass. Nice theory, doesn't work in practice.
3887 // When this code is enabled, even simple programs throw NullPointer
3888 // exceptions. I'm guessing that this is caused by some constant pool
3889 // cache difference between the new, merged constant pool and the
3890 // constant pool that was just being used by the klass. I'm keeping
3891 // this code around to archive the idea, but the code has to remain
3892 // disabled for now.
3893
4077 MemberNameTable* mnt = the_class->member_names();
4078 if (mnt != NULL) {
4079 bool trace_name_printed = false;
4080 mnt->adjust_method_entries(the_class(), &trace_name_printed);
4081 }
4082
4083 if (the_class->oop_map_cache() != NULL) {
4084 // Flush references to any obsolete methods from the oop map cache
4085 // so that obsolete methods are not pinned.
4086 the_class->oop_map_cache()->flush_obsolete_entries();
4087 }
4088
4089 // increment the classRedefinedCount field in the_class and in any
4090 // direct and indirect subclasses of the_class
4091 increment_class_counter((InstanceKlass *)the_class(), THREAD);
4092
4093 // RC_TRACE macro has an embedded ResourceMark
4094 RC_TRACE_WITH_THREAD(0x00000001, THREAD,
4095 ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
4096 the_class->external_name(),
4097 java_lang_Class::classRedefinedCount(the_class_mirror),
4098 os::available_memory() >> 10));
4099
4100 {
4101 ResourceMark rm(THREAD);
4102 Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
4103 the_class->external_name(),
4104 java_lang_Class::classRedefinedCount(the_class_mirror));
4105
4106 }
4107 RC_TIMER_STOP(_timer_rsc_phase2);
4108 } // end redefine_single_class()
4109
4110
4111 // Increment the classRedefinedCount field in the specific InstanceKlass
4112 // and in all direct and indirect subclasses.
4113 void VM_RedefineClasses::increment_class_counter(InstanceKlass *ik, TRAPS) {
4114 oop class_mirror = ik->java_mirror();
4115 Klass* class_oop = java_lang_Class::as_Klass(class_mirror);
4116 int new_count = java_lang_Class::classRedefinedCount(class_mirror) + 1;
4117 java_lang_Class::set_classRedefinedCount(class_mirror, new_count);
4118
4119 if (class_oop != _the_class_oop) {
4120 // _the_class_oop count is printed at end of redefine_single_class()
4121 RC_TRACE_WITH_THREAD(0x00000008, THREAD,
4122 ("updated count in subclass=%s to %d", ik->external_name(), new_count));
4123 }
4124
|
50 Array<Method*>* VM_RedefineClasses::_new_methods = NULL;
51 Method** VM_RedefineClasses::_matching_old_methods = NULL;
52 Method** VM_RedefineClasses::_matching_new_methods = NULL;
53 Method** VM_RedefineClasses::_deleted_methods = NULL;
54 Method** VM_RedefineClasses::_added_methods = NULL;
55 int VM_RedefineClasses::_matching_methods_length = 0;
56 int VM_RedefineClasses::_deleted_methods_length = 0;
57 int VM_RedefineClasses::_added_methods_length = 0;
58 Klass* VM_RedefineClasses::_the_class_oop = NULL;
59
60
61 VM_RedefineClasses::VM_RedefineClasses(jint class_count,
62 const jvmtiClassDefinition *class_defs,
63 JvmtiClassLoadKind class_load_kind) {
64 _class_count = class_count;
65 _class_defs = class_defs;
66 _class_load_kind = class_load_kind;
67 _res = JVMTI_ERROR_NONE;
68 }
69
70 static inline InstanceKlass* get_ik(jclass def) {
71 oop mirror = JNIHandles::resolve_non_null(def);
72 return InstanceKlass::cast(java_lang_Class::as_Klass(mirror));
73 }
74
75 // If any of the classes are being redefined, wait
76 // Parallel constant pool merging leads to indeterminate constant pools.
77 void VM_RedefineClasses::lock_classes() {
78 MutexLocker ml(RedefineClasses_lock);
79 bool has_redefined;
80 do {
81 has_redefined = false;
82 // Go through classes each time until none are being redefined.
83 for (int i = 0; i < _class_count; i++) {
84 if (get_ik(_class_defs[i].klass)->is_being_redefined()) {
85 RedefineClasses_lock->wait();
86 has_redefined = true;
87 break; // for loop
88 }
89 }
90 } while (has_redefined);
91 for (int i = 0; i < _class_count; i++) {
92 get_ik(_class_defs[i].klass)->set_is_being_redefined(true);
93 }
94 RedefineClasses_lock->notify_all();
95 }
96
97 void VM_RedefineClasses::unlock_classes() {
98 MutexLocker ml(RedefineClasses_lock);
99 for (int i = 0; i < _class_count; i++) {
100 assert(get_ik(_class_defs[i].klass)->is_being_redefined(),
101 "should be being redefined to get here");
102 get_ik(_class_defs[i].klass)->set_is_being_redefined(false);
103 }
104 RedefineClasses_lock->notify_all();
105 }
106
107 bool VM_RedefineClasses::doit_prologue() {
108 if (_class_count == 0) {
109 _res = JVMTI_ERROR_NONE;
110 return false;
111 }
112 if (_class_defs == NULL) {
113 _res = JVMTI_ERROR_NULL_POINTER;
114 return false;
115 }
116 for (int i = 0; i < _class_count; i++) {
117 if (_class_defs[i].klass == NULL) {
118 _res = JVMTI_ERROR_INVALID_CLASS;
119 return false;
120 }
121 if (_class_defs[i].class_byte_count == 0) {
122 _res = JVMTI_ERROR_INVALID_CLASS_FORMAT;
123 return false;
124 }
125 if (_class_defs[i].class_bytes == NULL) {
126 _res = JVMTI_ERROR_NULL_POINTER;
127 return false;
128 }
129
130 oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass);
131 // classes for primitives and arrays cannot be redefined
132 // check here so following code can assume these classes are InstanceKlass
133 if (!is_modifiable_class(mirror)) {
134 _res = JVMTI_ERROR_UNMODIFIABLE_CLASS;
135 return false;
136 }
137 }
138
139 // Start timer after all the sanity checks; not quite accurate, but
140 // better than adding a bunch of stop() calls.
141 RC_TIMER_START(_timer_vm_op_prologue);
142
143 lock_classes();
144 // We first load new class versions in the prologue, because somewhere down the
145 // call chain it is required that the current thread is a Java thread.
146 _res = load_new_class_versions(Thread::current());
147 if (_res != JVMTI_ERROR_NONE) {
148 // free any successfully created classes, since none are redefined
149 for (int i = 0; i < _class_count; i++) {
150 if (_scratch_classes[i] != NULL) {
151 ClassLoaderData* cld = _scratch_classes[i]->class_loader_data();
152 // Free the memory for this class at class unloading time. Not before
153 // because CMS might think this is still live.
154 cld->add_to_deallocate_list((InstanceKlass*)_scratch_classes[i]);
155 }
156 }
157 // Free os::malloc allocated memory in load_new_class_version.
158 os::free(_scratch_classes);
159 RC_TIMER_STOP(_timer_vm_op_prologue);
160 unlock_classes();
161 return false;
162 }
163
164 RC_TIMER_STOP(_timer_vm_op_prologue);
165 return true;
166 }
167
168 void VM_RedefineClasses::doit() {
169 Thread *thread = Thread::current();
170
171 if (UseSharedSpaces) {
172 // Sharing is enabled so we remap the shared readonly space to
173 // shared readwrite, private just in case we need to redefine
174 // a shared class. We do the remap during the doit() phase of
175 // the safepoint to be safer.
176 if (!MetaspaceShared::remap_shared_readonly_as_readwrite()) {
177 RC_TRACE_WITH_THREAD(0x00000001, thread,
178 ("failed to remap shared readonly space to readwrite, private"));
179 _res = JVMTI_ERROR_INTERNAL;
180 return;
200 SystemDictionary::notice_modification();
201
202 // Set flag indicating that some invariants are no longer true.
203 // See jvmtiExport.hpp for detailed explanation.
204 JvmtiExport::set_has_redefined_a_class();
205
206 // check_class() is optionally called for product bits, but is
207 // always called for non-product bits.
208 #ifdef PRODUCT
209 if (RC_TRACE_ENABLED(0x00004000)) {
210 #endif
211 RC_TRACE_WITH_THREAD(0x00004000, thread, ("calling check_class"));
212 CheckClass check_class(thread);
213 ClassLoaderDataGraph::classes_do(&check_class);
214 #ifdef PRODUCT
215 }
216 #endif
217 }
218
219 void VM_RedefineClasses::doit_epilogue() {
220 unlock_classes();
221
222 // Free os::malloc allocated memory.
223 os::free(_scratch_classes);
224
225 // Reset the_class_oop to null for error printing.
226 _the_class_oop = NULL;
227
228 if (RC_TRACE_ENABLED(0x00000004)) {
229 // Used to have separate timers for "doit" and "all", but the timer
230 // overhead skewed the measurements.
231 jlong doit_time = _timer_rsc_phase1.milliseconds() +
232 _timer_rsc_phase2.milliseconds();
233 jlong all_time = _timer_vm_op_prologue.milliseconds() + doit_time;
234
235 RC_TRACE(0x00000004, ("vm_op: all=" UINT64_FORMAT
236 " prologue=" UINT64_FORMAT " doit=" UINT64_FORMAT, all_time,
237 _timer_vm_op_prologue.milliseconds(), doit_time));
238 RC_TRACE(0x00000004,
239 ("redefine_single_class: phase1=" UINT64_FORMAT " phase2=" UINT64_FORMAT,
240 _timer_rsc_phase1.milliseconds(), _timer_rsc_phase2.milliseconds()));
241 }
993 os::malloc(sizeof(Klass*) * _class_count, mtClass);
994 if (_scratch_classes == NULL) {
995 return JVMTI_ERROR_OUT_OF_MEMORY;
996 }
997 // Zero initialize the _scratch_classes array.
998 for (int i = 0; i < _class_count; i++) {
999 _scratch_classes[i] = NULL;
1000 }
1001
1002 ResourceMark rm(THREAD);
1003
1004 JvmtiThreadState *state = JvmtiThreadState::state_for(JavaThread::current());
1005 // state can only be NULL if the current thread is exiting which
1006 // should not happen since we're trying to do a RedefineClasses
1007 guarantee(state != NULL, "exiting thread calling load_new_class_versions");
1008 for (int i = 0; i < _class_count; i++) {
1009 // Create HandleMark so that any handles created while loading new class
1010 // versions are deleted. Constant pools are deallocated while merging
1011 // constant pools
1012 HandleMark hm(THREAD);
1013 instanceKlassHandle the_class(THREAD, get_ik(_class_defs[i].klass));
1014 Symbol* the_class_sym = the_class->name();
1015
1016 // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
1017 RC_TRACE_WITH_THREAD(0x00000001, THREAD,
1018 ("loading name=%s kind=%d (avail_mem=" UINT64_FORMAT "K)",
1019 the_class->external_name(), _class_load_kind,
1020 os::available_memory() >> 10));
1021
1022 ClassFileStream st((u1*) _class_defs[i].class_bytes,
1023 _class_defs[i].class_byte_count, (char *)"__VM_RedefineClasses__");
1024
1025 // Parse the stream.
1026 Handle the_class_loader(THREAD, the_class->class_loader());
1027 Handle protection_domain(THREAD, the_class->protection_domain());
1028 // Set redefined class handle in JvmtiThreadState class.
1029 // This redefined class is sent to agent event handler for class file
1030 // load hook event.
1031 state->set_class_being_redefined(&the_class, _class_load_kind);
1032
1033 Klass* k = SystemDictionary::parse_stream(the_class_sym,
3880
3881
3882 // Install the redefinition of a class:
3883 // - house keeping (flushing breakpoints and caches, deoptimizing
3884 // dependent compiled code)
3885 // - replacing parts in the_class with parts from scratch_class
3886 // - adding a weak reference to track the obsolete but interesting
3887 // parts of the_class
3888 // - adjusting constant pool caches and vtables in other classes
3889 // that refer to methods in the_class. These adjustments use the
3890 // ClassLoaderDataGraph::classes_do() facility which only allows
3891 // a helper method to be specified. The interesting parameters
3892 // that we would like to pass to the helper method are saved in
3893 // static global fields in the VM operation.
3894 void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
3895 Klass* scratch_class_oop, TRAPS) {
3896
3897 HandleMark hm(THREAD); // make sure handles from this call are freed
3898 RC_TIMER_START(_timer_rsc_phase1);
3899
3900 instanceKlassHandle scratch_class(THREAD, scratch_class_oop);
3901 instanceKlassHandle the_class(THREAD, get_ik(the_jclass));
3902
3903 // Remove all breakpoints in methods of this class
3904 JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints();
3905 jvmti_breakpoints.clearall_in_class_at_safepoint(the_class());
3906
3907 // Deoptimize all compiled code that depends on this class
3908 flush_dependent_code(the_class, THREAD);
3909
3910 _old_methods = the_class->methods();
3911 _new_methods = scratch_class->methods();
3912 _the_class_oop = the_class();
3913 compute_added_deleted_matching_methods();
3914 update_jmethod_ids();
3915
3916 // Attach new constant pool to the original klass. The original
3917 // klass still refers to the old constant pool (for now).
3918 scratch_class->constants()->set_pool_holder(the_class());
3919
3920 #if 0
3921 // In theory, with constant pool merging in place we should be able
3922 // to save space by using the new, merged constant pool in place of
3923 // the old constant pool(s). By "pool(s)" I mean the constant pool in
3924 // the klass version we are replacing now and any constant pool(s) in
3925 // previous versions of klass. Nice theory, doesn't work in practice.
3926 // When this code is enabled, even simple programs throw NullPointer
3927 // exceptions. I'm guessing that this is caused by some constant pool
3928 // cache difference between the new, merged constant pool and the
3929 // constant pool that was just being used by the klass. I'm keeping
3930 // this code around to archive the idea, but the code has to remain
3931 // disabled for now.
3932
4116 MemberNameTable* mnt = the_class->member_names();
4117 if (mnt != NULL) {
4118 bool trace_name_printed = false;
4119 mnt->adjust_method_entries(the_class(), &trace_name_printed);
4120 }
4121
4122 if (the_class->oop_map_cache() != NULL) {
4123 // Flush references to any obsolete methods from the oop map cache
4124 // so that obsolete methods are not pinned.
4125 the_class->oop_map_cache()->flush_obsolete_entries();
4126 }
4127
4128 // increment the classRedefinedCount field in the_class and in any
4129 // direct and indirect subclasses of the_class
4130 increment_class_counter((InstanceKlass *)the_class(), THREAD);
4131
4132 // RC_TRACE macro has an embedded ResourceMark
4133 RC_TRACE_WITH_THREAD(0x00000001, THREAD,
4134 ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
4135 the_class->external_name(),
4136 java_lang_Class::classRedefinedCount(the_class->java_mirror()),
4137 os::available_memory() >> 10));
4138
4139 {
4140 ResourceMark rm(THREAD);
4141 Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
4142 the_class->external_name(),
4143 java_lang_Class::classRedefinedCount(the_class->java_mirror()));
4144
4145 }
4146 RC_TIMER_STOP(_timer_rsc_phase2);
4147 } // end redefine_single_class()
4148
4149
4150 // Increment the classRedefinedCount field in the specific InstanceKlass
4151 // and in all direct and indirect subclasses.
4152 void VM_RedefineClasses::increment_class_counter(InstanceKlass *ik, TRAPS) {
4153 oop class_mirror = ik->java_mirror();
4154 Klass* class_oop = java_lang_Class::as_Klass(class_mirror);
4155 int new_count = java_lang_Class::classRedefinedCount(class_mirror) + 1;
4156 java_lang_Class::set_classRedefinedCount(class_mirror, new_count);
4157
4158 if (class_oop != _the_class_oop) {
4159 // _the_class_oop count is printed at end of redefine_single_class()
4160 RC_TRACE_WITH_THREAD(0x00000008, THREAD,
4161 ("updated count in subclass=%s to %d", ik->external_name(), new_count));
4162 }
4163
|