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"
1293 OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
1294 }
1295
1296 unsigned char nmethod::unloading_clock() {
1297 return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
1298 }
1299
1300 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1301
1302 post_compiled_method_unload();
1303
1304 // Since this nmethod is being unloaded, make sure that dependencies
1305 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1306 // indicate that this work is being done during a GC.
1307 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1308 assert(is_alive != NULL, "Should be non-NULL");
1309 // A non-NULL is_alive closure indicates that this is being called during GC.
1310 flush_dependencies(is_alive);
1311
1312 // Break cycle between nmethod & method
1313 if (TraceClassUnloading && WizardMode) {
1314 tty->print_cr("[Class unloading: Making nmethod " INTPTR_FORMAT
1315 " unloadable], Method*(" INTPTR_FORMAT
1316 "), cause(" INTPTR_FORMAT ")",
1317 p2i(this), p2i(_method), p2i(cause));
1318 if (!Universe::heap()->is_gc_active())
1319 cause->klass()->print();
1320 }
1321 // Unlink the osr method, so we do not look this up again
1322 if (is_osr_method()) {
1323 invalidate_osr_method();
1324 }
1325 // If _method is already NULL the Method* is about to be unloaded,
1326 // so we don't have to break the cycle. Note that it is possible to
1327 // have the Method* live here, in case we unload the nmethod because
1328 // it is pointing to some oop (other than the Method*) being unloaded.
1329 if (_method != NULL) {
1330 // OSR methods point to the Method*, but the Method* does not
1331 // point back!
1332 if (_method->code() == this) {
1333 _method->clear_code(); // Break a cycle
1334 }
1335 _method = NULL; // Clear the method of this dead nmethod
1336 }
1337
1338 // Make the class unloaded - i.e., change state and notify sweeper
1339 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"
1294 OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
1295 }
1296
1297 unsigned char nmethod::unloading_clock() {
1298 return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
1299 }
1300
1301 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
1302
1303 post_compiled_method_unload();
1304
1305 // Since this nmethod is being unloaded, make sure that dependencies
1306 // recorded in instanceKlasses get flushed and pass non-NULL closure to
1307 // indicate that this work is being done during a GC.
1308 assert(Universe::heap()->is_gc_active(), "should only be called during gc");
1309 assert(is_alive != NULL, "Should be non-NULL");
1310 // A non-NULL is_alive closure indicates that this is being called during GC.
1311 flush_dependencies(is_alive);
1312
1313 // Break cycle between nmethod & method
1314 if (log_is_enabled(Trace, classunload)) {
1315 outputStream* log = LogHandle(classunload)::trace_stream();
1316 log->print_cr("making nmethod " INTPTR_FORMAT
1317 " unloadable, Method*(" INTPTR_FORMAT
1318 "), cause(" INTPTR_FORMAT ")",
1319 p2i(this), p2i(_method), p2i(cause));
1320 if (!Universe::heap()->is_gc_active())
1321 cause->klass()->print_on(log);
1322 }
1323 // Unlink the osr method, so we do not look this up again
1324 if (is_osr_method()) {
1325 invalidate_osr_method();
1326 }
1327 // If _method is already NULL the Method* is about to be unloaded,
1328 // so we don't have to break the cycle. Note that it is possible to
1329 // have the Method* live here, in case we unload the nmethod because
1330 // it is pointing to some oop (other than the Method*) being unloaded.
1331 if (_method != NULL) {
1332 // OSR methods point to the Method*, but the Method* does not
1333 // point back!
1334 if (_method->code() == this) {
1335 _method->clear_code(); // Break a cycle
1336 }
1337 _method = NULL; // Clear the method of this dead nmethod
1338 }
1339
1340 // Make the class unloaded - i.e., change state and notify sweeper
1341 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|