--- old/src/share/vm/gc_implementation/shared/suspendibleThreadSet.cpp 2015-04-09 18:21:15.375702111 -0400 +++ new/src/share/vm/gc_implementation/shared/suspendibleThreadSet.cpp 2015-04-09 18:21:15.263695689 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,16 +33,26 @@ double SuspendibleThreadSet::_suspend_all_start = 0.0; void SuspendibleThreadSet::join() { + assert(Thread::current()->is_suspendible_thread() == false, + "Thread already joined"); MonitorLockerEx ml(STS_lock, Mutex::_no_safepoint_check_flag); while (_suspend_all) { ml.wait(Mutex::_no_safepoint_check_flag); } _nthreads++; +#ifdef ASSERT + Thread::current()->set_suspendible_thread(); +#endif } void SuspendibleThreadSet::leave() { + assert(Thread::current()->is_suspendible_thread(), + "Thread not joined"); MonitorLockerEx ml(STS_lock, Mutex::_no_safepoint_check_flag); assert(_nthreads > 0, "Invalid"); +#ifdef ASSERT + Thread::current()->clear_suspendible_thread(); +#endif _nthreads--; if (_suspend_all) { ml.notify_all(); @@ -50,6 +60,7 @@ } void SuspendibleThreadSet::yield() { + assert(Thread::current()->is_suspendible_thread(), "Must have joined"); if (_suspend_all) { MonitorLockerEx ml(STS_lock, Mutex::_no_safepoint_check_flag); if (_suspend_all) {