src/share/vm/gc_implementation/shared/concurrentGCThread.cpp

Print this page




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "gc_implementation/shared/concurrentGCThread.hpp"
  28 #include "oops/instanceRefKlass.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/init.hpp"
  31 #include "runtime/interfaceSupport.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/javaCalls.hpp"

  34 
  35 // CopyrightVersion 1.2
  36 
  37 int  ConcurrentGCThread::_CGC_flag            = CGC_nil;
  38 
  39 SuspendibleThreadSet ConcurrentGCThread::_sts;
  40 
  41 ConcurrentGCThread::ConcurrentGCThread() :
  42   _should_terminate(false), _has_terminated(false) {
  43   _sts.initialize();
  44 };
  45 
  46 void ConcurrentGCThread::safepoint_synchronize() {
  47   _sts.suspend_all();
  48 }
  49 
  50 void ConcurrentGCThread::safepoint_desynchronize() {
  51   _sts.resume_all();
  52 }
  53 


 189   JavaValue result(T_VOID);
 190   JavaCalls::call_special(&result, thread_oop,
 191                           klass,
 192                           vmSymbols::object_initializer_name(),
 193                           vmSymbols::threadgroup_string_void_signature(),
 194                           thread_group,
 195                           string,
 196                           CHECK_NULL);
 197 
 198   SurrogateLockerThread* res;
 199   {
 200     MutexLocker mu(Threads_lock);
 201     res = new SurrogateLockerThread();
 202 
 203     // At this point it may be possible that no osthread was created for the
 204     // JavaThread due to lack of memory. We would have to throw an exception
 205     // in that case. However, since this must work and we do not allow
 206     // exceptions anyway, check and abort if this fails.
 207     if (res == NULL || res->osthread() == NULL) {
 208       vm_exit_during_initialization("java.lang.OutOfMemoryError",
 209                                     "unable to create new native thread");
 210     }
 211     java_lang_Thread::set_thread(thread_oop(), res);
 212     java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
 213     java_lang_Thread::set_daemon(thread_oop());
 214 
 215     res->set_threadObj(thread_oop());
 216     Threads::add(res);
 217     Thread::start(res);
 218   }
 219   os::yield(); // This seems to help with initial start-up of SLT
 220   return res;
 221 }
 222 
 223 void SurrogateLockerThread::manipulatePLL(SLT_msg_type msg) {
 224   MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
 225   assert(_buffer == empty, "Should be empty");
 226   assert(msg != empty, "empty message");
 227   assert(!Heap_lock->owned_by_self(), "Heap_lock owned by requesting thread");
 228 
 229   _buffer = msg;




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "gc_implementation/shared/concurrentGCThread.hpp"
  28 #include "oops/instanceRefKlass.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/init.hpp"
  31 #include "runtime/interfaceSupport.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/javaCalls.hpp"
  34 #include "runtime/os.hpp"
  35 
  36 // CopyrightVersion 1.2
  37 
  38 int  ConcurrentGCThread::_CGC_flag            = CGC_nil;
  39 
  40 SuspendibleThreadSet ConcurrentGCThread::_sts;
  41 
  42 ConcurrentGCThread::ConcurrentGCThread() :
  43   _should_terminate(false), _has_terminated(false) {
  44   _sts.initialize();
  45 };
  46 
  47 void ConcurrentGCThread::safepoint_synchronize() {
  48   _sts.suspend_all();
  49 }
  50 
  51 void ConcurrentGCThread::safepoint_desynchronize() {
  52   _sts.resume_all();
  53 }
  54 


 190   JavaValue result(T_VOID);
 191   JavaCalls::call_special(&result, thread_oop,
 192                           klass,
 193                           vmSymbols::object_initializer_name(),
 194                           vmSymbols::threadgroup_string_void_signature(),
 195                           thread_group,
 196                           string,
 197                           CHECK_NULL);
 198 
 199   SurrogateLockerThread* res;
 200   {
 201     MutexLocker mu(Threads_lock);
 202     res = new SurrogateLockerThread();
 203 
 204     // At this point it may be possible that no osthread was created for the
 205     // JavaThread due to lack of memory. We would have to throw an exception
 206     // in that case. However, since this must work and we do not allow
 207     // exceptions anyway, check and abort if this fails.
 208     if (res == NULL || res->osthread() == NULL) {
 209       vm_exit_during_initialization("java.lang.OutOfMemoryError",
 210                                     os::native_thread_creation_failed_msg());
 211     }
 212     java_lang_Thread::set_thread(thread_oop(), res);
 213     java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
 214     java_lang_Thread::set_daemon(thread_oop());
 215 
 216     res->set_threadObj(thread_oop());
 217     Threads::add(res);
 218     Thread::start(res);
 219   }
 220   os::yield(); // This seems to help with initial start-up of SLT
 221   return res;
 222 }
 223 
 224 void SurrogateLockerThread::manipulatePLL(SLT_msg_type msg) {
 225   MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
 226   assert(_buffer == empty, "Should be empty");
 227   assert(msg != empty, "empty message");
 228   assert(!Heap_lock->owned_by_self(), "Heap_lock owned by requesting thread");
 229 
 230   _buffer = msg;


TPATH=src/share/vm/gc_implementation/shared WDIR=/scratch/iklam/jdk/hotspot-rt9/webrev RTOP=../../../../..