src/share/vm/runtime/vm_operations.cpp

Thu, 24 May 2018 20:03:11 +0800

author
aoqi
date
Thu, 24 May 2018 20:03:11 +0800
changeset 8868
91ddc23482a4
parent 8604
04d83ba48607
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

Increase MaxHeapSize for better performance on MIPS

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "classfile/symbolTable.hpp"
aoqi@0 27 #include "classfile/vmSymbols.hpp"
aoqi@0 28 #include "compiler/compileBroker.hpp"
aoqi@0 29 #include "compiler/compilerOracle.hpp"
aoqi@0 30 #include "gc_implementation/shared/isGCActiveMark.hpp"
aoqi@0 31 #include "memory/resourceArea.hpp"
aoqi@0 32 #include "oops/symbol.hpp"
aoqi@0 33 #include "runtime/arguments.hpp"
aoqi@0 34 #include "runtime/deoptimization.hpp"
aoqi@0 35 #include "runtime/interfaceSupport.hpp"
aoqi@0 36 #include "runtime/sweeper.hpp"
aoqi@0 37 #include "runtime/thread.inline.hpp"
aoqi@0 38 #include "runtime/vm_operations.hpp"
aoqi@0 39 #include "services/threadService.hpp"
aoqi@0 40 #include "trace/tracing.hpp"
aoqi@0 41
aoqi@0 42 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
aoqi@0 43
aoqi@0 44 #define VM_OP_NAME_INITIALIZE(name) #name,
aoqi@0 45
aoqi@0 46 const char* VM_Operation::_names[VM_Operation::VMOp_Terminating] = \
aoqi@0 47 { VM_OPS_DO(VM_OP_NAME_INITIALIZE) };
aoqi@0 48
aoqi@0 49 void VM_Operation::set_calling_thread(Thread* thread, ThreadPriority priority) {
aoqi@0 50 _calling_thread = thread;
aoqi@0 51 assert(MinPriority <= priority && priority <= MaxPriority, "sanity check");
aoqi@0 52 _priority = priority;
aoqi@0 53 }
aoqi@0 54
aoqi@0 55
aoqi@0 56 void VM_Operation::evaluate() {
aoqi@0 57 ResourceMark rm;
aoqi@0 58 if (TraceVMOperation) {
aoqi@0 59 tty->print("[");
aoqi@0 60 NOT_PRODUCT(print();)
aoqi@0 61 }
aoqi@0 62 doit();
aoqi@0 63 if (TraceVMOperation) {
aoqi@0 64 tty->print_cr("]");
aoqi@0 65 }
aoqi@0 66 }
aoqi@0 67
aoqi@0 68 const char* VM_Operation::mode_to_string(Mode mode) {
aoqi@0 69 switch(mode) {
aoqi@0 70 case _safepoint : return "safepoint";
aoqi@0 71 case _no_safepoint : return "no safepoint";
aoqi@0 72 case _concurrent : return "concurrent";
aoqi@0 73 case _async_safepoint: return "async safepoint";
aoqi@0 74 default : return "unknown";
aoqi@0 75 }
aoqi@0 76 }
aoqi@0 77 // Called by fatal error handler.
aoqi@0 78 void VM_Operation::print_on_error(outputStream* st) const {
aoqi@0 79 st->print("VM_Operation (" PTR_FORMAT "): ", this);
aoqi@0 80 st->print("%s", name());
aoqi@0 81
aoqi@0 82 const char* mode = mode_to_string(evaluation_mode());
aoqi@0 83 st->print(", mode: %s", mode);
aoqi@0 84
aoqi@0 85 if (calling_thread()) {
aoqi@0 86 st->print(", requested by thread " PTR_FORMAT, calling_thread());
aoqi@0 87 }
aoqi@0 88 }
aoqi@0 89
aoqi@0 90 void VM_ThreadStop::doit() {
aoqi@0 91 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
aoqi@0 92 JavaThread* target = java_lang_Thread::thread(target_thread());
aoqi@0 93 // Note that this now allows multiple ThreadDeath exceptions to be
aoqi@0 94 // thrown at a thread.
aoqi@0 95 if (target != NULL) {
aoqi@0 96 // the thread has run and is not already in the process of exiting
aoqi@0 97 target->send_thread_stop(throwable());
aoqi@0 98 }
aoqi@0 99 }
aoqi@0 100
aoqi@0 101 void VM_Deoptimize::doit() {
aoqi@0 102 // We do not want any GCs to happen while we are in the middle of this VM operation
aoqi@0 103 ResourceMark rm;
aoqi@0 104 DeoptimizationMarker dm;
aoqi@0 105
aoqi@0 106 // Deoptimize all activations depending on marked nmethods
aoqi@0 107 Deoptimization::deoptimize_dependents();
aoqi@0 108
thartmann@8074 109 // Make the dependent methods not entrant
thartmann@8074 110 CodeCache::make_marked_nmethods_not_entrant();
aoqi@0 111 }
aoqi@0 112
aoqi@0 113
aoqi@0 114 VM_DeoptimizeFrame::VM_DeoptimizeFrame(JavaThread* thread, intptr_t* id) {
aoqi@0 115 _thread = thread;
aoqi@0 116 _id = id;
aoqi@0 117 }
aoqi@0 118
aoqi@0 119
aoqi@0 120 void VM_DeoptimizeFrame::doit() {
aoqi@0 121 Deoptimization::deoptimize_frame_internal(_thread, _id);
aoqi@0 122 }
aoqi@0 123
aoqi@0 124
aoqi@0 125 #ifndef PRODUCT
aoqi@0 126
aoqi@0 127 void VM_DeoptimizeAll::doit() {
aoqi@0 128 DeoptimizationMarker dm;
aoqi@0 129 // deoptimize all java threads in the system
aoqi@0 130 if (DeoptimizeALot) {
aoqi@0 131 for (JavaThread* thread = Threads::first(); thread != NULL; thread = thread->next()) {
aoqi@0 132 if (thread->has_last_Java_frame()) {
aoqi@0 133 thread->deoptimize();
aoqi@0 134 }
aoqi@0 135 }
aoqi@0 136 } else if (DeoptimizeRandom) {
aoqi@0 137
aoqi@0 138 // Deoptimize some selected threads and frames
aoqi@0 139 int tnum = os::random() & 0x3;
aoqi@0 140 int fnum = os::random() & 0x3;
aoqi@0 141 int tcount = 0;
aoqi@0 142 for (JavaThread* thread = Threads::first(); thread != NULL; thread = thread->next()) {
aoqi@0 143 if (thread->has_last_Java_frame()) {
aoqi@0 144 if (tcount++ == tnum) {
aoqi@0 145 tcount = 0;
aoqi@0 146 int fcount = 0;
aoqi@0 147 // Deoptimize some selected frames.
aoqi@0 148 // Biased llocking wants a updated register map
aoqi@0 149 for(StackFrameStream fst(thread, UseBiasedLocking); !fst.is_done(); fst.next()) {
aoqi@0 150 if (fst.current()->can_be_deoptimized()) {
aoqi@0 151 if (fcount++ == fnum) {
aoqi@0 152 fcount = 0;
aoqi@0 153 Deoptimization::deoptimize(thread, *fst.current(), fst.register_map());
aoqi@0 154 }
aoqi@0 155 }
aoqi@0 156 }
aoqi@0 157 }
aoqi@0 158 }
aoqi@0 159 }
aoqi@0 160 }
aoqi@0 161 }
aoqi@0 162
aoqi@0 163
aoqi@0 164 void VM_ZombieAll::doit() {
aoqi@0 165 JavaThread *thread = (JavaThread *)calling_thread();
aoqi@0 166 assert(thread->is_Java_thread(), "must be a Java thread");
aoqi@0 167 thread->make_zombies();
aoqi@0 168 }
aoqi@0 169
aoqi@0 170 #endif // !PRODUCT
aoqi@0 171
aoqi@0 172 void VM_UnlinkSymbols::doit() {
aoqi@0 173 JavaThread *thread = (JavaThread *)calling_thread();
aoqi@0 174 assert(thread->is_Java_thread(), "must be a Java thread");
aoqi@0 175 SymbolTable::unlink();
aoqi@0 176 }
aoqi@0 177
aoqi@0 178 void VM_Verify::doit() {
aoqi@0 179 Universe::heap()->prepare_for_verify();
aoqi@0 180 Universe::verify(_silent);
aoqi@0 181 }
aoqi@0 182
aoqi@0 183 bool VM_PrintThreads::doit_prologue() {
aoqi@0 184 assert(Thread::current()->is_Java_thread(), "just checking");
aoqi@0 185
aoqi@0 186 // Make sure AbstractOwnableSynchronizer is loaded
aoqi@0 187 if (JDK_Version::is_gte_jdk16x_version()) {
aoqi@0 188 java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
aoqi@0 189 }
aoqi@0 190
aoqi@0 191 // Get Heap_lock if concurrent locks will be dumped
aoqi@0 192 if (_print_concurrent_locks) {
aoqi@0 193 Heap_lock->lock();
aoqi@0 194 }
aoqi@0 195 return true;
aoqi@0 196 }
aoqi@0 197
aoqi@0 198 void VM_PrintThreads::doit() {
aoqi@0 199 Threads::print_on(_out, true, false, _print_concurrent_locks);
aoqi@0 200 }
aoqi@0 201
aoqi@0 202 void VM_PrintThreads::doit_epilogue() {
aoqi@0 203 if (_print_concurrent_locks) {
aoqi@0 204 // Release Heap_lock
aoqi@0 205 Heap_lock->unlock();
aoqi@0 206 }
aoqi@0 207 }
aoqi@0 208
aoqi@0 209 void VM_PrintJNI::doit() {
aoqi@0 210 JNIHandles::print_on(_out);
aoqi@0 211 }
aoqi@0 212
aoqi@0 213 VM_FindDeadlocks::~VM_FindDeadlocks() {
aoqi@0 214 if (_deadlocks != NULL) {
aoqi@0 215 DeadlockCycle* cycle = _deadlocks;
aoqi@0 216 while (cycle != NULL) {
aoqi@0 217 DeadlockCycle* d = cycle;
aoqi@0 218 cycle = cycle->next();
aoqi@0 219 delete d;
aoqi@0 220 }
aoqi@0 221 }
aoqi@0 222 }
aoqi@0 223
aoqi@0 224 bool VM_FindDeadlocks::doit_prologue() {
aoqi@0 225 assert(Thread::current()->is_Java_thread(), "just checking");
aoqi@0 226
aoqi@0 227 // Load AbstractOwnableSynchronizer class
aoqi@0 228 if (_concurrent_locks && JDK_Version::is_gte_jdk16x_version()) {
aoqi@0 229 java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
aoqi@0 230 }
aoqi@0 231
aoqi@0 232 return true;
aoqi@0 233 }
aoqi@0 234
aoqi@0 235 void VM_FindDeadlocks::doit() {
aoqi@0 236 _deadlocks = ThreadService::find_deadlocks_at_safepoint(_concurrent_locks);
aoqi@0 237 if (_out != NULL) {
aoqi@0 238 int num_deadlocks = 0;
aoqi@0 239 for (DeadlockCycle* cycle = _deadlocks; cycle != NULL; cycle = cycle->next()) {
aoqi@0 240 num_deadlocks++;
aoqi@0 241 cycle->print_on(_out);
aoqi@0 242 }
aoqi@0 243
aoqi@0 244 if (num_deadlocks == 1) {
aoqi@0 245 _out->print_cr("\nFound 1 deadlock.\n");
aoqi@0 246 _out->flush();
aoqi@0 247 } else if (num_deadlocks > 1) {
aoqi@0 248 _out->print_cr("\nFound %d deadlocks.\n", num_deadlocks);
aoqi@0 249 _out->flush();
aoqi@0 250 }
aoqi@0 251 }
aoqi@0 252 }
aoqi@0 253
aoqi@0 254 VM_ThreadDump::VM_ThreadDump(ThreadDumpResult* result,
aoqi@0 255 int max_depth,
aoqi@0 256 bool with_locked_monitors,
aoqi@0 257 bool with_locked_synchronizers) {
aoqi@0 258 _result = result;
aoqi@0 259 _num_threads = 0; // 0 indicates all threads
aoqi@0 260 _threads = NULL;
aoqi@0 261 _result = result;
aoqi@0 262 _max_depth = max_depth;
aoqi@0 263 _with_locked_monitors = with_locked_monitors;
aoqi@0 264 _with_locked_synchronizers = with_locked_synchronizers;
aoqi@0 265 }
aoqi@0 266
aoqi@0 267 VM_ThreadDump::VM_ThreadDump(ThreadDumpResult* result,
aoqi@0 268 GrowableArray<instanceHandle>* threads,
aoqi@0 269 int num_threads,
aoqi@0 270 int max_depth,
aoqi@0 271 bool with_locked_monitors,
aoqi@0 272 bool with_locked_synchronizers) {
aoqi@0 273 _result = result;
aoqi@0 274 _num_threads = num_threads;
aoqi@0 275 _threads = threads;
aoqi@0 276 _result = result;
aoqi@0 277 _max_depth = max_depth;
aoqi@0 278 _with_locked_monitors = with_locked_monitors;
aoqi@0 279 _with_locked_synchronizers = with_locked_synchronizers;
aoqi@0 280 }
aoqi@0 281
aoqi@0 282 bool VM_ThreadDump::doit_prologue() {
aoqi@0 283 assert(Thread::current()->is_Java_thread(), "just checking");
aoqi@0 284
aoqi@0 285 // Load AbstractOwnableSynchronizer class before taking thread snapshots
aoqi@0 286 if (JDK_Version::is_gte_jdk16x_version()) {
aoqi@0 287 java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
aoqi@0 288 }
aoqi@0 289
aoqi@0 290 if (_with_locked_synchronizers) {
aoqi@0 291 // Acquire Heap_lock to dump concurrent locks
aoqi@0 292 Heap_lock->lock();
aoqi@0 293 }
aoqi@0 294
aoqi@0 295 return true;
aoqi@0 296 }
aoqi@0 297
aoqi@0 298 void VM_ThreadDump::doit_epilogue() {
aoqi@0 299 if (_with_locked_synchronizers) {
aoqi@0 300 // Release Heap_lock
aoqi@0 301 Heap_lock->unlock();
aoqi@0 302 }
aoqi@0 303 }
aoqi@0 304
aoqi@0 305 void VM_ThreadDump::doit() {
aoqi@0 306 ResourceMark rm;
aoqi@0 307
aoqi@0 308 ConcurrentLocksDump concurrent_locks(true);
aoqi@0 309 if (_with_locked_synchronizers) {
aoqi@0 310 concurrent_locks.dump_at_safepoint();
aoqi@0 311 }
aoqi@0 312
aoqi@0 313 if (_num_threads == 0) {
aoqi@0 314 // Snapshot all live threads
aoqi@0 315 for (JavaThread* jt = Threads::first(); jt != NULL; jt = jt->next()) {
aoqi@0 316 if (jt->is_exiting() ||
aoqi@0 317 jt->is_hidden_from_external_view()) {
aoqi@0 318 // skip terminating threads and hidden threads
aoqi@0 319 continue;
aoqi@0 320 }
aoqi@0 321 ThreadConcurrentLocks* tcl = NULL;
aoqi@0 322 if (_with_locked_synchronizers) {
aoqi@0 323 tcl = concurrent_locks.thread_concurrent_locks(jt);
aoqi@0 324 }
aoqi@0 325 ThreadSnapshot* ts = snapshot_thread(jt, tcl);
aoqi@0 326 _result->add_thread_snapshot(ts);
aoqi@0 327 }
aoqi@0 328 } else {
aoqi@0 329 // Snapshot threads in the given _threads array
aoqi@0 330 // A dummy snapshot is created if a thread doesn't exist
aoqi@0 331 for (int i = 0; i < _num_threads; i++) {
aoqi@0 332 instanceHandle th = _threads->at(i);
aoqi@0 333 if (th() == NULL) {
aoqi@0 334 // skip if the thread doesn't exist
aoqi@0 335 // Add a dummy snapshot
aoqi@0 336 _result->add_thread_snapshot(new ThreadSnapshot());
aoqi@0 337 continue;
aoqi@0 338 }
aoqi@0 339
aoqi@0 340 // Dump thread stack only if the thread is alive and not exiting
aoqi@0 341 // and not VM internal thread.
aoqi@0 342 JavaThread* jt = java_lang_Thread::thread(th());
aoqi@0 343 if (jt == NULL || /* thread not alive */
aoqi@0 344 jt->is_exiting() ||
aoqi@0 345 jt->is_hidden_from_external_view()) {
aoqi@0 346 // add a NULL snapshot if skipped
aoqi@0 347 _result->add_thread_snapshot(new ThreadSnapshot());
aoqi@0 348 continue;
aoqi@0 349 }
aoqi@0 350 ThreadConcurrentLocks* tcl = NULL;
aoqi@0 351 if (_with_locked_synchronizers) {
aoqi@0 352 tcl = concurrent_locks.thread_concurrent_locks(jt);
aoqi@0 353 }
aoqi@0 354 ThreadSnapshot* ts = snapshot_thread(jt, tcl);
aoqi@0 355 _result->add_thread_snapshot(ts);
aoqi@0 356 }
aoqi@0 357 }
aoqi@0 358 }
aoqi@0 359
aoqi@0 360 ThreadSnapshot* VM_ThreadDump::snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl) {
aoqi@0 361 ThreadSnapshot* snapshot = new ThreadSnapshot(java_thread);
aoqi@0 362 snapshot->dump_stack_at_safepoint(_max_depth, _with_locked_monitors);
aoqi@0 363 snapshot->set_concurrent_locks(tcl);
aoqi@0 364 return snapshot;
aoqi@0 365 }
aoqi@0 366
aoqi@0 367 volatile bool VM_Exit::_vm_exited = false;
aoqi@0 368 Thread * VM_Exit::_shutdown_thread = NULL;
aoqi@0 369
aoqi@0 370 int VM_Exit::set_vm_exited() {
aoqi@0 371 Thread * thr_cur = ThreadLocalStorage::get_thread_slow();
aoqi@0 372
aoqi@0 373 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
aoqi@0 374
aoqi@0 375 int num_active = 0;
aoqi@0 376
aoqi@0 377 _shutdown_thread = thr_cur;
aoqi@0 378 _vm_exited = true; // global flag
aoqi@0 379 for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next())
aoqi@0 380 if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
aoqi@0 381 ++num_active;
aoqi@0 382 thr->set_terminated(JavaThread::_vm_exited); // per-thread flag
aoqi@0 383 }
aoqi@0 384
aoqi@0 385 return num_active;
aoqi@0 386 }
aoqi@0 387
aoqi@0 388 int VM_Exit::wait_for_threads_in_native_to_block() {
aoqi@0 389 // VM exits at safepoint. This function must be called at the final safepoint
aoqi@0 390 // to wait for threads in _thread_in_native state to be quiescent.
aoqi@0 391 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
aoqi@0 392
aoqi@0 393 Thread * thr_cur = ThreadLocalStorage::get_thread_slow();
aoqi@0 394 Monitor timer(Mutex::leaf, "VM_Exit timer", true);
aoqi@0 395
aoqi@0 396 // Compiler threads need longer wait because they can access VM data directly
aoqi@0 397 // while in native. If they are active and some structures being used are
aoqi@0 398 // deleted by the shutdown sequence, they will crash. On the other hand, user
aoqi@0 399 // threads must go through native=>Java/VM transitions first to access VM
aoqi@0 400 // data, and they will be stopped during state transition. In theory, we
aoqi@0 401 // don't have to wait for user threads to be quiescent, but it's always
aoqi@0 402 // better to terminate VM when current thread is the only active thread, so
aoqi@0 403 // wait for user threads too. Numbers are in 10 milliseconds.
aoqi@0 404 int max_wait_user_thread = 30; // at least 300 milliseconds
aoqi@0 405 int max_wait_compiler_thread = 1000; // at least 10 seconds
aoqi@0 406
aoqi@0 407 int max_wait = max_wait_compiler_thread;
aoqi@0 408
aoqi@0 409 int attempts = 0;
aoqi@0 410 while (true) {
aoqi@0 411 int num_active = 0;
aoqi@0 412 int num_active_compiler_thread = 0;
aoqi@0 413
aoqi@0 414 for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next()) {
aoqi@0 415 if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
aoqi@0 416 num_active++;
aoqi@0 417 if (thr->is_Compiler_thread()) {
aoqi@0 418 num_active_compiler_thread++;
aoqi@0 419 }
aoqi@0 420 }
aoqi@0 421 }
aoqi@0 422
aoqi@0 423 if (num_active == 0) {
aoqi@0 424 return 0;
aoqi@0 425 } else if (attempts > max_wait) {
aoqi@0 426 return num_active;
aoqi@0 427 } else if (num_active_compiler_thread == 0 && attempts > max_wait_user_thread) {
aoqi@0 428 return num_active;
aoqi@0 429 }
aoqi@0 430
aoqi@0 431 attempts++;
aoqi@0 432
aoqi@0 433 MutexLockerEx ml(&timer, Mutex::_no_safepoint_check_flag);
aoqi@0 434 timer.wait(Mutex::_no_safepoint_check_flag, 10);
aoqi@0 435 }
aoqi@0 436 }
aoqi@0 437
aoqi@0 438 void VM_Exit::doit() {
aoqi@0 439 CompileBroker::set_should_block();
aoqi@0 440
aoqi@0 441 // Wait for a short period for threads in native to block. Any thread
aoqi@0 442 // still executing native code after the wait will be stopped at
aoqi@0 443 // native==>Java/VM barriers.
aoqi@0 444 // Among 16276 JCK tests, 94% of them come here without any threads still
aoqi@0 445 // running in native; the other 6% are quiescent within 250ms (Ultra 80).
aoqi@0 446 wait_for_threads_in_native_to_block();
aoqi@0 447
aoqi@0 448 set_vm_exited();
aoqi@0 449
aoqi@0 450 // cleanup globals resources before exiting. exit_globals() currently
aoqi@0 451 // cleans up outputStream resources and PerfMemory resources.
aoqi@0 452 exit_globals();
aoqi@0 453
aoqi@0 454 // Check for exit hook
aoqi@0 455 exit_hook_t exit_hook = Arguments::exit_hook();
aoqi@0 456 if (exit_hook != NULL) {
aoqi@0 457 // exit hook should exit.
aoqi@0 458 exit_hook(_exit_code);
aoqi@0 459 // ... but if it didn't, we must do it here
aoqi@0 460 vm_direct_exit(_exit_code);
aoqi@0 461 } else {
aoqi@0 462 vm_direct_exit(_exit_code);
aoqi@0 463 }
aoqi@0 464 }
aoqi@0 465
aoqi@0 466
aoqi@0 467 void VM_Exit::wait_if_vm_exited() {
aoqi@0 468 if (_vm_exited &&
aoqi@0 469 ThreadLocalStorage::get_thread_slow() != _shutdown_thread) {
aoqi@0 470 // _vm_exited is set at safepoint, and the Threads_lock is never released
aoqi@0 471 // we will block here until the process dies
aoqi@0 472 Threads_lock->lock_without_safepoint_check();
aoqi@0 473 ShouldNotReachHere();
aoqi@0 474 }
aoqi@0 475 }

mercurial