1 /* |
1 /* |
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
31 #include "services/classLoadingService.hpp" |
31 #include "services/classLoadingService.hpp" |
32 #include "services/memoryService.hpp" |
32 #include "services/memoryService.hpp" |
33 #include "utilities/dtrace.hpp" |
33 #include "utilities/dtrace.hpp" |
34 #include "utilities/macros.hpp" |
34 #include "utilities/macros.hpp" |
35 #include "utilities/defaultStream.hpp" |
35 #include "utilities/defaultStream.hpp" |
|
36 #include "logging/log.hpp" |
|
37 #include "logging/logConfiguration.hpp" |
36 |
38 |
37 #ifdef DTRACE_ENABLED |
39 #ifdef DTRACE_ENABLED |
38 |
40 |
39 // Only bother with this argument setup if dtrace is available |
41 // Only bother with this argument setup if dtrace is available |
40 |
42 |
133 for (int i = 0; i < methods->length(); i++) { |
135 for (int i = 0; i < methods->length(); i++) { |
134 _class_methods_size->inc(-methods->at(i)->size()); |
136 _class_methods_size->inc(-methods->at(i)->size()); |
135 } |
137 } |
136 } |
138 } |
137 |
139 |
138 if (TraceClassUnloading) { |
140 if (log_is_enabled(Info, classunload)) { |
139 ResourceMark rm; |
141 ResourceMark rm; |
140 tty->print_cr("[Unloading class %s " INTPTR_FORMAT "]", k->external_name(), p2i(k)); |
142 log_info(classunload)("unloading class %s " INTPTR_FORMAT , k->external_name(), p2i(k)); |
141 } |
143 } |
142 } |
144 } |
143 |
145 |
144 void ClassLoadingService::notify_class_loaded(InstanceKlass* k, bool shared_class) { |
146 void ClassLoadingService::notify_class_loaded(InstanceKlass* k, bool shared_class) { |
145 DTRACE_CLASSLOAD_PROBE(loaded, k, shared_class); |
147 DTRACE_CLASSLOAD_PROBE(loaded, k, shared_class); |
177 return class_size * oopSize; |
179 return class_size * oopSize; |
178 } |
180 } |
179 |
181 |
180 bool ClassLoadingService::set_verbose(bool verbose) { |
182 bool ClassLoadingService::set_verbose(bool verbose) { |
181 MutexLocker m(Management_lock); |
183 MutexLocker m(Management_lock); |
182 |
|
183 // verbose will be set to the previous value |
184 // verbose will be set to the previous value |
184 Flag::Error error = CommandLineFlags::boolAtPut("TraceClassLoading", &verbose, Flag::MANAGEMENT); |
185 if (verbose) { |
185 assert(error==Flag::SUCCESS, "Setting TraceClassLoading flag failed with error %s", Flag::flag_error_str(error)); |
186 LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL); |
|
187 } else { |
|
188 LogConfiguration::parse_log_arguments("stdout", "classload=off", NULL, NULL, NULL); |
|
189 } |
186 reset_trace_class_unloading(); |
190 reset_trace_class_unloading(); |
187 |
|
188 return verbose; |
191 return verbose; |
189 } |
192 } |
190 |
193 |
191 // Caller to this function must own Management_lock |
194 // Caller to this function must own Management_lock |
192 void ClassLoadingService::reset_trace_class_unloading() { |
195 void ClassLoadingService::reset_trace_class_unloading() { |
193 assert(Management_lock->owned_by_self(), "Must own the Management_lock"); |
196 assert(Management_lock->owned_by_self(), "Must own the Management_lock"); |
194 bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); |
197 bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); |
195 Flag::Error error = CommandLineFlags::boolAtPut("TraceClassUnloading", &value, Flag::MANAGEMENT); |
198 if (value) { |
196 assert(error==Flag::SUCCESS, "Setting TraceClassUnLoading flag failed with error %s", Flag::flag_error_str(error)); |
199 LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL); |
|
200 } else { |
|
201 LogConfiguration::parse_log_arguments("stdout", "classunload=off", NULL, NULL, NULL); |
|
202 } |
197 } |
203 } |
198 |
204 |
199 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL; |
205 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL; |
200 Thread* LoadedClassesEnumerator::_current_thread = NULL; |
206 Thread* LoadedClassesEnumerator::_current_thread = NULL; |
201 |
207 |