1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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/disassembler.hpp"
37 #include "interpreter/bytecode.hpp"
38 #include "oops/methodData.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "prims/jvmtiRedefineClassesTrace.hpp"
41 #include "prims/jvmtiImpl.hpp"
42 #include "runtime/atomic.inline.hpp"
43 #include "runtime/orderAccess.inline.hpp"
44 #include "runtime/os.hpp"
45 #include "runtime/sharedRuntime.hpp"
46 #include "runtime/sweeper.hpp"
47 #include "utilities/resourceHash.hpp"
48 #include "utilities/dtrace.hpp"
49 #include "utilities/events.hpp"
50 #include "utilities/xmlstream.hpp"
51 #ifdef TARGET_ARCH_x86
52 # include "nativeInst_x86.hpp"
53 #endif
54 #ifdef TARGET_ARCH_sparc
55 # include "nativeInst_sparc.hpp"
56 #endif
57 #ifdef TARGET_ARCH_zero
58 # include "nativeInst_zero.hpp"
59 #endif
60 #ifdef TARGET_ARCH_arm
61 # include "nativeInst_arm.hpp"
62 #endif
63 #ifdef TARGET_ARCH_ppc
64 # include "nativeInst_ppc.hpp"
65 #endif
66 #ifdef SHARK
67 #include "shark/sharkCompiler.hpp"
68 #endif
69 #if INCLUDE_JVMCI
70 #include "jvmci/jvmciJavaClasses.hpp"
1289 OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
1290 }
1291
1292 unsigned char nmethod::unloading_clock() {
1293 return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
1294 }
1295
1296 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1297
1298 post_compiled_method_unload();
1299
1300 // Since this nmethod is being unloaded, make sure that dependencies
1301 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1302 // indicate that this work is being done during a GC.
1303 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1304 assert(is_alive != NULL, "Should be non-NULL");
1305 // A non-NULL is_alive closure indicates that this is being called during GC.
1306 flush_dependencies(is_alive);
1307
1308 // Break cycle between nmethod & method
1309 if (TraceClassUnloading && WizardMode) {
1310 tty->print_cr("[Class unloading: Making nmethod " INTPTR_FORMAT
1311 " unloadable], Method*(" INTPTR_FORMAT
1312 "), cause(" INTPTR_FORMAT ")",
1313 p2i(this), p2i(_method), p2i(cause));
1314 if (!Universe::heap()->is_gc_active())
1315 cause->klass()->print();
1316 }
1317 // Unlink the osr method, so we do not look this up again
1318 if (is_osr_method()) {
1319 invalidate_osr_method();
1320 }
1321 // If _method is already NULL the Method* is about to be unloaded,
1322 // so we don't have to break the cycle. Note that it is possible to
1323 // have the Method* live here, in case we unload the nmethod because
1324 // it is pointing to some oop (other than the Method*) being unloaded.
1325 if (_method != NULL) {
1326 // OSR methods point to the Method*, but the Method* does not
1327 // point back!
1328 if (_method->code() == this) {
1329 _method->clear_code(); // Break a cycle
1330 }
1331 _method = NULL; // Clear the method of this dead nmethod
1332 }
1333
1334 // Make the class unloaded - i.e., change state and notify sweeper
1335 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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/disassembler.hpp"
37 #include "interpreter/bytecode.hpp"
38 #include "oops/methodData.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "prims/jvmtiRedefineClassesTrace.hpp"
41 #include "prims/jvmtiImpl.hpp"
42 #include "runtime/atomic.inline.hpp"
43 #include "runtime/orderAccess.inline.hpp"
44 #include "runtime/os.hpp"
45 #include "runtime/sharedRuntime.hpp"
46 #include "runtime/sweeper.hpp"
47 #include "utilities/resourceHash.hpp"
48 #include "utilities/dtrace.hpp"
49 #include "utilities/events.hpp"
50 #include "utilities/xmlstream.hpp"
51 #include "logging/log.hpp"
52 #ifdef TARGET_ARCH_x86
53 # include "nativeInst_x86.hpp"
54 #endif
55 #ifdef TARGET_ARCH_sparc
56 # include "nativeInst_sparc.hpp"
57 #endif
58 #ifdef TARGET_ARCH_zero
59 # include "nativeInst_zero.hpp"
60 #endif
61 #ifdef TARGET_ARCH_arm
62 # include "nativeInst_arm.hpp"
63 #endif
64 #ifdef TARGET_ARCH_ppc
65 # include "nativeInst_ppc.hpp"
66 #endif
67 #ifdef SHARK
68 #include "shark/sharkCompiler.hpp"
69 #endif
70 #if INCLUDE_JVMCI
71 #include "jvmci/jvmciJavaClasses.hpp"
1290 OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
1291 }
1292
1293 unsigned char nmethod::unloading_clock() {
1294 return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
1295 }
1296
1297 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1298
1299 post_compiled_method_unload();
1300
1301 // Since this nmethod is being unloaded, make sure that dependencies
1302 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1303 // indicate that this work is being done during a GC.
1304 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1305 assert(is_alive != NULL, "Should be non-NULL");
1306 // A non-NULL is_alive closure indicates that this is being called during GC.
1307 flush_dependencies(is_alive);
1308
1309 // Break cycle between nmethod & method
1310 if (log_is_enabled(Trace, classunload)) {
1311 outputStream* log = LogHandle(classunload)::trace_stream();
1312 log->print_cr("[Class unloading: Making nmethod " INTPTR_FORMAT
1313 " unloadable], Method*(" INTPTR_FORMAT
1314 "), cause(" INTPTR_FORMAT ")",
1315 p2i(this), p2i(_method), p2i(cause));
1316 if (!Universe::heap()->is_gc_active())
1317 cause->klass()->print_on(log);
1318 }
1319 // Unlink the osr method, so we do not look this up again
1320 if (is_osr_method()) {
1321 invalidate_osr_method();
1322 }
1323 // If _method is already NULL the Method* is about to be unloaded,
1324 // so we don't have to break the cycle. Note that it is possible to
1325 // have the Method* live here, in case we unload the nmethod because
1326 // it is pointing to some oop (other than the Method*) being unloaded.
1327 if (_method != NULL) {
1328 // OSR methods point to the Method*, but the Method* does not
1329 // point back!
1330 if (_method->code() == this) {
1331 _method->clear_code(); // Break a cycle
1332 }
1333 _method = NULL; // Clear the method of this dead nmethod
1334 }
1335
1336 // Make the class unloaded - i.e., change state and notify sweeper
1337 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|