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/jvm.h"
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"
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 if (log_is_enabled(Trace, class, unload)) {
1040 outputStream* log = Log(class, unload)::trace_stream();
1041 log->print_cr("making nmethod " INTPTR_FORMAT
1042 " unloadable, Method*(" INTPTR_FORMAT
1043 "), cause(" INTPTR_FORMAT ")",
1044 p2i(this), p2i(_method), p2i(cause));
1045 if (!Universe::heap()->is_gc_active())
1046 cause->klass()->print_on(log);
1047 }
1048 // Unlink the osr method, so we do not look this up again
1049 if (is_osr_method()) {
1050 // Invalidate the osr nmethod only once
1051 if (is_in_use()) {
1052 invalidate_osr_method();
1053 }
1054 #ifdef ASSERT
1055 if (method() != NULL) {
1056 // Make sure osr nmethod is invalidated, i.e. not on the list
1057 bool found = method()->method_holder()->remove_osr_nmethod(this);
1058 assert(!found, "osr nmethod should have been invalidated");
1059 }
1060 #endif
1061 }
1062
1063 // If _method is already NULL the Method* is about to be unloaded,
1064 // so we don't have to break the cycle. Note that it is possible to
1065 // have the Method* live here, in case we unload the nmethod because
1066 // 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/jvm.h"
45 #include "prims/jvmtiImpl.hpp"
46 #include "runtime/atomic.hpp"
47 #include "runtime/orderAccess.inline.hpp"
48 #include "runtime/os.hpp"
49 #include "runtime/sharedRuntime.hpp"
50 #include "runtime/sweeper.hpp"
51 #include "utilities/resourceHash.hpp"
52 #include "utilities/dtrace.hpp"
53 #include "utilities/events.hpp"
54 #include "utilities/xmlstream.hpp"
55 #include "logging/log.hpp"
56 #ifdef SHARK
57 #include "shark/sharkCompiler.hpp"
58 #endif
59 #if INCLUDE_JVMCI
60 #include "jvmci/jvmciJavaClasses.hpp"
1020 if (m == NULL) return;
1021 MethodData* mdo = m->method_data();
1022 if (mdo == NULL) return;
1023 // There is a benign race here. See comments in methodData.hpp.
1024 mdo->inc_decompile_count();
1025 }
1026
1027 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1028
1029 post_compiled_method_unload();
1030
1031 // Since this nmethod is being unloaded, make sure that dependencies
1032 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1033 // indicate that this work is being done during a GC.
1034 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1035 assert(is_alive != NULL, "Should be non-NULL");
1036 // A non-NULL is_alive closure indicates that this is being called during GC.
1037 flush_dependencies(is_alive);
1038
1039 // Break cycle between nmethod & method
1040 LogTarget(Trace, class, unload) lt;
1041 if (lt.is_enabled()) {
1042 LogStream ls(lt);
1043 ls.print_cr("making nmethod " INTPTR_FORMAT
1044 " unloadable, Method*(" INTPTR_FORMAT
1045 "), cause(" INTPTR_FORMAT ")",
1046 p2i(this), p2i(_method), p2i(cause));
1047 if (!Universe::heap()->is_gc_active())
1048 cause->klass()->print_on(&ls);
1049 }
1050 // Unlink the osr method, so we do not look this up again
1051 if (is_osr_method()) {
1052 // Invalidate the osr nmethod only once
1053 if (is_in_use()) {
1054 invalidate_osr_method();
1055 }
1056 #ifdef ASSERT
1057 if (method() != NULL) {
1058 // Make sure osr nmethod is invalidated, i.e. not on the list
1059 bool found = method()->method_holder()->remove_osr_nmethod(this);
1060 assert(!found, "osr nmethod should have been invalidated");
1061 }
1062 #endif
1063 }
1064
1065 // If _method is already NULL the Method* is about to be unloaded,
1066 // so we don't have to break the cycle. Note that it is possible to
1067 // have the Method* live here, in case we unload the nmethod because
1068 // it is pointing to some oop (other than the Method*) being unloaded.
|