1 /*
2 * Copyright (c) 1997, 2019, 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 *
546 // GC vm_operations can get caught at the safepoint, and the
547 // heap is unparseable if they are caught. Grab the Heap_lock
548 // to prevent this. The GC vm_operations will not be able to
549 // queue until after we release it, but we never do that as we
550 // are terminating the VM process.
551 MutexLocker ml(Heap_lock);
552
553 VMThread::execute(&op);
554 // should never reach here; but in case something wrong with VM Thread.
555 vm_direct_exit(code);
556 } else {
557 // VM thread is gone, just exit
558 vm_direct_exit(code);
559 }
560 ShouldNotReachHere();
561 }
562
563 void notify_vm_shutdown() {
564 // For now, just a dtrace probe.
565 HOTSPOT_VM_SHUTDOWN();
566 HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
567 }
568
569 void vm_direct_exit(int code) {
570 notify_vm_shutdown();
571 os::wait_for_keypress_at_exit();
572 os::exit(code);
573 }
574
575 void vm_perform_shutdown_actions() {
576 if (is_init_completed()) {
577 Thread* thread = Thread::current_or_null();
578 if (thread != NULL && thread->is_Java_thread()) {
579 // We are leaving the VM, set state to native (in case any OS exit
580 // handlers call back to the VM)
581 JavaThread* jt = (JavaThread*)thread;
582 // Must always be walkable or have no last_Java_frame when in
583 // thread_in_native
584 jt->frame_anchor()->make_walkable(jt);
585 jt->set_thread_state(_thread_in_native);
586 }
|
1 /*
2 * Copyright (c) 1997, 2020, 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 *
546 // GC vm_operations can get caught at the safepoint, and the
547 // heap is unparseable if they are caught. Grab the Heap_lock
548 // to prevent this. The GC vm_operations will not be able to
549 // queue until after we release it, but we never do that as we
550 // are terminating the VM process.
551 MutexLocker ml(Heap_lock);
552
553 VMThread::execute(&op);
554 // should never reach here; but in case something wrong with VM Thread.
555 vm_direct_exit(code);
556 } else {
557 // VM thread is gone, just exit
558 vm_direct_exit(code);
559 }
560 ShouldNotReachHere();
561 }
562
563 void notify_vm_shutdown() {
564 // For now, just a dtrace probe.
565 HOTSPOT_VM_SHUTDOWN();
566 }
567
568 void vm_direct_exit(int code) {
569 notify_vm_shutdown();
570 os::wait_for_keypress_at_exit();
571 os::exit(code);
572 }
573
574 void vm_perform_shutdown_actions() {
575 if (is_init_completed()) {
576 Thread* thread = Thread::current_or_null();
577 if (thread != NULL && thread->is_Java_thread()) {
578 // We are leaving the VM, set state to native (in case any OS exit
579 // handlers call back to the VM)
580 JavaThread* jt = (JavaThread*)thread;
581 // Must always be walkable or have no last_Java_frame when in
582 // thread_in_native
583 jt->frame_anchor()->make_walkable(jt);
584 jt->set_thread_state(_thread_in_native);
585 }
|