hotspot/src/share/vm/runtime/thread.cpp
changeset 11636 3c07b54482a5
parent 11480 1bf714e8adb4
child 11637 030466036615
equal deleted inserted replaced
11635:5a16856f871f 11636:3c07b54482a5
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
  1598   if (!destroy_vm || JDK_Version::is_jdk12x_version()) {
  1598   if (!destroy_vm || JDK_Version::is_jdk12x_version()) {
  1599     // JSR-166: change call from from ThreadGroup.uncaughtException to
  1599     // JSR-166: change call from from ThreadGroup.uncaughtException to
  1600     // java.lang.Thread.dispatchUncaughtException
  1600     // java.lang.Thread.dispatchUncaughtException
  1601     if (uncaught_exception.not_null()) {
  1601     if (uncaught_exception.not_null()) {
  1602       Handle group(this, java_lang_Thread::threadGroup(threadObj()));
  1602       Handle group(this, java_lang_Thread::threadGroup(threadObj()));
  1603       Events::log("uncaught exception INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT",
       
  1604         (address)uncaught_exception(), (address)threadObj(), (address)group());
       
  1605       {
  1603       {
  1606         EXCEPTION_MARK;
  1604         EXCEPTION_MARK;
  1607         // Check if the method Thread.dispatchUncaughtException() exists. If so
  1605         // Check if the method Thread.dispatchUncaughtException() exists. If so
  1608         // call it.  Otherwise we have an older library without the JSR-166 changes,
  1606         // call it.  Otherwise we have an older library without the JSR-166 changes,
  1609         // so call ThreadGroup.uncaughtException()
  1607         // so call ThreadGroup.uncaughtException()
  3883   }
  3881   }
  3884 
  3882 
  3885   ThreadService::add_thread(p, daemon);
  3883   ThreadService::add_thread(p, daemon);
  3886 
  3884 
  3887   // Possible GC point.
  3885   // Possible GC point.
  3888   Events::log("Thread added: " INTPTR_FORMAT, p);
  3886   Events::log(p, "Thread added: " INTPTR_FORMAT, p);
  3889 }
  3887 }
  3890 
  3888 
  3891 void Threads::remove(JavaThread* p) {
  3889 void Threads::remove(JavaThread* p) {
  3892   // Extra scope needed for Thread_lock, so we can check
  3890   // Extra scope needed for Thread_lock, so we can check
  3893   // that we do not remove thread without safepoint code notice
  3891   // that we do not remove thread without safepoint code notice
  3928     // of this thread since it is removed from the queue.
  3926     // of this thread since it is removed from the queue.
  3929     p->set_terminated_value();
  3927     p->set_terminated_value();
  3930   } // unlock Threads_lock
  3928   } // unlock Threads_lock
  3931 
  3929 
  3932   // Since Events::log uses a lock, we grab it outside the Threads_lock
  3930   // Since Events::log uses a lock, we grab it outside the Threads_lock
  3933   Events::log("Thread exited: " INTPTR_FORMAT, p);
  3931   Events::log(p, "Thread exited: " INTPTR_FORMAT, p);
  3934 }
  3932 }
  3935 
  3933 
  3936 // Threads_lock must be held when this is called (or must be called during a safepoint)
  3934 // Threads_lock must be held when this is called (or must be called during a safepoint)
  3937 bool Threads::includes(JavaThread* p) {
  3935 bool Threads::includes(JavaThread* p) {
  3938   assert(Threads_lock->is_locked(), "sanity check");
  3936   assert(Threads_lock->is_locked(), "sanity check");