20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/dependencies.hpp"
29 #include "code/nativeInst.hpp"
30 #include "code/nmethod.hpp"
31 #include "code/scopeDesc.hpp"
32 #include "compiler/abstractCompiler.hpp"
33 #include "compiler/compileBroker.hpp"
34 #include "compiler/compileLog.hpp"
35 #include "compiler/compilerDirectives.hpp"
36 #include "compiler/directivesParser.hpp"
37 #include "compiler/disassembler.hpp"
38 #include "interpreter/bytecode.hpp"
39 #include "logging/log.hpp"
40 #include "memory/resourceArea.hpp"
41 #include "oops/methodData.hpp"
42 #include "oops/oop.inline.hpp"
43 #include "prims/jvmtiImpl.hpp"
44 #include "runtime/atomic.hpp"
45 #include "runtime/orderAccess.inline.hpp"
46 #include "runtime/os.hpp"
47 #include "runtime/sharedRuntime.hpp"
48 #include "runtime/sweeper.hpp"
49 #include "utilities/resourceHash.hpp"
50 #include "utilities/dtrace.hpp"
51 #include "utilities/events.hpp"
52 #include "utilities/xmlstream.hpp"
53 #include "logging/log.hpp"
54 #ifdef SHARK
55 #include "shark/sharkCompiler.hpp"
56 #endif
57 #if INCLUDE_JVMCI
58 #include "jvmci/jvmciJavaClasses.hpp"
59 #endif
1018 if (m == NULL) return;
1019 MethodData* mdo = m->method_data();
1020 if (mdo == NULL) return;
1021 // There is a benign race here. See comments in methodData.hpp.
1022 mdo->inc_decompile_count();
1023 }
1024
1025 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1026
1027 post_compiled_method_unload();
1028
1029 // Since this nmethod is being unloaded, make sure that dependencies
1030 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1031 // indicate that this work is being done during a GC.
1032 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1033 assert(is_alive != NULL, "Should be non-NULL");
1034 // A non-NULL is_alive closure indicates that this is being called during GC.
1035 flush_dependencies(is_alive);
1036
1037 // Break cycle between nmethod & method
1038 if (log_is_enabled(Trace, class, unload)) {
1039 outputStream* log = Log(class, unload)::trace_stream();
1040 log->print_cr("making nmethod " INTPTR_FORMAT
1041 " unloadable, Method*(" INTPTR_FORMAT
1042 "), cause(" INTPTR_FORMAT ")",
1043 p2i(this), p2i(_method), p2i(cause));
1044 if (!Universe::heap()->is_gc_active())
1045 cause->klass()->print_on(log);
1046 }
1047 // Unlink the osr method, so we do not look this up again
1048 if (is_osr_method()) {
1049 // Invalidate the osr nmethod only once
1050 if (is_in_use()) {
1051 invalidate_osr_method();
1052 }
1053 #ifdef ASSERT
1054 if (method() != NULL) {
1055 // Make sure osr nmethod is invalidated, i.e. not on the list
1056 bool found = method()->method_holder()->remove_osr_nmethod(this);
1057 assert(!found, "osr nmethod should have been invalidated");
1058 }
1059 #endif
1060 }
1061
1062 // If _method is already NULL the Method* is about to be unloaded,
1063 // so we don't have to break the cycle. Note that it is possible to
1064 // have the Method* live here, in case we unload the nmethod because
1065 // it is pointing to some oop (other than the Method*) being unloaded.
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/dependencies.hpp"
29 #include "code/nativeInst.hpp"
30 #include "code/nmethod.hpp"
31 #include "code/scopeDesc.hpp"
32 #include "compiler/abstractCompiler.hpp"
33 #include "compiler/compileBroker.hpp"
34 #include "compiler/compileLog.hpp"
35 #include "compiler/compilerDirectives.hpp"
36 #include "compiler/directivesParser.hpp"
37 #include "compiler/disassembler.hpp"
38 #include "interpreter/bytecode.hpp"
39 #include "logging/log.hpp"
40 #include "logging/logStream.hpp"
41 #include "memory/resourceArea.hpp"
42 #include "oops/methodData.hpp"
43 #include "oops/oop.inline.hpp"
44 #include "prims/jvmtiImpl.hpp"
45 #include "runtime/atomic.hpp"
46 #include "runtime/orderAccess.inline.hpp"
47 #include "runtime/os.hpp"
48 #include "runtime/sharedRuntime.hpp"
49 #include "runtime/sweeper.hpp"
50 #include "utilities/resourceHash.hpp"
51 #include "utilities/dtrace.hpp"
52 #include "utilities/events.hpp"
53 #include "utilities/xmlstream.hpp"
54 #include "logging/log.hpp"
55 #ifdef SHARK
56 #include "shark/sharkCompiler.hpp"
57 #endif
58 #if INCLUDE_JVMCI
59 #include "jvmci/jvmciJavaClasses.hpp"
60 #endif
1019 if (m == NULL) return;
1020 MethodData* mdo = m->method_data();
1021 if (mdo == NULL) return;
1022 // There is a benign race here. See comments in methodData.hpp.
1023 mdo->inc_decompile_count();
1024 }
1025
1026 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1027
1028 post_compiled_method_unload();
1029
1030 // Since this nmethod is being unloaded, make sure that dependencies
1031 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1032 // indicate that this work is being done during a GC.
1033 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1034 assert(is_alive != NULL, "Should be non-NULL");
1035 // A non-NULL is_alive closure indicates that this is being called during GC.
1036 flush_dependencies(is_alive);
1037
1038 // Break cycle between nmethod & method
1039 LogTarget(Trace, class, unload) lt;
1040 if (lt.is_enabled()) {
1041 LogStream ls(lt);
1042 ls.print_cr("making nmethod " INTPTR_FORMAT
1043 " unloadable, Method*(" INTPTR_FORMAT
1044 "), cause(" INTPTR_FORMAT ")",
1045 p2i(this), p2i(_method), p2i(cause));
1046 if (!Universe::heap()->is_gc_active())
1047 cause->klass()->print_on(&ls);
1048 }
1049 // Unlink the osr method, so we do not look this up again
1050 if (is_osr_method()) {
1051 // Invalidate the osr nmethod only once
1052 if (is_in_use()) {
1053 invalidate_osr_method();
1054 }
1055 #ifdef ASSERT
1056 if (method() != NULL) {
1057 // Make sure osr nmethod is invalidated, i.e. not on the list
1058 bool found = method()->method_holder()->remove_osr_nmethod(this);
1059 assert(!found, "osr nmethod should have been invalidated");
1060 }
1061 #endif
1062 }
1063
1064 // If _method is already NULL the Method* is about to be unloaded,
1065 // so we don't have to break the cycle. Note that it is possible to
1066 // have the Method* live here, in case we unload the nmethod because
1067 // it is pointing to some oop (other than the Method*) being unloaded.
|