mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8188919: Generalize GC thread suspend/resume at safepoints
Reviewed-by: pliden, rkennke
This commit is contained in:
parent
e8fe842a41
commit
9adfa12663
6 changed files with 26 additions and 21 deletions
|
@ -134,6 +134,14 @@ void CMSHeap::stop() {
|
||||||
ConcurrentMarkSweepThread::cmst()->stop();
|
ConcurrentMarkSweepThread::cmst()->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMSHeap::safepoint_synchronize_begin() {
|
||||||
|
ConcurrentMarkSweepThread::synchronize(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMSHeap::safepoint_synchronize_end() {
|
||||||
|
ConcurrentMarkSweepThread::desynchronize(false);
|
||||||
|
}
|
||||||
|
|
||||||
void CMSHeap::cms_process_roots(StrongRootsScope* scope,
|
void CMSHeap::cms_process_roots(StrongRootsScope* scope,
|
||||||
bool young_gen_as_roots,
|
bool young_gen_as_roots,
|
||||||
ScanningOption so,
|
ScanningOption so,
|
||||||
|
|
|
@ -79,6 +79,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
void safepoint_synchronize_begin();
|
||||||
|
void safepoint_synchronize_end();
|
||||||
|
|
||||||
// If "young_gen_as_roots" is false, younger generations are
|
// If "young_gen_as_roots" is false, younger generations are
|
||||||
// not scanned as roots; in this case, the caller must be arranging to
|
// not scanned as roots; in this case, the caller must be arranging to
|
||||||
|
|
|
@ -1842,6 +1842,14 @@ void G1CollectedHeap::stop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void G1CollectedHeap::safepoint_synchronize_begin() {
|
||||||
|
SuspendibleThreadSet::synchronize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void G1CollectedHeap::safepoint_synchronize_end() {
|
||||||
|
SuspendibleThreadSet::desynchronize();
|
||||||
|
}
|
||||||
|
|
||||||
size_t G1CollectedHeap::conservative_max_heap_alignment() {
|
size_t G1CollectedHeap::conservative_max_heap_alignment() {
|
||||||
return HeapRegion::max_region_size();
|
return HeapRegion::max_region_size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -968,6 +968,8 @@ public:
|
||||||
jint initialize();
|
jint initialize();
|
||||||
|
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
virtual void safepoint_synchronize_begin();
|
||||||
|
virtual void safepoint_synchronize_end();
|
||||||
|
|
||||||
// Return the (conservative) maximum heap alignment for any G1 heap
|
// Return the (conservative) maximum heap alignment for any G1 heap
|
||||||
static size_t conservative_max_heap_alignment();
|
static size_t conservative_max_heap_alignment();
|
||||||
|
|
|
@ -221,6 +221,10 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||||
// Stop any onging concurrent work and prepare for exit.
|
// Stop any onging concurrent work and prepare for exit.
|
||||||
virtual void stop() {}
|
virtual void stop() {}
|
||||||
|
|
||||||
|
// Stop and resume concurrent GC threads interfering with safepoint operations
|
||||||
|
virtual void safepoint_synchronize_begin() {}
|
||||||
|
virtual void safepoint_synchronize_end() {}
|
||||||
|
|
||||||
void initialize_reserved_region(HeapWord *start, HeapWord *end);
|
void initialize_reserved_region(HeapWord *start, HeapWord *end);
|
||||||
MemRegion reserved_region() const { return _reserved; }
|
MemRegion reserved_region() const { return _reserved; }
|
||||||
address base() const { return (address)reserved_region().start(); }
|
address base() const { return (address)reserved_region().start(); }
|
||||||
|
|
|
@ -63,10 +63,6 @@
|
||||||
#include "trace/traceMacros.hpp"
|
#include "trace/traceMacros.hpp"
|
||||||
#include "utilities/events.hpp"
|
#include "utilities/events.hpp"
|
||||||
#include "utilities/macros.hpp"
|
#include "utilities/macros.hpp"
|
||||||
#if INCLUDE_ALL_GCS
|
|
||||||
#include "gc/cms/concurrentMarkSweepThread.hpp"
|
|
||||||
#include "gc/g1/suspendibleThreadSet.hpp"
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
|
||||||
#ifdef COMPILER1
|
#ifdef COMPILER1
|
||||||
#include "c1/c1_globals.hpp"
|
#include "c1/c1_globals.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,15 +90,7 @@ void SafepointSynchronize::begin() {
|
||||||
_ts_of_current_safepoint = tty->time_stamp().seconds();
|
_ts_of_current_safepoint = tty->time_stamp().seconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INCLUDE_ALL_GCS
|
Universe::heap()->safepoint_synchronize_begin();
|
||||||
if (UseConcMarkSweepGC) {
|
|
||||||
// In the future we should investigate whether CMS can use the
|
|
||||||
// more-general mechanism below. DLD (01/05).
|
|
||||||
ConcurrentMarkSweepThread::synchronize(false);
|
|
||||||
} else if (UseG1GC) {
|
|
||||||
SuspendibleThreadSet::synchronize();
|
|
||||||
}
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
|
||||||
|
|
||||||
// By getting the Threads_lock, we assure that no threads are about to start or
|
// By getting the Threads_lock, we assure that no threads are about to start or
|
||||||
// exit. It is released again in SafepointSynchronize::end().
|
// exit. It is released again in SafepointSynchronize::end().
|
||||||
|
@ -512,14 +500,7 @@ void SafepointSynchronize::end() {
|
||||||
Threads_lock->unlock();
|
Threads_lock->unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
#if INCLUDE_ALL_GCS
|
Universe::heap()->safepoint_synchronize_end();
|
||||||
// If there are any concurrent GC threads resume them.
|
|
||||||
if (UseConcMarkSweepGC) {
|
|
||||||
ConcurrentMarkSweepThread::desynchronize(false);
|
|
||||||
} else if (UseG1GC) {
|
|
||||||
SuspendibleThreadSet::desynchronize();
|
|
||||||
}
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
|
||||||
// record this time so VMThread can keep track how much time has elapsed
|
// record this time so VMThread can keep track how much time has elapsed
|
||||||
// since last safepoint.
|
// since last safepoint.
|
||||||
_end_of_last_safepoint = os::javaTimeMillis();
|
_end_of_last_safepoint = os::javaTimeMillis();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue