mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2024-11-26 22:00:25 +00:00
8247310: Shenandoah: pacer should not affect interrupt status
Reviewed-by: zgu
This commit is contained in:
parent
7a3bf58b8a
commit
9a4593b5ea
@ -27,6 +27,7 @@
|
||||
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
|
||||
#include "gc/shenandoah/shenandoahPacer.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
|
||||
/*
|
||||
* In normal concurrent cycle, we have to pace the application to let GC finish.
|
||||
@ -238,7 +239,7 @@ void ShenandoahPacer::pace_for_alloc(size_t words) {
|
||||
}
|
||||
|
||||
// Threads that are attaching should not block at all: they are not
|
||||
// fully initialized yet. Calling sleep() on them would be awkward.
|
||||
// fully initialized yet. Blocking them would be awkward.
|
||||
// This is probably the path that allocates the thread oop itself.
|
||||
// Forcefully claim without waiting.
|
||||
if (JavaThread::current()->is_attaching_via_jni()) {
|
||||
@ -263,7 +264,7 @@ void ShenandoahPacer::pace_for_alloc(size_t words) {
|
||||
}
|
||||
cur = MAX2<size_t>(1, cur);
|
||||
|
||||
JavaThread::current()->sleep(cur);
|
||||
wait(cur);
|
||||
|
||||
double end = os::elapsedTime();
|
||||
total = (size_t)((end - start) * 1000);
|
||||
@ -288,6 +289,19 @@ void ShenandoahPacer::pace_for_alloc(size_t words) {
|
||||
}
|
||||
}
|
||||
|
||||
void ShenandoahPacer::wait(long time_ms) {
|
||||
// Perform timed wait. It works like like sleep(), except without modifying
|
||||
// the thread interruptible status. MonitorLocker also checks for safepoints.
|
||||
assert(time_ms > 0, "Should not call this with zero argument, as it would stall until notify");
|
||||
MonitorLocker locker(_wait_monitor);
|
||||
_wait_monitor->wait(time_ms);
|
||||
}
|
||||
|
||||
void ShenandoahPacer::notify_waiters() {
|
||||
MonitorLocker locker(_wait_monitor);
|
||||
_wait_monitor->notify_all();
|
||||
}
|
||||
|
||||
void ShenandoahPacer::print_on(outputStream* out) const {
|
||||
out->print_cr("ALLOCATION PACING:");
|
||||
out->cr();
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
ShenandoahHeap* _heap;
|
||||
BinaryMagnitudeSeq _delays;
|
||||
TruncatedSeq* _progress_history;
|
||||
Monitor* _wait_monitor;
|
||||
|
||||
// Set once per phase
|
||||
volatile intptr_t _epoch;
|
||||
@ -63,6 +64,7 @@ public:
|
||||
ShenandoahPacer(ShenandoahHeap* heap) :
|
||||
_heap(heap),
|
||||
_progress_history(new TruncatedSeq(5)),
|
||||
_wait_monitor(new Monitor(Mutex::leaf, "_wait_monitor", true, Monitor::_safepoint_check_always)),
|
||||
_epoch(0),
|
||||
_tax_rate(1),
|
||||
_budget(0),
|
||||
@ -97,6 +99,9 @@ private:
|
||||
void restart_with(size_t non_taxable_bytes, double tax_rate);
|
||||
|
||||
size_t update_and_get_progress_history();
|
||||
|
||||
void wait(long time_ms);
|
||||
void notify_waiters();
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHPACER_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user