< prev index next >
src/share/vm/runtime/thread.cpp
Print this page
*** 93,102 ****
--- 93,103 ----
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
#include "utilities/macros.hpp"
#include "utilities/preserveException.hpp"
#if INCLUDE_ALL_GCS
+ #include "gc/shenandoah/shenandoahConcurrentThread.hpp"
#include "gc/cms/concurrentMarkSweepThread.hpp"
#include "gc/g1/concurrentMarkThread.inline.hpp"
#include "gc/parallel/pcTasks.hpp"
#endif // INCLUDE_ALL_GCS
#ifdef COMPILER1
*** 260,269 ****
--- 261,272 ----
_ParkEvent = ParkEvent::Allocate(this);
_SleepEvent = ParkEvent::Allocate(this);
_MutexEvent = ParkEvent::Allocate(this);
_MuxEvent = ParkEvent::Allocate(this);
+ _evacuating = false;
+
#ifdef CHECK_UNHANDLED_OOPS
if (CheckUnhandledOops) {
_unhandled_oops = new UnhandledOops(this);
}
#endif // CHECK_UNHANDLED_OOPS
*** 1263,1272 ****
--- 1266,1276 ----
return time_slept;
}
void WatcherThread::run() {
+
assert(this == watcher_thread(), "just checking");
this->record_stack_base_and_size();
this->initialize_thread_local_storage();
this->set_native_thread_name(this->name());
*** 1469,1485 ****
}
#if INCLUDE_ALL_GCS
SATBMarkQueueSet JavaThread::_satb_mark_queue_set;
DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
#endif // INCLUDE_ALL_GCS
JavaThread::JavaThread(bool is_attaching_via_jni) :
Thread()
#if INCLUDE_ALL_GCS
, _satb_mark_queue(&_satb_mark_queue_set),
! _dirty_card_queue(&_dirty_card_queue_set)
#endif // INCLUDE_ALL_GCS
{
initialize();
if (is_attaching_via_jni) {
_jni_attach_state = _attaching_via_jni;
--- 1473,1491 ----
}
#if INCLUDE_ALL_GCS
SATBMarkQueueSet JavaThread::_satb_mark_queue_set;
DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
+ bool JavaThread::_evacuation_in_progress_global = false;
#endif // INCLUDE_ALL_GCS
JavaThread::JavaThread(bool is_attaching_via_jni) :
Thread()
#if INCLUDE_ALL_GCS
, _satb_mark_queue(&_satb_mark_queue_set),
! _dirty_card_queue(&_dirty_card_queue_set),
! _evacuation_in_progress(_evacuation_in_progress_global)
#endif // INCLUDE_ALL_GCS
{
initialize();
if (is_attaching_via_jni) {
_jni_attach_state = _attaching_via_jni;
*** 1533,1543 ****
JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
Thread()
#if INCLUDE_ALL_GCS
, _satb_mark_queue(&_satb_mark_queue_set),
! _dirty_card_queue(&_dirty_card_queue_set)
#endif // INCLUDE_ALL_GCS
{
initialize();
_jni_attach_state = _not_attaching_via_jni;
set_entry_point(entry_point);
--- 1539,1550 ----
JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
Thread()
#if INCLUDE_ALL_GCS
, _satb_mark_queue(&_satb_mark_queue_set),
! _dirty_card_queue(&_dirty_card_queue_set),
! _evacuation_in_progress(_evacuation_in_progress_global)
#endif // INCLUDE_ALL_GCS
{
initialize();
_jni_attach_state = _not_attaching_via_jni;
set_entry_point(entry_point);
*** 1668,1678 ****
}
static void ensure_join(JavaThread* thread) {
// We do not need to grap the Threads_lock, since we are operating on ourself.
! Handle threadObj(thread, thread->threadObj());
assert(threadObj.not_null(), "java thread object must exist");
ObjectLocker lock(threadObj, thread);
// Ignore pending exception (ThreadDeath), since we are exiting anyway
thread->clear_pending_exception();
// Thread is exiting. So set thread_status field in java.lang.Thread class to TERMINATED.
--- 1675,1685 ----
}
static void ensure_join(JavaThread* thread) {
// We do not need to grap the Threads_lock, since we are operating on ourself.
! Handle threadObj(thread, oopDesc::bs()->write_barrier(thread->threadObj()));
assert(threadObj.not_null(), "java thread object must exist");
ObjectLocker lock(threadObj, thread);
// Ignore pending exception (ThreadDeath), since we are exiting anyway
thread->clear_pending_exception();
// Thread is exiting. So set thread_status field in java.lang.Thread class to TERMINATED.
*** 1862,1874 ****
#if INCLUDE_ALL_GCS
// We must flush the G1-related buffers before removing a thread
// from the list of active threads. We must do this after any deferred
// card marks have been flushed (above) so that any entries that are
// added to the thread's dirty card queue as a result are not lost.
! if (UseG1GC) {
flush_barrier_queues();
}
#endif // INCLUDE_ALL_GCS
// Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
Threads::remove(this);
}
--- 1869,1884 ----
#if INCLUDE_ALL_GCS
// We must flush the G1-related buffers before removing a thread
// from the list of active threads. We must do this after any deferred
// card marks have been flushed (above) so that any entries that are
// added to the thread's dirty card queue as a result are not lost.
! if (UseG1GC || UseShenandoahGC) {
flush_barrier_queues();
}
+ if (UseShenandoahGC && UseTLAB) {
+ gclab().make_parsable(true);
+ }
#endif // INCLUDE_ALL_GCS
// Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
Threads::remove(this);
}
*** 1899,1908 ****
--- 1909,1933 ----
DirtyCardQueue& dirty_queue = dirty_card_queue();
// The dirty card queue should have been constructed with its
// active field set to true.
assert(dirty_queue.is_active(), "dirty card queue should be active");
}
+
+ bool JavaThread::evacuation_in_progress() const {
+ return _evacuation_in_progress;
+ }
+
+ void JavaThread::set_evacuation_in_progress(bool in_prog) {
+ _evacuation_in_progress = in_prog;
+ }
+
+ void JavaThread::set_evacuation_in_progress_all_threads(bool in_prog) {
+ _evacuation_in_progress_global = in_prog;
+ for (JavaThread* t = Threads::first(); t; t = t->next()) {
+ t->set_evacuation_in_progress(in_prog);
+ }
+ }
#endif // INCLUDE_ALL_GCS
void JavaThread::cleanup_failed_attach_current_thread() {
if (get_thread_profiler() != NULL) {
get_thread_profiler()->disengage();
*** 1928,1940 ****
if (UseTLAB) {
tlab().make_parsable(true); // retire TLAB, if any
}
#if INCLUDE_ALL_GCS
! if (UseG1GC) {
flush_barrier_queues();
}
#endif // INCLUDE_ALL_GCS
Threads::remove(this);
delete this;
}
--- 1953,1968 ----
if (UseTLAB) {
tlab().make_parsable(true); // retire TLAB, if any
}
#if INCLUDE_ALL_GCS
! if (UseG1GC || UseShenandoahGC) {
flush_barrier_queues();
}
+ if (UseShenandoahGC && UseTLAB) {
+ gclab().make_parsable(true);
+ }
#endif // INCLUDE_ALL_GCS
Threads::remove(this);
delete this;
}
*** 2879,2888 ****
--- 2907,2917 ----
oop thread_obj = threadObj();
if (thread_obj != NULL) {
oop thread_group = java_lang_Thread::threadGroup(thread_obj);
if (thread_group != NULL) {
typeArrayOop name = java_lang_ThreadGroup::name(thread_group);
+ name = typeArrayOop(oopDesc::bs()->read_barrier(name));
// ThreadGroup.name can be null
if (name != NULL) {
const char* str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
return str;
}
*** 2898,2907 ****
--- 2927,2937 ----
oop thread_group = java_lang_Thread::threadGroup(thread_obj);
if (thread_group != NULL) {
oop parent = java_lang_ThreadGroup::parent(thread_group);
if (parent != NULL) {
typeArrayOop name = java_lang_ThreadGroup::name(parent);
+ name = typeArrayOop(oopDesc::bs()->read_barrier(name));
// ThreadGroup.name can be null
if (name != NULL) {
const char* str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
return str;
}
*** 3510,3522 ****
#if INCLUDE_ALL_GCS
// Support for ConcurrentMarkSweep. This should be cleaned up
// and better encapsulated. The ugly nested if test would go away
// once things are properly refactored. XXX YSR
! if (UseConcMarkSweepGC || UseG1GC) {
if (UseConcMarkSweepGC) {
ConcurrentMarkSweepThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
} else {
ConcurrentMarkThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
}
}
#endif // INCLUDE_ALL_GCS
--- 3540,3554 ----
#if INCLUDE_ALL_GCS
// Support for ConcurrentMarkSweep. This should be cleaned up
// and better encapsulated. The ugly nested if test would go away
// once things are properly refactored. XXX YSR
! if (UseConcMarkSweepGC || UseG1GC || UseShenandoahGC) {
if (UseConcMarkSweepGC) {
ConcurrentMarkSweepThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
+ } else if (UseShenandoahGC) {
+ ShenandoahConcurrentThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
} else {
ConcurrentMarkThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
}
}
#endif // INCLUDE_ALL_GCS
*** 3921,3930 ****
--- 3953,3965 ----
before_exit(thread);
thread->exit(true);
+ // Stop GC threads.
+ Universe::heap()->shutdown();
+
// Stop VM thread.
{
// 4945125 The vm thread comes to a safepoint during exit.
// GC vm_operations can get caught at the safepoint, and the
// heap is unparseable if they are caught. Grab the Heap_lock
< prev index next >